開發(fā)環(huán)境
- macOS Ventura 13.4
- Xcode 14.3
Xcode 14.3 無法運(yùn)行測(cè)試
模擬器file not found: libarclite_iphonesimulator.a
真機(jī) file not found: libarclite_iphoneos.a
這個(gè)問題分為2方面解決:
- Xcode 14.3版本移除了內(nèi)置ARC相關(guān)的庫,從而導(dǎo)致一些默認(rèn)部署目標(biāo)是iOS 8版本的第三方庫出現(xiàn)報(bào)錯(cuò)。只要最低部署目標(biāo)不低于iOS 9版本,運(yùn)行項(xiàng)目時(shí)就不會(huì)去鏈接ARC相關(guān)的庫,也就不會(huì)出現(xiàn)找不到庫的報(bào)錯(cuò)。
在Podfile文件中添加
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
end
end
end
2.有時(shí)候必須支持老版本, 不管用模擬器還是真機(jī)測(cè)試的時(shí)候, 僅僅是添加上述代碼, 依然無法運(yùn)行. 因此我們需要將未升級(jí)前的arc文件復(fù)制到Xcode 14.3
轉(zhuǎn)至arc下載頁
解壓后復(fù)制到指定的目錄路徑:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib
Xcode 14.3 Command PhaseScriptExecution failed with a nonzero exit code
由于Pods-app-frameworks.sh編譯時(shí), 出現(xiàn)的問題
全局搜索
source="$(readlink "${source}")"
替換為
source="$(readlink -f "${source}")"
但是, 每當(dāng)重新build的時(shí)候, 編譯文件又回歸原始, 因此我們可以在Podfile文件post_install do |installer|中添加
shell_script_path = "Pods/Target Support Files/#{target.name}/#{target.name}-frameworks.sh"
if File::exists?(shell_script_path)
shell_script_input_lines = File.readlines(shell_script_path)
shell_script_output_lines = shell_script_input_lines.map { |line| line.sub("source=\"$(readlink \"${source}\")\"", "source=\"$(readlink -f \"${source}\")\"") }
File.open(shell_script_path, 'w') do |f|
shell_script_output_lines.each do |line|
f.write line
end
end
end
這樣, 就會(huì)在build的時(shí)候, 自動(dòng)替換.
post_install do |installer| 的一些變量
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 11.0
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
end
if config.name == 'Test'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)','TEST=1']
config.build_settings['SWIFT_ACTIVE_COMPILATION_CONDITIONS'] = ['$(inherited)','TEST']
config.build_settings['GCC_OPTIMIZATION_LEVEL'] = 0
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone'
end
end
end
end
IPHONEOS_DEPLOYMENT_TARGET 庫最低版本設(shè)置
GCC_PREPROCESSOR_DEFINITIONS 編譯環(huán)境配置
SWIFT_ACTIVE_COMPILATION_CONDITIONS 編譯環(huán)境配置
GCC_OPTIMIZATION_LEVEL oc編譯優(yōu)化級(jí)別
SWIFT_OPTIMIZATION_LEVEL swift編譯級(jí)別優(yōu)化