更新到Xcode15,適配之前的代碼,記錄當(dāng)前遇到的問題和解決方法。
1.WebKit錯誤
error: type argument 'nw_proxy_config_t' (aka 'struct nw_proxy_config *') is neither an Objective-C object nor a block type
@property (nullable, nonatomic, copy) NSArray<nw_proxy_config_t> *proxyConfigurations NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(14.0), ios(17.0));
^~~~~~~~~~~~~~~~~
1 error generated.
WebViewJavascriptBridge/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h:16:9: fatal error: could not build module 'WebKit'
#import <WebKit/WebKit.h>
這里主要要搜索“nw_proxy_config_t”關(guān)鍵字,建議不要用百度搜索,有點坑,用谷歌或者必應(yīng)進行搜索。
解決方法1:
1.選中不能編譯的庫的xcodeproj,在Build Phrases -> Compile Sources,選中所有文件,逐一在Complier Flags 里刪除 -DOS_OBJECT_USE_OBJC=0。
如圖:

webBug.png
解決方法2:
??????如果上面的方法不能解決報錯,請用下面的方法進行修改:
1.訪達前往:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk/System/Library/Frameworks/WebKit.framework/Headers
2. 拷貝一份“WKWebsiteDataStore.h”文件到自己的桌面
3.將WKWebsiteDataStore.h文件中的 將里面的 170000 修改成 180000。
4.將桌面上修改的 WKWebsiteDataStore.h 文件拷貝到 Headers 文件下面進行替換老的WKWebsiteDataStore.h文件
5.再次運行demo

參考圖片.png
2.缺失 libarclite_iphoneos.a
報錯:
找不到文件:/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a
解決方法:
因為需要指定版本到有特殊要求,可以考慮從其他版本的Xcode拷貝
使用訪達,文件前往:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/
在這個路徑下新建一個 usr 文件夾,放入鏈接下載的文件,即可。
文件鏈接:https://gitee.com/TikBai_admin/Libarclite-Files.git

存放路徑.png
3. duplicate symbols && Assertion failed
報錯信息:
ld: 1 duplicate symbols
clang: error: linker command failed with exit code 1 (use -v to see invocation)
或者:
Assertion failed: (false && "compact unwind compressed function offset doesn't fit in 24 bits"), function operator(), file Layout.cpp, line 5758.
解決方法:
在other link flags添加 -ld64
Build Settings -> Linking - General -> Other Link Flags 添加-ld64 或者 -ld_classic
如圖:

duplicate.png
4.打包報錯Command PhaseScriptExecution failed with a nonzero exit code
解決方法:
找到Pods-xxxx-frameworks.sh文件,替換代碼:
# source="$(readlink "${source}")"
source="$(readlink -f "${source}")"
如圖所示:

打包編譯報錯.png
5.打包報錯騰訊IM:Asset validation failed
報錯信息:
/Frameworks/TUIGroup.framework' is missing plist key.The
Info.plist file is missing the required key:CFBundleShortVersionString.Please find more
information about CFBundleShortVersionString at https://developer.apple.com/
documentation/bundleresources/information_property_list/cfbundleshortversionstring(ID:
0627ef87-66c9-428b-b36b-69178374702c
如圖所示:

打包im報錯.png
解決方法:
通過添加騰訊IM相關(guān)的技術(shù)人員解決

騰訊解決.png
在 podfile 最后一個 end 后面,添加下這個看看
#Pods config
#Fix Xcode14 Bundle target error
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['GENERATE_INFOPLIST_FILE'] = "NO"
end
end
end