iOS Development
Xcode
iOS Simulator
Framework Compatibility
Build Errors

Building for iOS Simulator, but the linked framework '.framework' was built for iOS

Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms

Building an application for the iOS Simulator can sometimes present challenges, particularly when dealing with frameworks that are compiled for the actual iOS device architecture rather than the simulator. A common issue developers encounter is the error message: "Building for iOS Simulator, but the linked framework '****.framework' was built for iOS". This article addresses the causes of this problem and provides some technical guidance for troubleshooting and resolving it.

Understanding the iOS Simulator vs. iOS Device Architecture

When developing iOS applications using Xcode, the binaries need to target different architectures depending on the usage context:

  • iOS Devices typically utilize ARM architectures (armv7, arm64).
  • iOS Simulator relies on x86_64 or Apple Silicon (for newer Mac M1 or M2 chips) architectures.

Frameworks compiled for an iOS device cannot natively run on the iOS Simulator due to these architecture differences.

Common Causes of the Error

  1. Framework Architecture Mismatch:
    • The framework you're attempting to link against your application is compiled only for the ARM architecture and lacks the necessary slices for the simulator.
  2. Incompatible Build Settings:
    • Incorrect configuration in Xcode build settings that do not target the simulator's architecture.
  3. Static Libraries:
    • Use of static libraries that are not universal and contain only device-specific architectures.

Solutions and Workarounds

Creating a Universal Framework

A universal (or fat) framework bundles multiple architectures into a single binary. This allows the same framework to be used on both iOS devices and the simulator.

Steps to Create a Universal Framework:

  1. Modify Build Settings:
    • Open the framework's project in Xcode.
    • Go to Build Settings.
    • Set Build Active Architecture Only to No for both Debug and Release configurations.
  2. Build for Both Architectures:
    • Use the xcodebuild CLI to build your framework for different architectures:
    • Navigate to the build directory.
    • Use lipo to create a universal binary:
    • For the device:
    • For the simulator:
    • Drag the YourFramework.xcframework to your Xcode project’s Frameworks folder.
  • Static vs Dynamic Libraries: Prefer dynamic libraries for better compatibility unless static libraries provide significant advantages.
  • CocoaPods or Carthage: Check if your package manager supports XCFrameworks to automate integration.
  • Podspecs and Package.swift: Ensure they define appropriate architecture support for simulator builds.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms