Bitcode是蘋果在Xcode7及以后推出的新功能。用於代碼的二次編譯,針對CPU進行優化,編譯工作由蘋果AppStore后台來完成。
針對iOS是可選項,默認打開。watchOS 和 tvOS 是必選項。蘋果文檔如下
https://developer.apple.com/library/tvos/documentation/IDEs/Conceptual/AppDistributionGuide/AppThinning/AppThinning.html
打開選項如下圖

那么問題來了,如果一個工程里面有靜態庫的引用,那么所有的靜態庫也需要打開Bitcode后重新編譯。
這一切都沒有問題,但是在“Archive”的時候就會報錯。
這時,就需要給靜態庫的工程增加一個選項“-fembed-bitcode”。之后就可以正常Archive了。
報錯內容
ld: bitcode bundle could not be generated because '/Users/liuyuning/Desktop/TestDecode/Decode/libDecode.a(Decode.o)' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

增加“-fembed-bitcode”

另外,如果靜態庫的工程有 -Werror 的選項,需要去掉。應為在編譯的時候有一個警告。 clang: warning: argument unused during compilation: '-fembed-bitcode-marker'
如果不去掉就會報錯。

https://developer.apple.com/library/tvos/documentation/IDEs/Conceptual/AppDistributionGuide/AppThinning/AppThinning.html
打開選項如下圖

那么問題來了,如果一個工程里面有靜態庫的引用,那么所有的靜態庫也需要打開Bitcode后重新編譯。
這一切都沒有問題,但是在“Archive”的時候就會報錯。
這時,就需要給靜態庫的工程增加一個選項“-fembed-bitcode”。之后就可以正常Archive了。
報錯內容
ld: bitcode bundle could not be generated because '/Users/liuyuning/Desktop/TestDecode/Decode/libDecode.a(Decode.o)' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

增加“-fembed-bitcode”

另外,如果靜態庫的工程有 -Werror 的選項,需要去掉。應為在編譯的時候有一個警告。 clang: warning: argument unused during compilation: '-fembed-bitcode-marker'
如果不去掉就會報錯。
