Xcode – Disable Swift Package(arm64) for iOS Simulator

I have installed a Swift Package in my iOS app. This package only supports arm64 for the moment. This means I cant run my app on a iOS Simulator that has another architecture.

Is it possible to disable a Swift Package only for iOS Simulator? So this library is not linked with my binary during build? I want to keep this library still activated on a physical device.

Im using this code in my app, but it is not enough:

#if !targetEnvironment(simulator) && canImport(MyLibrary)
import MyLibrary
// Code for physical device
#else
// Code for iOS Simulator
#endif

When running my app on iOS Simulator I get this error:

While building for iOS Simulator, no library for this platform was found in ‘MyLibrary.xcframework’.

Leave a Comment