欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

[绍棠] Xcode 11.4 模拟器编译报错 Building for iOS Simulator was built for iOS

程序员文章站 2022-04-13 11:44:41
...

xcode升级完成,选择模拟器编译,出现了报错。
[绍棠] Xcode 11.4 模拟器编译报错 Building for iOS Simulator was built for iOS
 

对此,苹果员工 edford 给出的答案是:

Having x86_64 code is not sufficient to distinguish if a binary is intended for the iOS Simulator, a macOS app, or a Mac Catalyst app. Combing built binaries across different destinations (which includes the simulator vs. device binaries) is not a supported combination – there is no Apple platform where ARM code and x86_64 code in the same binary is a correct configuration.

If this is your library, you should have your app build it from source as a dependency of your Xcode project, either through an Xcode target or through Swift Package Manager, so that the right platform information is included based on the build target.

If this is your library but you have a specific reason for it to be pre-compiled, please build it as an XCFramework. XCFrameworks correctly separate out binaries that have the right architectures for the different platforms you target. In addition to instructions on how to build such a XCFramework linked earlier, we have a WWDC talk illustrating it.

If this library is from a framework vendor (either as source or a pre-compiled binary), or you integrate a vendor’s library into your app with a third party dependency manager, please consult with the library vendor or dependency manager for support.

Apple 让我们重新编译这些 SDK 以支持 iOS Simulator,如果我们使用的第三方的 SDK,请联系第三方以提供技术支持,这显然不是我们想要的。一方面,一些年代久远的 SDK 已经找不到维护人员,另一方面有些 SDK 仅提供设备的支持也是合理的,毕竟它们本身就无法在模拟器上正确运行,因为它们依赖于硬件设备。

解决方法

方法一:

修改Workspaces Setting

File–>Workspaces Setting–>Legacy Build System

[绍棠] Xcode 11.4 模拟器编译报错 Building for iOS Simulator was built for iOS

不推荐这种方法, 这种事回到以前的编译系统

方法二:

debug模式忽略.a或者framework

build Setting–> EXCLUDED_SOURCE_FILE_NAMES

[绍棠] Xcode 11.4 模拟器编译报错 Building for iOS Simulator was built for iOS

另外, 在我们引用这些第三方库的时候添加上

#if !TARGET_IPHONE_SIMULATOR
#endif

例如:

[绍棠] Xcode 11.4 模拟器编译报错 Building for iOS Simulator was built for iOS

setupPresentView方法中就是用到这些不支持模拟器的SDK的调用地方

 


 

相关标签: iOS开发 iOS