使用Swift開發(fā)Framework遇到的問題及解決方法

  1. Failed to build module 'xxx'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.5 effective-4.2 (swiftlang-1300.0.31.1 clang-1300.0.29.1)', while this compiler is 'Apple Swift version 5.5.2 effective-4.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)'). Please select a toolchain which matches the SDK.

在build setting中將BUILD_LIBRARY_FOR_DISTRIBUTION設(shè)置為Yes

  1. Include of non-modular header inside framework module
    該問題發(fā)生場景為:依賴第三方framework,且項(xiàng)目中只能看到framework,頭文件必須在Finder中才能看到。

解決:如果能看到頭文件,在build perhaps->Headers中將頭文件放到public中。如果看不到,需要在build setting->OTHER_SWIFT_FLAGS中添加-Xcc -Wno-error=non-modular-include-in-framework-module

3.SDK依賴第三方庫,在導(dǎo)入SDK后pod對應(yīng)庫后編譯出現(xiàn)Undefined symbols
解決:找到對應(yīng)三方庫的TARGETS -> Build Settings -> BUILD_LIBRARY_FOR_DISTRIBUTION 設(shè)置為YES

Sandbox: rsync.samba(13741) deny(1) file-write-create

TARGETS -> Build Settings -> ENABLE_USER_SCRIPT_SANDBOXING -> No

5.導(dǎo)入C或者OC的頭文件報(bào)錯

第一種,將header文件在Build Phases -> Headers中設(shè)置為Public,然后在xxx.h(如framework叫abc,會有一個abc.h)import。
可能會遇到的錯誤:
double-quoted include "xxx.h" in framework header, expected angle-bracketed instead
解決:將#import "xxx.h" 改為 #import <framework的名字/xxx.h> ,在c或oc文件中報(bào)這個錯誤也用相同方式解決(include)

第二種,modulemap
暫未遇到問題

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容