Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building project for M1 Mac fails because of architectures it believes are missing

We have a project that uses many AWS libraries. On first attempting to build it, using carthage, it downloaded binaries and it did not build at all. So we ran carthage --no-use-binaries and it built the libs.

Then this error occurs:

LoginService.swift:9:8: Module 'AWSMobileClient' was created for incompatible target arm64-apple-ios9.0: ..Carthage/Build/iOS/AWSMobileClient.framework/Modules/AWSMobileClient.swiftmodule/arm64.swiftmodule

Based on this stack overflow thread, we add arm64 to excluded architectures for the simulator.

enter image description here

Which makes all the aws code compile (yay) but then, this error occurs trying to use a framework that is coming in via the Swift Package Manager:

[].swift:10:8: Could not find module 'Parma' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator

So it wants the x86 version of this lib, and cannot find it.

The app does run on the phone now. But not the simulator of course. Not sure if there is a way to figure out which architectures are built by SPM? or control it. I did reset the SPM cache after excluding the arm64 arch.

like image 421
Rob Avatar asked Dec 19 '20 22:12

Rob


1 Answers

I think the best solution for getting this working on M1 is to use XC-Frameworks.

carthage update --use-xcframeworks

This will only build the valid archs you need. If you have any dependencies that don't support XCFrameworks yet you'll have to run lipo to remove x86 simulator targets in your build phase.

like image 182
Retebitall Avatar answered Oct 12 '22 09:10

Retebitall