适配 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

解决方案

  1. 选中不能编译的库的xcodeproj,在Build Phrases -> Compile Sources选中所有文件Complier Flags删除 -DOS_OBJECT_USE_OBJC=0

可能是三方库的目标版本比较低,cocoapods兼容版本自动加上了 –DOS_OBJECT_USE_OBJC=0,也可以修改库的podspecs.platforms = { :ios => "11.0", :osx => "" } 重新 pod install

  1. 临时方案
    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 &amp;&amp; “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 -> LinkingGeneral -> 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_version15
        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 -> LinkingGeneral -> Other Link Flags 添加-weak_framework SwiftUI

原文地址:https://blog.csdn.net/tongwei117/article/details/132860813

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。

如若转载,请注明出处:http://www.7code.cn/show_11673.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注