-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
x/mobile: enable building frameworks for Catalyst #36856
Comments
@hyangah if y'all are okay with this, I can implement? |
All yours ! |
@losh11 added a new case "catalyst" for function envInit , but when I do 'gomobile bind' and create the .framework, Xcode still displaying error in when building on macOS Catalyst. Am I missing something ? |
@damiandizeo I'm not able to check exactly what you've done without a full set of diffs. This likely means your framework is not build for |
@losh11 thanks, adding the cflag '-target x86_64-apple-ios13.0-macabi', was able to compile the framework and now runs under Mac Catalyst |
Great to hear @damiandizeo, if you or anyone else has time to implement this, that would be awesome. Unfortunately I no longer have the time to do this myself. |
See: golang/go#36856 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: ``` error: Building for Mac Catalyst, but the linked framework 'Sample.framework' was built for iOS + iOS Simulator. You may need to restrict the platforms for which this framework should be linked in the target editor, or replace it with an XCFramework that supports both platforms. (in target 'MySampleApp' from project 'MySampleApp') ``` This commit adds a case for catalyst (although architecture is just amd64) when configuring the environment for each architecture, providing the flags needed to enable the built .Framework to be used with catalyst.
I looked at this quickly last night, and had a bit of trouble coming up with a solution as elegant as I had hoped. The environment is configured in Rather, when setting up the environment in Feedback is appreciated, after which I'll mark ready for review. 🚀 |
Change https://golang.org/cl/310949 mentions this issue: |
@hyangah Could you take a look at the PR? I've already looked and this seems overall good to me. |
Awesome thanks for merging guys! I wonder if there's now interest for adding support for Windows? Not very familiar with Windows libraries. |
After this change, I found that some of my libraries cannot be built with gomobile. For example, the library uses UIKit, but this build fails with 'macos' target:
I'm not sure the convention of Catalyst. Is this a usual thing? Would it be fine to add an option to select targets, or would it be better to fix my code? EDIT: My current understanding is that I should fix my code with |
Maybe we should add build tags for macos and catalyst? Edit: UIKit is available in maccatalyst target. Have you tried building for maccatalyst? |
I think we should stop using ios build tag for macos and catalyst, and this might require Go change (#42100). |
I tried the targets |
I can take a look. Do you have a project or branch I can check out? |
Thanks, but it's a little complicated: I'm using ebitenmobile that wraps gomobile, so this might not be a good project for testing... Would it be possible to add a test that just uses UIKit? |
Just in case, what I am currently doing is
|
I’d try this.
|
@hajimehoshi I think I’m getting close with a fix for Edit: you can see the WIP branch here: |
Thanks!
|
The I just landed a commit that expands the You can get fancy and specify multiple targets which will be compiled into a single XCFramework like this:
TODO: add consistent build tags for each platform, specific to that platform and |
Hmm, I'm not sure it'd be appropriate when GOOS is |
They’re not exclusive. Edit: I’m open to being convinced otherwise! Making the Is there a macOS gobot build for the mobile repo? |
So another question is, would it make sense to make them exclusive? In Catalyst, should we think the environment is macOS and iOS at the same time? |
I suppose macCatalyst could imply the build tags |
IIUC, on Catalyst, |
@hajimehoshi can you reopen this issue? The previous CL closed it automatically. |
@hajimehoshi does ebitenmobile build with the new branch? |
ebitenmobile is a wrapper of gomobile, not a fork. |
@hajimehoshi so I got this ^ to mostly work. I had to add an additional cflag However, it stopped here: https://github.com/hajimehoshi/ebiten/blob/f1fc6fe3e8819d06c651620e8b30d95faf612de0/cmd/ebitenmobile/main.go#L226 2021/07/22 08:15:30 open ios/mobile/ios/Mobile.xcframework/Versions/A/Headers/MobileEbitenViewController.h: no such file or directory
exit status 1 Presumably because it’s trying to manipulate a The
|
Yeah MobileEbitenViewController.h is inserted by ebitenmobile after .framework is generated by gomobile, then your guess seems correct. Thank you for testing! |
@losh11 This is fixed in golang/mobile@6d8ad35e (golang/mobile#70). |
As of macOS 10.15, users can build iPad apps to run on macOS using Catalyst. However if you build a framework using gomobile, even though the framework has support for
x86_64
, Xcode will display an error.To fix this, all you need to do is target clang for the macOS sdk & add a cflag with
-target x86_64-apple-ios13.0-macabi
. Fully tested example below.Gomobile should support specifying a target
catalyst
. Inx/mobile/cmd/gomobile/env.go
, add a new case"catalyst"
for functionenvInit
which looks like this:The text was updated successfully, but these errors were encountered: