-
Notifications
You must be signed in to change notification settings - Fork 787
Support building for target catalyst #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This PR (HEAD: a7f75e2) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/mobile/+/226817 to see it. Tip: You can toggle comments from me using the |
Message from Gobot Gobot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/226817. |
Message from Hyang-Ah Hana Kim: Patch Set 1: Run-TryBot+1 (4 comments) How do you expect users to specify the 'catalyst' as the target os? (-target flag?) Please don’t reply on this GitHub thread. Visit golang.org/cl/226817. |
Message from Gobot Gobot: Patch Set 1: TryBots beginning. Status page: https://farmer.golang.org/try?commit=155879fb Please don’t reply on this GitHub thread. Visit golang.org/cl/226817. |
Message from Gobot Gobot: Patch Set 1: TryBot-Result+1 TryBots are happy. Please don’t reply on this GitHub thread. Visit golang.org/cl/226817. |
After having opened this (draft) PR implementing the suggestion in golang/go#36856, I realized I was quite naive and the solution will be more involved than what I'd previously and optimistically hoped. I managed to spend a few moments looking back at this, and here's what I've learned. Each of the different architectures is used to build a corresponding static library which is ultimately combined with
It is simple enough to create a separate
I think this approach should work, and I probably just need to spend some time learning |
I think Apple recently introduced .xcframework to solve exactly this packaging problem. |
I looked into this quickly last night and it does seem to be a promising, and probably the best, solution forwards. I was able to quickly generate a working This was not a smooth process though, with the first attempt giving:
This was easily solved by converting
so I need to better understand what is going on and change how the
But I haven't yet verified that this is (or is not) truly the case. Regardless, using |
- This commit generates separate .framework for each architecture - Combining the frameworks with `xcodebuild -create-xcframework` results in an .xcframework that works on iOS, simulator, and catalyst - An "equivalent library definitions" error was encountered when including armv7 and i386 architectures - See: golang#45 (comment)
I implemented the commit locally: How to invoke it? |
What is in a7f75e2 will not work. See the discussion above: #45 (comment). If you need to get a solution you can see: dpwiese#1 - it's WIP but should get the job done. It will allow you to generate a separate |
Actually it worked.
Then deleted the Xcode cache, checked the macOS box and build the macOS target. |
@thstart - it "works" in that you'll get a build for architecture If sacrificing iOS simulator support is an acceptable compromise for you to be able to support Catalyst, then you'll be just fine. But that was not at all the intention of this, and a problem that is nominally solved in dpwiese#1 with |
I'm testing only on physical devices so simulator doesn't matter. I will look at .xcframework solution, but don't see steps in what to do. But after testing it on a Mac - the performance is very slow. Are there a way optimize it? |
Any update on this feature? |
@thstart - I've done no work on this since what has been in dpwiese#1 and the comment dpwiese#1 (comment) which I hope is helpful. I don't have any insight at the moment regarding performance on Mac. |
Message from Go Bot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/226817. |
Message from Go Bot: Patch Set 1: TryBots beginning. Status page: https://farmer.golang.org/try?commit=155879fb Please don’t reply on this GitHub thread. Visit golang.org/cl/226817. |
Message from Go Bot: Patch Set 1: TryBot-Result+1 TryBots are happy. Please don’t reply on this GitHub thread. Visit golang.org/cl/226817. |
Anything I can help to move this one forward? |
@imWildCat - I think the main effort needed here is better defining the spec. Is it acceptable to drop support for |
@dpwiese thanks for your reply! I think generating xcframeork is the only way to do, especially for Xcode 12.3 or newer version: https://developer.apple.com/forums/thread/669411 Fat frameworks are no longer supported. |
@imWildCat great, and thanks for the helpful link. I'll try to have a look at this on the weekend. |
@imWildCat I updated this in dpwiese#2 and it is working again, now with go1.15 which has dropped support for some 32-bit architectures. I've got to fix the tests |
a7f75e2
to
6cad7ff
Compare
This PR (HEAD: 6cad7ff) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/mobile/+/226817 to see it. Tip: You can toggle comments from me using the |
in addition to this you can create a valid xcframework doing this mkdir arm
gomobile bind -ldflags="-w -s" -target=ios/arm64,ios/arm -o ./arm/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
xcodebuild -create-xcframework \
-framework ./arm/Openpgp.framework \
-framework ./amd64/Openpgp.framework \
-output Openpgp.xcframework the final xcframework should looks like this a ./Openpgp.xcframework
a ./Openpgp.xcframework/ios-x86_64-simulator
a ./Openpgp.xcframework/Info.plist
a ./Openpgp.xcframework/ios-arm64_armv7
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Openpgp
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Resources
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Versions
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Headers
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Modules
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Versions/A
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Versions/Current
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Versions/A/Openpgp
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Versions/A/Resources
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Versions/A/Headers
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Versions/A/Modules
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Versions/A/Modules/module.modulemap
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Versions/A/Headers/Openpgp.objc.h
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Versions/A/Headers/ref.h
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Versions/A/Headers/Openpgp.h
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Versions/A/Headers/Universe.objc.h
a ./Openpgp.xcframework/ios-arm64_armv7/Openpgp.framework/Versions/A/Resources/Info.plist
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Openpgp
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Resources
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Versions
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Headers
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Modules
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Versions/A
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Versions/Current
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Versions/A/Openpgp
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Versions/A/Resources
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Versions/A/Headers
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Versions/A/Modules
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Versions/A/Modules/module.modulemap
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Versions/A/Headers/Openpgp.objc.h
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Versions/A/Headers/ref.h
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Versions/A/Headers/Openpgp.h
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Versions/A/Headers/Universe.objc.h
a ./Openpgp.xcframework/ios-x86_64-simulator/Openpgp.framework/Versions/A/Resources/Info.plist I'm using go 1.14.13 |
Closing. It seems #65 represents the current evolution of this work. |
Add support for macOS (non-Catalyst) and Catalyst targets. The compiled library is packaged into a "fat" XCFramework file (as opposed to a Framework), which includes binaries for iOS, macOS, MacCatalyst (iOS on macOS), and iOS Simulator targets, for amd64 and arm64 architectures. The generated XCFramework file is suitable for distribution as a binary Swift Package Manager package: https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages This change is based on earlier work: #45 #63 Fixes golang/go#36856 Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf GitHub-Last-Rev: 623f8f3 GitHub-Pull-Request: #65 Reviewed-on: https://go-review.googlesource.com/c/mobile/+/310949 Reviewed-by: Hyang-Ah Hana Kim <[email protected]> Reviewed-by: Hajime Hoshi <[email protected]> Trust: Hyang-Ah Hana Kim <[email protected]> Trust: Hajime Hoshi <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: Go Bot <[email protected]>
As of macOS 10.15 target catalyst can be used to build an iPad app to run on macOS. Existing
.Framework
built with gomobile produces the following error when targetting catalyst:This PR adds a case for catalyst (although architecture is justamd64
) when configuring the environment for each architecture, providing the flags needed to enable the built.Framework
to be used with catalyst.Fixes golang/go#36856
Update 18-Jan-2021
This PR has been updated to provide nominally working support of
.xcframework
generation with go1.15, which has removed support for some 32 bit architectures. See: dpwiese#1 (comment). In addition, unlike dpwiese#1 this PR doesn't require manual thinning or combining of the generated.framework
s for each of the various "architectures" - this is now done automatically.Todo
Running
go test
fails with the following.Note: on current
master
branchTestIOSBuild
fails