Xcode iOS Simulator Architecture Mismatch: Resolving arm64 Build Errors
When building iOS applications in Xcode, you may encounter the error: "building for iOS Simulator, but linking in an object file built for iOS, for architecture 'arm64'". This common issue occurs when there's a mismatch between the target platform (simulator vs. device) and CPU architectures.
Understanding Platform and Architecture Differences
iOS development involves two key concepts:
- Platforms: iOS device vs. iOS Simulator
- Architectures: arm64 (Apple Silicon) vs. x86_64 (Intel)
Different platforms use different system libraries, while different architectures use different CPU instructions. Your build must match the target environment precisely.
How Xcode Handles Architectures
Xcode's default behavior varies based on your configuration:
Debug builds (development speed prioritized):
- Build only for the current target's architecture
- iPhone → arm64 only
- Simulator → Architecture based on your Mac's processor
Release builds (compatibility prioritized):
- Build for all supported architectures
- Creates universal binaries for distribution
Primary Solutions
1. Update Pre-compiled Libraries
The optimal solution is to ensure all dependencies support Apple Silicon:
# Contact vendors for updated XCFrameworks with arm64 simulator support
# Or rebuild libraries from source as XCFrameworksINFO
Apple recommends against permanently excluding architectures. Strive for complete architecture support in all dependencies.
2. Temporary Workaround: Exclude arm64 for Simulator
If updated libraries aren't available, temporarily exclude arm64 for simulator builds:
In your project's Build Settings:
- Navigate to Build Settings → Excluded Architectures
- Add
Any iOS Simulator SDKwith valuearm64
In your Podfile (for CocoaPods dependencies):
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
endWARNING
This prevents building for M1 simulators directly. You'll need to use Rosetta instead.
3. Use Rosetta Simulator (Apple Silicon Macs)
For Apple Silicon Macs, you can use Rosetta-based simulators:
- Go to Product → Destination → Show All Run Destinations
- Select a simulator with "(Rosetta)" designation
- Clean build folder (Cmd+Shift+K) and rebuild
How to enable Rosetta for Xcode
Right-click Xcode in Applications → Get Info → check "Open using Rosetta"
Advanced Configuration
For Complex Project Setups
Ensure architecture settings are consistent across all targets:
# Comprehensive Podfile configuration
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# Remove deprecated settings
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
config.build_settings.delete 'VALID_ARCHS'
# Optimize for development
config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
end
end
endInspecting Binaries
Use command-line tools to check architecture support:
# Check architectures in a binary
lipo -info /path/to/YourFramework.framework/YourFramework
# For XCFrameworks, check each platform-specific binary
lipo -info /path/to/YourFramework.xcframework/ios-arm64/YourFramework.framework/YourFramework
lipo -info /path/to/YourFramework.xcframework/ios-arm64_x86_64-simulator/YourFramework.framework/YourFrameworkCommon Pitfalls and Solutions
| Issue | Solution |
|---|---|
| Pre-compiled library lacks arm64 support | Contact vendor for updated XCFramework |
| Settings inconsistent between project and pods | Apply changes to all targets |
| Build folder has cached incompatible binaries | Clean build folder (Cmd+Shift+K) |
| Rosetta not enabled on Apple Silicon | Use Rosetta simulator or enable Rosetta for Xcode |
DANGER
Never exclude arm64 for the iOS platform (devices) - this will prevent building for physical devices and App Store submission.
Best Practices
- Prefer XCFrameworks over fat binaries for better platform isolation
- Keep dependencies updated to ensure Apple Silicon support
- Validate architecture settings across all targets (project, pods, dependencies)
- Use Rosetta only as temporary solution while updating dependencies
When to Use Each Approach
| Scenario | Recommended Solution |
|---|---|
| Library source available | Build as XCFramework with full architecture support |
| Pre-compiled library from vendor | Request updated XCFramework from vendor |
| Temporary development need | Use Rosetta simulator |
| Emergency fix | Exclude arm64 for simulator (temporary) |
By understanding the architecture requirements and applying the appropriate solution, you can resolve the build errors while maintaining compatibility across both Intel and Apple Silicon environments.