iOS 17 适配 Xcode 15 问题

在适配 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,也可以修改库的podspec 的 s.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 && “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

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/tongwei117/article/details/132860813