Fix “Building for iOS Simulator but Linking in Object File Built for iOS” in Cordova/Xcode

If you develop hybrid apps using Apache Cordova, sooner or later you may encounter an intimidating Xcode build error:

Building for ‘iOS Simulator’, but linking in object file built for ‘iOS’.

This typically appears when you run cordova build ios or launch your app in the iOS Simulator on a Mac, especially Apple Silicon Macs. It’s a common stumbling block for developers integrating third-party plugins such as cordova-plugin-facebook5 or libraries like Bolts.framework.

In this article, we’ll explain why this happens, how architectures differ between device and simulator builds, and provide clear, step-by-step solutions to eliminate the error.


Why This Error Happens

The root cause is architecture mismatch.

  • iOS devices run on arm64 binaries.
  • The iOS Simulator on Intel Macs runs on x86_64 binaries.
  • The iOS Simulator on Apple Silicon Macs runs on arm64 binaries but still needs frameworks marked for simulator use.

When a framework (like Bolts.framework) is compiled only for iOS devices and not for the simulator, Xcode refuses to link it.


Common Context: Cordova Plugins

Many Cordova plugins, including cordova-plugin-facebook5, include precompiled frameworks via their plugin.xml. These frameworks may lack simulator slices or may still use outdated <framework type="podspec"> syntax, which causes additional friction with modern Cordova and Xcode versions.


Step-by-Step Fixes

1. Update Cordova and Plugins

First, ensure you’re running the latest versions of Cordova and the iOS platform:

npm install -g cordova
cordova platform remove ios
cordova platform add ios@latest

Then update your plugins, especially cordova-plugin-facebook5:

cordova plugin remove cordova-plugin-facebook5
cordova plugin add cordova-plugin-facebook5@latest

2. Switch from <framework type="podspec"> to <podspec>

If you maintain a custom plugin or a fork, open plugin.xml and replace:

<framework src="Bolts" type="podspec" spec="~> 1.9"/>

with:

<podspec spec="Bolts ~> 1.9"/>

This ensures CocoaPods manages the framework correctly for all architectures.

3. Use CocoaPods Properly

Run:

cd platforms/ios
pod repo update
pod install

This refreshes your local Podspecs and installs the proper slices for the simulator.

4. Exclude arm64 for the Simulator in Xcode

If the framework still lacks a simulator slice, instruct Xcode to skip arm64 for simulators:

  • Open platforms/ios/YourApp.xcworkspace in Xcode.
  • Select the project > Build Settings.
  • Find Excluded Architectures.
  • For Any iOS Simulator SDK, add arm64.

This tells Xcode to compile the simulator build using x86_64 only, bypassing the missing arm64 slice.

5. Clean and Rebuild

After changes:

cordova clean ios
cordova build ios

Or inside Xcode: Product > Clean Build Folder, then rebuild.

6. Verify in Simulator and Device

Test both on a real iPhone and in the Simulator to ensure your app launches in both environments.


Advanced Tips

  • Universal (XCFramework) Libraries: Ask plugin maintainers to migrate to XCFrameworks, which natively support multiple architectures.
  • Apple Silicon Awareness: On M1/M2 Macs, prefer arm64-ready pods or frameworks. If unavailable, use Rosetta 2 for Xcode or explicitly exclude arm64 for simulators.
  • Continuous Integration: If you’re running builds on CI (GitLab CI, GitHub Actions), match your build server’s architecture to avoid inconsistent results.

Troubleshooting Checklist

IssueQuick Fix
Plugin uses old <framework type="podspec">Switch to <podspec>
Framework missing simulator sliceExclude arm64 for Simulator in Xcode
Pods not updatingpod repo update + pod install
Still failingCheck plugin’s GitHub issues or fork to update frameworks

Conclusion

The “Building for iOS Simulator but linking in object file built for iOS” error is a classic Cordova/Xcode issue caused by architecture mismatches. Fortunately, with the right combination of updating plugins, using <podspec>, excluding incompatible architectures, and cleaning builds, you can resolve it quickly and get back to developing your hybrid app.

By applying the steps above, your Cordova project will be compatible with modern versions of Xcode and the iOS Simulator — and you’ll avoid this frustrating build error in the future.

This article is inspired by real-world challenges we tackle in our projects. If you're looking for expert solutions or need a team to bring your idea to life,

Let's talk!

    Please fill your details, and we will contact you back

      Please fill your details, and we will contact you back