Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Building for iOS, but the embedded framework 'xxx.framework' was built for iOS + iOS Simulator"

Tags:

ios

xcode12

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.

like image 955
skoonppman Avatar asked Dec 15 '20 06:12

skoonppman


People also ask

What are iOS simulators?

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.

How do I add iOS simulator to Xcode?

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.

Can we run iOS simulator without Xcode?

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.

What is Xcode iOS simulator?

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.


2 Answers

Xcode Build Settings

It could be helped to try to set your "Validate Workspace" of "Build Options" in "Build Settings" as Yes.

like image 126
lenbo Avatar answered Oct 19 '22 21:10

lenbo


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.

enter image description here

For this to work properly you have to follow the steps that Carthage page provide:

If you're building for iOS, tvOS, or watchOS

  1. Create a Cartfile that lists the frameworks you’d like to use in your project.

  2. Run carthage update. This will fetch dependencies into a Carthage/Checkouts folder, then build each one or download a pre-compiled framework.

  3. 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.

  4. 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
    
  5. Create a file named input.xcfilelist and a file named output.xcfilelist

  6. 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
    
  7. 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.

  8. Add the input.xcfilelist to the "Input File Lists" section of the Carthage run script phase

  9. Add 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)

like image 4
gcharita Avatar answered Oct 19 '22 21:10

gcharita