Xcode 12.3: Building for iOS Simulator, but the linked and embedded framework was built for iOS + iOS Simulator
I'm afraid that this is actually the correct error and the framework shouldn't contain iOS and iOS Simulator code at the same time. Apple tries to force us to use XCFramework
s for this purpose. They started it in Xcode 11 and just tightened up the restrictions.
The only correct way to resolve this is to rebuild the framework as an XCFramework. Which is easy to do:
xcrun xcodebuild -create-xcframework \
-framework /path/to/ios.framework \
-framework /path/to/sim.framework \
-output combined.xcframework
You can start with a combined .framework
. Make two copies of the framework, and use lipo
to remove the slices from the binary that are associated with a different SDK.
It is based on the original answer from Apple here.
My particular case is that I'm getting this error using Rome, which produces these frameworks (a possible solution is here). Also, a lot of struggling is going on on the Carthage side.
Swift Framework build fails for device but not for simulator
It sounds like you built the framework for a simulator and not for a device. When the linker is trying to link the application for a device, it doesn't find the framework built for that device.
Two of the ways to do it are as follows.
1) When building the framework, set the active scheme appropriate for the device (upper left area in Xcode). Then, before building the application for the device, go to Build Settings for the app and add the framework's location to Framework Search Paths. Make sure you pick the right binary! For example, when building for the iOS simulator, a debug binary of the framework is going to be in a directory called Build/Products/Debug-iphonesimulator.
With this approach you also need to add the framework to the Copy Files build phase of your app, specifying Destination as Frameworks.
2) Embed the framework into the application, make it a dependency of the app, and set up the application to link with the framework in the app's Build Phases. See
https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html
about embedding a framework and for other useful framework-related info. A convenient way of accomplishing this is to go to the General tab of your application target and add the framework in the Embedded Binaries section.
Alternatively, if you create your framework after creating the application, you can ask Xcode to embed the framework into the app.
Related Topics
Restkit Request Not Sending Parameters
iOS 11 CPU Throttling and Idle Timer
Uidocumentinteractioncontroller Does Not Open Other App in iOS 11
Uicollectionview Inside Tableviewcell Not Called
How to Animate a Nslayoutconstraint in Swift
How to Detect If My Device Is an iPhone x in Swift 4
Xcode Export App, Wildcard Error
Detect Array with Issue (Debug Mode)
Submit Watchkit Provisioning Error
Runtime Error When Using Corefoundation Objects in a Swift Nsobject Subclass
Nsurlprotocol Isn't Asked to Load After Yes Response to Caninitwithrequest
How to Make a Nsurlsesssion Get Request with Cookies
How to Get the Index in Results of a Certain Realm Object
Save Scrollviews Position and Scroll Back to It Later (Offset to Position)
iOS Where to Put Custom Cell Design? Awakefromnib or Cellforrowatindexpath
Media_Err_Decode on HTML5 Video in iOS UIwebview After Many Plays
How to Rotate a UIview Without The Black Bars
Set Custom Font for UItableview Swipe Action (Uicontextualaction)