升级到Xcode 12.3时,出现错误:
Building for iOS, but the embedded framework 'opus.framework' was built for iOS + iOS Simulator
但在更新之前一切都正常。
尝试将您的“构建设置”中的“构建选项”下的“验证工作空间”设置为“Yes”,可能会有所帮助。
编辑:这是一个可以帮助那些使用Carthage的观察结果。
显然,此答案中描述的解决此问题的最受欢迎的方法是:
在Build Settings选项卡中将Validate Workspace设置为Yes
此外,此答案的观察结果是正确的:
恐怕这实际上是正确的错误,框架不应同时包含iOS和iOS模拟器代码。苹果试图强制我们使用XCFramework来实现这个目的。他们从XCode 11开始推出,并收紧了限制。
除xcframework用法之外,其他所有解决方法似乎在即将发布的Xcode版本中变得越来越临时。
如果你正在使用Carthage并添加了一个带有Embed & Sign
的框架,这就是一个问题。
为了使其正常工作,您必须遵循Carthage页面提供的步骤。
也许这也是其他情况的临时解决方案。(依赖项未使用Carthage构建)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
spec.public_header_files = "YourFramework.framework/Headers/*.h" spec.source_files = "YourFramework/Headers/*.h" spec.vendored_frameworks = "YourFramework"
2)从podfile引用框架 - Sergiy Salyuk