1、 出现错误 Error: Command Codesign failed with a nonzero exit code
解决方法:
1、Clean Build Folder (Command+shift+K)后,再次编译。
2、在build setting中 找到 other code signing flags 输入 ”--deep“
2、 预编译指令问题。 结构如下:

1、在mac 环境下运行 以下指令结果为:
(指令都需要添加TARGET_OS_前缀,如TARGET_OS_MAC)
MAC | OSX | IPHONE | IOS | SIMULATOR | MACCATALYST | UIKITFORMAC |
---|---|---|---|---|---|---|
1 | 0 | 1 | 1 | 0 | 1 | 1 |
2、在 模拟器 环境下运行 以下指令结果为:
MAC | OSX | IPHONE | IOS | SIMULATOR | MACCATALYST | UIKITFORMAC |
---|---|---|---|---|---|---|
1 | 0 | 1 | 1 | 1 | 0 | 0 |
结论:
如果在代码中需要用预编译指令区分 iphone、模拟器及Mac Catalyst 时,
先判断Mac Catalyst,再判断模拟器,最后判断iphone。
3、生成的xcframework使用问题
1、使用 Starscream.xcframework 时 (版本:3.04)
在swiftinterface
文件中出现错误 No such module SSCZLib
和 No such module SSCommonCrypto
。因为在框架中用到 .modulemap
来加载子模块,但是在xcframework
中并不能加载到。
`解决方法`:删除zlib目录下的所有文件,然后在WebSocket.swift文件中导入“zlib”和 “CommonCrypto”,重新生成xcframework 即可。
2、使用SwiftyJSON时 (版本4.3.0)
出现错误 Use of undeclared type 'SwiftyJSON'
,同样是在生成swiftinterface
文件时,多添加了SwiftyJSON.
前缀。
`解决方法`:使用全局替换将“SwiftyJSON.” 替换为空字符串 即可。
3、使用 SQLite.swift时 (版本0.12.0)
出现错误initializer does not override a designated initializer from its superclass
,在生成swiftinterface文件时,没有对FTSConfig
类 生成init
方法。
`解决方法`:在swiftinterface 的类FTSConfig 中添加方法 ` public init() ` 即可
4、下载SnapKit后,在Deployment Info中没有Mac iPhone iPad 的Target设备支持。
`解决方法`:在Build Setting中 搜索 Base SDK 选择 iOS 即可
总结
1、 生成xcframework时,自动生成的swiftinterface 里面的代码缺失或多添加类前缀。
2、 第三方框架中使用到子模块 .modulemap,编译不通过。
3、 在Base SDK中设置 iOS,才能在Deployment info中选择多个Target 设备。
网友评论