Xcode 14 打包 iOS11/12 设备崩溃问题(含pod安装库)

相信很多开发者用xcode14打包的app提交到appstore后都有用户反馈iOS12.3一下设备启动闪退的问题,这点大家可以参看https://www.jianshu.com/p/6d205a3e1f9f 这个链接来解决。但同时有一个问题,对于pod生成的target 如果需要修改的就会很麻烦,尤其是在pod install 后,手动修改后的pod target的build setting会被重置

这时候可以修改podfile文件,在 post installer后在other linker flag 后append 相关设置。具体代码如下:

```

post_install do |installer|

  installer.pods_project.targets.each do |target|

    #####

    if target.name != "FCFileManager" //去除OC 库

      xcconfig_paths = Array.new

      target.build_configurations.each do |config|

        new_xcconfig_path = config.base_configuration_reference.real_path

        if xcconfig_paths.include? new_xcconfig_path

          next

        end

        xcconfig_paths << new_xcconfig_path

        xcconfig_path = config.base_configuration_reference.real_path

        # read from xcconfig to build_settings dictionary

        build_settings = Hash[*File.read(xcconfig_path).lines.map{|x| x.split(/\s*=\s*/, 2)}.flatten]

        # modify OTHER_LDFLAGS

        build_settings['OTHER_LDFLAGS'] = "-Wl,-weak-lswiftCoreGraphics -Wl,-rpath,/usr/lib/swift #{build_settings['OTHER_LDFLAGS']}"

        # clear current file content

        File.open(xcconfig_path, "w") {|file| file.puts ""}

        # write build_settings dictionary to xcconfig

        build_settings.each do |key,value|

          File.open(xcconfig_path, "a") {|file| file.puts "#{key} = #{value}"}

        end

      end

    end

    #########

  end

end

```

参考连接:

https://developer.apple.com/forums/thread/714795

你可能感兴趣的:(Xcode 14 打包 iOS11/12 设备崩溃问题(含pod安装库))