visit
Apple silicon processors are a revolution in the world of desktop CPUs. The transition from Intel's x86_64 architecture to Apple's arm64 was quite smooth for the consumers, thanks to the Rosetta 2 emulator, which allows translation of x86_64 commands to arm64 without a significant loss in performance. The developers, however, also needed to rely on the emulation because when the new architecture was first released at the end of 2020, most developer tools and libraries didn't support arm64 architecture. And that could result in either unstable performance or crashes in some cases.
Now that the new Apple silicon chips have been around for almost two years, things have changed. It is the best time to look into migrating your project for the arm64 architecture if you have not done so already. Compared to last year or the end of 2020, most dependencies and tools now support the new architecture, so you won’t face any major hurdles in the transition during the migration process.
In addition, we can’t help but mention that your favorite CI/CD provider Codemagic has released the first Mac mini M1 build machines to the public! Some of our customers have already tried the powerful build machines with the new efficient chips and are getting much faster build times. So, let’s discuss Intel-to-M1 migration: migrating the CI/CD pipeline for your project from the good old x86_64 to the shiny new arm64.
At the time of writing, to migrate your workflows to the new Apple M1 virtual machine on Codemagic, you must use Xcode 13.3+ because the base image of the macOS M1 build machine has it preinstalled. Xcode 13.3.1 (13E500a) is the latest version and is used by default when you set 13.3
, 13.3.1
, edge
, or latest
in your codemagic.yaml
file or select it in the build settings in the Workflow Editor for Flutter apps.
In the beginning, developers used Rosetta emulation to use apps built for a Mac with an Intel processor. Many CocoaPods dependencies and Swift packages were incompatible with the arm64 architecture in the initial months. As the developers started transitioning and getting the latest M1 and M1 Pro/Max/Ultra series devices, they requested open-source projects and different SDKs to support the arm64 architecture.
While the architecture of the iPhone is already arm64
, Intel used x86_64
simulators. With the new M1 series devices, the simulators also run on the arm64
architecture.
Apple has provided a for resolving architecture build errors on Apple Silicon
Xcode already provides the default architecture build settings that help you build and ship on all the platforms. One of the settings is Build Active Architectures Only, a boolean value with the default value as Yes for Debug and No for Release configurations. Xcode automatically builds for the selected architecture if the value is set to Yes. So, if you are using an Apple Silicon machine, it builds for the arm64 simulator, and if you are working with an Intel machine, it builds for the x86_64 simulator.
Go to your project, select your target, and select Build Settings. Under the Architectures section, set Build Active Architecture Only to YES for debug builds. This ensures that the compiler generates the binary for only one architecture.
Do the same for the Pods as well:
If you set it to NO, Xcode will build the project for all the valid architectures. However, you may see an error that looks something like this:
Could not find module 'ColorKit' for target 'x86_64-apple-ios-simulator'; found:
arm64-apple-ios-simulator, at: /Users/rudrankriyam/Library/Developer/Xcode/DerivedData/Musadora-ccjzyuildzfnokedenrcjqixspxo/Build/Products/Debug-iphonesimulator/ColorKit.swiftmodule
Setting Build Active Architecture in Xcode to YES also reduces the build time drastically, as you are compiling for one architecture instead of two. This is a win-win situation for you!
brew install cocoapods
If you use Carthage, the best solution is to use XCFrameworks. This helps to build only the valid architectures that you need to build the app:
carthage update --use-xcframeworks
The initial project has an old version of a framework to showcase the error that occurs when an XCFramework does not support the arm64 architecture.
pod 'AppsFlyerFramework', '6.2.0'
ld: in /Users/rudrankriyam/Downloads/Silicon/Pods/AppsFlyerFramework/iOS/AppsFlyerLib.framework/AppsFlyerLib(AFSDKKeychainFactory.o),
building for iOS Simulator, but linking in object file built for iOS,
file '/Users/rudrankriyam/Downloads/Silicon/Pods/AppsFlyerFramework/iOS/AppsFlyerLib.framework/AppsFlyerLib'
for architecture arm64
You need the arm64 architecture to run the project in the simulator. But this version of the framework doesn’t support it.
To fix this issue, search the framework’s repository and check if they have released a version that adds support for arm64. As mentioned earlier, many priority frameworks and open-source projects have provided support for running on the latest silicon chips. Fortunately, arm64 support was added for this framework in version 6.3.0
, and we can update the Podfile
to fetch the latest version.
pod 'AppsFlyerFramework'
After you enter the command pod update
, you can run the project successfully on M1 devices and Intel machines.
If some dependency does not yet support arm64, you can ask the framework’s author to provide a newer updated version that supports both architectures. Taking the previous example of an iOS SDK that transitioned to support arm64 by providing a universal XCFramework, AppsFlyer iOS SDK released arm64 support in April of last year after developers requested it.
Test name |
Mac mini M1 |
Mac Pro |
---|---|---|
Installing scripts |
17s | 163s |
Building project |
254s | 280s |
Running tests |
270s | 395s |
Overall |
573s | 883s |
You can see the significant differences in the numbers, especially while running tests — they run substantially faster on the M1 build machines. After running the same tests for this app multiple times, we see a decrease of 35–40% in overall build times. The gap between the numbers adds up when running many builds and saves considerable time for a faster iteration process.
Reminder: M1 Mac mini build machines are already available on Codemagic. If you’re on the pay-as-you-go plan, just use
instance_type: mac_mini_m1
to try them out. If you’re on the Professional plan and want to set up a trial for the Mac mini M1, reach out to our customer engineering team to help you get fast green builds on the new machines!