When upgrading to Xcode 12.3, getting the error:
Building for iOS, but the embedded framework 'opus.framework' was built for iOS + iOS Simulator
But everything is ok before the update.
An iOS Simulator basically mimics an iOS app or browser on top of a developer's operating system. This is viewable in an iPad or iPhone like window. They cannot virtualize the actual hardware conditions of an iOS device, which is the main requirement for comprehensive testing and debugging.
If you require a different version of the iOS simulator than is provided by your Xcode installation, you can download additional simulators in Xcode. Open Xcode and click Menu > Xcode > Preferences > Select Components, and then choose the simulator version you want to download.
Well, that's not entirely true, you can actually still directly launch iOS Simulator without opening Xcode first by creating an alias. Note that modern versions of Xcode and OS X call the iOS Simulator simply “Simulator”, where you go will depend on which version of OS X the Mac is running.
Simulator app, available within Xcode, presents the iPhone, iPad, or Apple Watch user interface in a window on your Mac computer. You interact with Simulator by using the keyboard and the mouse to emulate taps, device rotation, and other user actions.
Xcode Build Settings
It could be helped to try to set your "Validate Workspace" of "Build Options" in "Build Settings" as Yes.
Edit: This was an observation that could help those who use Carthage.
Apparently the most popular solution to this problem described in this answer.
setting Validate Workspace to Yes in the Build Settings tab
Also, the observation of this answer is correct
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 for this purpose. They started it in XCode 11 and just tightened up the restrictions.
Every other solution (other than xcframework usage) seems to become increasingly temporary in the coming Xcode versions.
This is an issue if you are using Carthage and you have added a framework with Embed & Sign
.
For this to work properly you have to follow the steps that Carthage page provide:
If you're building for iOS, tvOS, or watchOS
Create a Cartfile that lists the frameworks you’d like to use in your project.
Run
carthage update
. This will fetch dependencies into a Carthage/Checkouts folder, then build each one or download a pre-compiled framework.Open your application targets’ General settings tab. For Xcode 11.0 and higher, in the "Frameworks, Libraries, and Embedded Content" section, drag and drop each framework you want to use from the Carthage/Build folder on disk. Then, in the "Embed" section, select "Do Not Embed" from the pulldown menu for each item added. For Xcode 10.x and lower, in the "Linked Frameworks and Libraries" section, drag and drop each framework you want to use from the Carthage/Build folder on disk.
On your application targets’ Build Phases settings tab, click the + icon and choose New Run Script Phase. Create a Run Script in which you specify your shell (ex:
/bin/sh
), add the following contents to the script area below the shell:/usr/local/bin/carthage copy-frameworks
Create a file named
input.xcfilelist
and a file namedoutput.xcfilelist
Add the paths to the frameworks you want to use to your
input.xcfilelist
. For example:$(SRCROOT)/Carthage/Build/iOS/Result.framework $(SRCROOT)/Carthage/Build/iOS/ReactiveSwift.framework $(SRCROOT)/Carthage/Build/iOS/ReactiveCocoa.framework
Add the paths to the copied frameworks to the
output.xcfilelist
. For example:$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Result.framework $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/ReactiveSwift.framework $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/ReactiveCocoa.framework
With output files specified alongside the input files, Xcode only needs to run the script when the input files have changed or the output files are missing. This means dirty builds will be faster when you haven't rebuilt frameworks with Carthage.
Add the
input.xcfilelist
to the "Input File Lists" section of the Carthage run script phaseAdd the
output.xcfilelist
to the "Output File Lists" section of the Carthage run script phase
Maybe this is a temporary fix for other cases also. (dependencies that are not build with Carthage)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With