升级到XCode15后的错误/适配
背景
2024/04/29开始,基于Xcode14打包的ipa包将无法提交app store。
升级XCode15意味着开发使用的iOS系统SDK版本升级。
将升级到XCode15后的错误记录在这里。
一、编译错误 duplicate symbols
XCode14下能正常编译的项目。发生编译错误 duplicate symbols
解决办法:在Xcode -> Target -> Build Setting -> Other Linker Flags 添加一行"-ld_classic"
二、对WKWebView设置UserAgent不能再使用NSUserDefaults
之前的方式,在XCode17开发环境打包+iOS17运行时将不再生效
#if 0 // XCode17以上的SDK下已经不适用了
// 设置global User-Agent
NSString *userAgent = @"location-ios";
[[NSUserDefaults standardUserDefaults] registerDefaults:@{@"UserAgent":userAgent}];
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(@"----UA configWebViewPJUA:%@", userAgent);
#endif
改为使用对WKWebView实例设置属性
wk.customUserAgent = @"location-ios";
三、Dubeg运行IDE开始时日志错误
IDE运行项目后,控制台最开始位置提示了红色文字
Logging Error: Failed to initialize logging system. Log messages may be missing. If this issue persists, try setting IDEPreferLogStreaming=YES in the active scheme actions environment variables.
解决办法: 在schema中增加环境变量IDEPreferLogStreaming并设置YES