XCode14.3问题 2023-04-07 周五

2023-04-06  本文已影响0人  松哥888

简介

本来好好的,突然打包不行了,模拟器也不能用了,郁闷了好几天。后来才发现原来的是XCode14.3的问题,降级到XCode14.2,就正常了。

打包问题

企业微信截图_08c872a8-353f-467b-baba-2a5f14ba0751.png image.png

Xcode 14.3 is now using a relative path in its symlink for frameworks. Without the -f flag, this relative path would be evaluated relative to the working directory of the script being executed, instead of relative to the framework symlink itself. With the -f flag, it resolves that relative path and returns the full path to the source.

如何解决?

把Pods -> Targets Support Files -> Pods-工程名字-frameworks.sh这个配置文件的44行,加个-f参数就好了

企业微信截图_b5cd1bb1-7394-4093-8502-3e1d60428e02.png

模拟器问题

编译都不过,第三方库直接就报错:

In /Users/zxs/git/ios/storage/Pods/YYImage/Vendor/WebP.framework/WebP(anim_decode.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/zxs/git/ios/storage/Pods/YYImage/Vendor/WebP.framework/WebP' for architecture arm64

解决方法

就是模拟器的时候,需要排除arm64芯片,需要在PodFile中添加以下内容:

# Fixed iOS simulator Link error for arm64 architecture on xCode 12.* for Apple M1 chip?
        # alse added on **** -> Build Settings -> Excluded architectures -> DebugStaging
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
      end
    end

自动添加-f参数的脚本

手动加个-f很简单,但是每次podinstall之后就会被改回去。这里有篇文章介绍在PodFile中用脚本自动改,可以试试。Podfile Xcode 13 readlink fix

post_install do |installer|
  project_path = "工程名字.xcodeproj"
  project = Xcodeproj::Project.open(project_path)
  project.targets.each do |target|
    shell_script_path = "Pods/Target Support Files/Pods-工程名字/Pods-"+target.name+"-frameworks.sh"
    shell_script_input_lines = File.readlines(shell_script_path)
    shell_script_output_lines = shell_script_input_lines.map { |line| line.sub("source=\"$(readlink \"${source}\")\"", "source=\"$(readlink -f \"${source}\")\"") }
    File.open(shell_script_path, 'w') do |f|
      shell_script_output_lines.each do |line|
        f.write line
      end
    end
  end
end

降低版本

XCode14.3问题很多,XCode14.2表现稳定,所以可以下载一个XCode14.2备用。

企业微信截图_feacad76-6d95-4d74-b213-4193a273e259.png

关于Command Line Tools

网上有文章说,在XCode14.3的环境中,使用14.2的Command Line Tools来解决问题。

image.png 企业微信截图_fff5254c-086b-4f5d-b0b3-9f83fb8244f5.png

这个问题可以通过设置XCode14.2命令行工具解决

小结

经过多方权衡,还是将XCode降级为14.2来解决问题比较好。

公司其他同事还没有升级,就别升级了,继续使用XCode14.2

参考文档

XCode升级14.3 archive打包失败

升级XCode14.3后,构建失败

iOS问题记录 - Xcode 14.3版本运行项目报错

后记

上一篇 下一篇

猜你喜欢

热点阅读