Skip to content
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

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

Open
lufinkey opened this issue Aug 16, 2021 · 2 comments

Comments

@lufinkey
Copy link

lufinkey commented Aug 16, 2021

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.

@kewlbear
Copy link

I've made pull request #340 for this.

@kewlbear
Copy link

I've also made a Swift package out of this. https://github.com/kewlbear/nodejs-ios

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants