Reputation: 3187
When I try to integrate a framework into an iOS app, then building will fail on an M1 MacBook (i.e., Apple Silicon), but does not fail on an Intel Mac. This occurs with the default build settings on the latest Xcode and also the latest Xcode Beta. The error is as follows:
ld: building for iOS Simulator, but linking in object file built for iOS, file '/.../testm1/GooglePlaces.framework/GooglePlaces' for architecture arm64
clang: error: linker command failed with exit code 1 (use - v to see invocation)
I tried to check which architectures are included in the framework, then I am presented with the following info:
Command:
lipo -info GooglePlaces.framework/GooglePlaces
Output:
GooglePlaces.framework/GooglePlaces: Mach-O universal binary with 2 architectures: [x86_64cMach-O 64-bit object x86_64] [arm64]
GooglePlaces.framework/GooglePlaces (for architecture x86_64): Mach-O 64-bit object x86_64
GooglePlaces.framework/GooglePlaces (for architecture arm64): Mach-O 64-bit object arm64
and I also tried to check with 'file':
Command:
file GooglePlaces.framework/GooglePlaces
Output:
GooglePlaces.framework/GooglePlaces: Mach-O universal binary with 2 architectures: [x86_64cMach-O 64-bit object x86_64] [arm64]
GooglePlaces.framework/GooglePlaces (for architecture x86_64): Mach-O 64-bit object x86_64
GooglePlaces.framework/GooglePlaces (for architecture arm64): Mach-O 64-bit object arm64
Both commands show that it contains arm64.
Configuration:
MacBook Pro. 13'' M1 2020,
16 GB
Big Sur 11.4
Xcode 12.5.1 & Xcode 13.0 (Beta 3)
Steps to reproduce:
ld: building for iOS Simulator, but linking in object file built for iOS, file '/.../testm1/GooglePlaces.framework/GooglePlaces' for architecture arm64
clang: error: linker command failed with exit code 1 (use - v to see invocation)
Questions:
As suggested:
I excluded the arm64 for any ios simulators - then building is successful. BUT: When I want to test the project without a host application the following error occurs:
2021-07-21 12:07:54.021519+0200 xctest[84732:517962] The bundle “testm1Tests” couldn’t be loaded because it doesn’t contain a version for the current architecture. Try installing a universal version of the bundle.
2021-07-21 12:07:54.021692+0200 xctest[84732:517962] (dlopen_preflight(/.../Build/Products/Debug-iphonesimulator/testm1Tests.xctest/testm1Tests): no suitable image found. Did find:
/.../Library/Developer/Xcode/DerivedData/testm1-bkwdzlmojcaocfabaqfrhjnlzfim/Build/Products/Debug-iphonesimulator/testm1Tests.xctest/testm1Tests: mach-o, but wrong architecture)
Program ended with exit code: 80
A workaround option:
Rosetta
. Then you will have no issues with any of those erros. I know that's not the best workaround as Apple may remove Rosetta
in future MacOS releases.Upvotes: 3
Views: 1637
Reputation: 133
Since you have specifically mentioned you are trying to build Google Places on M1 Mac, this is not possible was of now since GooglePlaces has not been updated to the new XCFrameworks,
Even you can check out the open issue here: https://github.com/googlemaps/google-maps-ios-utils/issues/355
Moreover for any frameworks to be run on M1 Mac simulator they should be shipped as XCFramework or you could as of now run on a physical device
Or apart from Google Places, for other frameworks you could use Carthage to consume them as xcframework by the use of below commnand:
carthage update --use-xcframeworks
Upvotes: 4
Reputation: 150565
In your project go to the
Upvotes: 1