Skip to content

x/mobile: enable building frameworks for Catalyst #36856

Closed
@losh11

Description

@losh11

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. In x/mobile/cmd/gomobile/env.go, add a new case "catalyst" for function envInit which looks like this:

case "catalyst":
    clang, cflags, err = envClang('macosx')
    cflags += " -target x86_64-apple-ios13.0-macabi"

Activity

added this to the Unreleased milestone on Jan 29, 2020
losh11

losh11 commented on Feb 1, 2020

@losh11
Author

@hyangah if y'all are okay with this, I can implement?

agnivade

agnivade commented on Feb 2, 2020

@agnivade
Contributor

All yours !

added
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
on Feb 6, 2020
damiandizeo

damiandizeo commented on Mar 24, 2020

@damiandizeo

@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 ?

losh11

losh11 commented on Mar 24, 2020

@losh11
Author

@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 x86_64h as required by catalyst.

damiandizeo

damiandizeo commented on Mar 24, 2020

@damiandizeo

@losh11 thanks, adding the cflag '-target x86_64-apple-ios13.0-macabi', was able to compile the framework and now runs under Mac Catalyst

losh11

losh11 commented on Mar 25, 2020

@losh11
Author

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.

added a commit that references this issue on Apr 1, 2020
dpwiese

dpwiese commented on Apr 1, 2020

@dpwiese

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 envInit() for each architecture in allArchs. Support for catalyst needs to provide an additional configuring, but for the existing amd64 architecture. I don't think it makes sense to add catalyst to allArchs as a new architecture, as it is not. Treating it as such seems like a poor choice, and furthermore would require many changes throughout to support it if added as a new "architecture".

Rather, when setting up the environment in envInit() I've simply included it as an additional case alongside the existing true architectures. I've opened a (draft) PR with the current proposed solution here: golang/mobile#45

Feedback is appreciated, after which I'll mark ready for review. 🚀

gopherbot

gopherbot commented on Jul 8, 2021

@gopherbot
Contributor

Change https://golang.org/cl/310949 mentions this issue: mobile: support macOS and Catalyst

31 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.help wantedmobileAndroid, iOS, and x/mobile

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Participants

      @hajimehoshi@ydnar@cagedmantis@networkimprov@agnivade

      Issue actions

        x/mobile: enable building frameworks for Catalyst · Issue #36856 · golang/go