Skip to content

Unable to build on M1 Mac (XCFramework has architecture ios-arm64, but not ios-arm64-simulator) #337

Open
@lufinkey

Description

@lufinkey

Project: nodejs-mobile
Version: latest
Mobile device: iPhone 12 Pro Max Simulator
Mobile OS and version: M1 Macbook 13"
Development Node.js: 14.17.5
Development platform: Darwin Nicks-MBP 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:40:21 PST 2020; root:xnu-7195.60.75~1/RELEASE_ARM64_T8101 arm64

When building for iOS Simulator in Xcode on an M1 mac, you cannot link directly against NodeMobile.framework. You will get the error building for ios simulator but the linked framework NodeMobile was built for iOS. So you must link against NodeMobile.xcframework.

However, since the iOS simulator is arm64 on an M1 mac, xcode looks for the ios-arm64-simulator slice inside the xcframework. Unfortunately, for some reason, the generated xcframework only contains ios-x86_64-simulator and ios-arm64. I've tried generating a new arm64 simulator framework by copying this line, changing the sdk to iphonesimulator, and building to a different location, but unfortunately xcode detects the libnode (and libuv etc...) architectures as built for iOS, not iOS simulator. So somehow libnode (and libuv and all the rest), need to be built using arm64, but specifically linked against the iOS Simulator SDK, not the iOS SDK.

I would make the change myself, but I don't know enough about cmake and the rest of the build system to do it. But basically all the dependent libraries and NodeMobile just need another architecture slice in the xcframework. As it stands though, supporting this would seem to require switching to building and linking against an xcframework by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions