在适配 iOS 17 + xcode 15时遇到的问题,记录一下。
1、 Could not build module ‘WebKit’
type argument 'nw_proxy_config_t' (aka 'struct nw_proxy_config *') is neither an Objective-C object nor a block type
解决方案:
- 选中不能编译的库的xcodeproj,在
Build Phrases -> Compile Sources
,选中所有文件,Complier Flags
里删除-DOS_OBJECT_USE_OBJC=0
可能是三方库的目标版本比较低,cocoapods兼容低版本自动加上了 -DOS_OBJECT_USE_OBJC=0
,也可以修改库的podspec 的 s.platforms = { :ios => "11.0", :osx => "" }
重新 pod install
。
- 临时方案
把NSArray<nw_proxy_config_t> *proxyConfigurations
编译版本改为180000
编辑文件/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk/System/Library/Frameworks/WebKit.framework/Headers/WKWebsiteDataStore.h
将里面的 170000 修改成 180000。
2、 Assertion failed
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
或者 -ld_classic
路径:Build Settings
-> Linking
- General
-> Other Link Flags
添加-ld64
或者 -ld_classic
post_install do |installer|
# 调试flutter时打开
# flutter_post_install(installer) if defined?(flutter_post_install)
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
# 同步 pod 库的最低支持版本为 10.0
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
# config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
# pod 也要添加“模拟器排除 arm64 支持”
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
# 修复 Xcode 15 上,ios 14及以下版本运行时崩溃的问题
xcode_version = `xcrun xcodebuild -version | grep Xcode | cut -d' ' -f2`.to_f
if xcode_version ≥ 15
config.build_settings["OTHER_LDFLAGS"] = "$(inherited) -Wl, -ld_classic"
end
# 修复 Xcode 14 中,Pod 工程中的 Bundle target 签名报错的问题
config.build settings["CODE SIGN IDENTITY"] = = ""
# if target.name.eql?('SnapKit')
# libraries = config.build_settings['OTHER_LDFLAGS']
# config.build_settings['OTHER_LDFLAGS'] = "#{libraries} -lswiftCoreGraphics"
# libraryPath = config.build_settings['LIBRARY_SEARCH_PATHS']
# config.build_settings['LIBRARY_SEARCH_PATHS'] = "#{libraryPath} $(SDKROOT)/usr/lib/swift"
# end
end
end
end
发现报错,因为项目中有些库没有用到swiftCoreGraphics,比如OC的三方库,或者非UI的库,所以还是要改,需要区分添加。针对项目中Swift类型的UI相关的库,添加这个编译选项,其他的不添加,最终示例如下:
need_otherlinkerflags_frameworks = ['FSPagerView', 'HandyJSON', 'IQKeyboardManagerSwift', 'JXSegmentedView', 'KDCircularProgress', 'Kingfisher', 'RxSwift', 'PKHUD', 'RxCocoa', 'SnapKit', 'ZLPhotoBrowser']
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if need_otherlinkerflags_frameworks.include?(target.name)
config.build_settings['OTHER_LDFLAGS'] = '-Wl,-weak-lswiftCoreGraphics'
end
end
end
end
3、 dyld: Library not loaded: /System/Library/Frameworks/SwiftUI.framework/SwiftUI
dyld: Library not loaded: /System/Library/Frameworks/SwiftUI.framework/SwiftUI
Referenced from: /var/containers/Bundle/Application/73E9CC61-6EBE-46DB-A786-4E47290284AD/xxx.app/xxx
Reason: image not found
项目中没有使用SwiftUI ,但是在适配iOS 17时还是报这个问题。
经排查,SwiftUI 使用 LC_LOAD_WEAK_DYLIB,而 Foundation 使用 LC_LOAD_DYLIB。这就是我们想要的。
https://developer.apple.com/forums/thread/126506
解决方法:
路径:Build Settings
-> Linking
- General
-> Other Link Flags
添加-weak_framework SwiftUI
4、 The iOS deployment target ‘IPHONEOS_DEPLOYMENT_TARGET’ is set to xxx
产生原因:
在编译cocoapods管理的三方库时出现了这个警告,原因是该三方库部署目标的系统版本最低要求是8.0,而升级Xcode支持的部署最低版本范围是xxx,不匹配所以报警了。文章来源:https://www.toymoban.com/news/detail-713601.html
解决方案:
将所有三方库的部署版本号强制修改到Xcode支持的范围内,代码如下:文章来源地址https://www.toymoban.com/news/detail-713601.html
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
end
end
end
到了这里,关于iOS 17 适配 Xcode 15 问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!