generate .xcframework file with gomobile

1k Views Asked by At

Is it possible to generate .xcframework file with gomobile?

I built the .framework file with gomobile with the following command:

gomobile bind -target ios -o ../frameworks/MyFramework.framework

After that I tried to build .xcframework file with this command

xcodebuild -create-xcframework -framework "MyFramework.framework" -output "MyFramework.xcframework"

But it shows error:

error: binaries with multiple platforms are not supported '/Users/nicco/myFramework/MyFramework.framework/MyFramework'

So looks like the problem is in gomobile framework generation process.

So I see 2 solutions:

  1. To generate .xcframework file with gomobile.
  2. Change the .framework build process for being able to convert .framework generated file to .xcframework

How to do it?

1

There are 1 best solutions below

0
On

this could help to generate and xcframework

you need to generate a framework for each architecture

mkdir arm64
gomobile bind -ldflags="-w -s" -target=ios/arm64 -o ./arm64/Openpgp.framework github.com/jerson/openpgp-mobile/openpgp

mkdir amd64
gomobile bind -ldflags="-w -s" -target=ios/amd64 -o ./amd64/Openpgp.framework github.com/jerson/openpgp-mobile/openpgp

and then just merge with xcode command

xcodebuild -create-xcframework \
    -framework ./arm64/Openpgp.framework \
    -framework ./amd64/Openpgp.framework \
    -output Openpgp.xcframework

and thats all, hope this help