前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Xcode14编译失败修改

Xcode14编译失败修改

原创
作者头像
莫空9081
发布2022-09-14 10:29:36
4.6K0
发布2022-09-14 10:29:36
举报
文章被收录于专栏:iOS 备忘录iOS 备忘录

背景

升级Xcode 14后,项目编译失败修改,共修改了两种编译错误:

  • 一种是bundle code sign error,Xcode 14 needs selected Development Team for Pod Bundles
  • 一种是Module compiled with Swift 5.6.1 cannot be imported by the Swift 5.7 compiler

<!--more-->

其中第一种比较容易解决,第二种稍微麻烦点,解决方案如下:

解决

Xcode 14 bundle code sign error

这个的解决方案,直接Google,第一个stackoverflow的链接是Xcode 14 needs selected Development Team for Pod Bundles,这里面给出的解决方法是,在Podfile里增加下面代码,然后运行Pod install,设置Pod库的DEVELOPMENT_TEAM是开发者账号的team。

笔者有两个项目,其中一个是Swift为主,用下面的设置方法试了,可以解决。要注意的是如果项目有多个target,target的开发者team又不同时需要区分设置,可参考下面注释的代码。

代码语言:txt
复制
post_install do |installer|
  installer.generated_projects.each do |project|
    project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings["DEVELOPMENT_TEAM"] = "Your Team ID"
#            if target.name == 'test'
#            config.build_settings["DEVELOPMENT_TEAM"] = "Your Team ID"
#          else
#            config.build_settings["DEVELOPMENT_TEAM"] = "Your Another Team ID"
#          end
         end
    end
  end
end

但是,笔者另外一个OC的项目中,按照这个方法设置,却一直不行,也是神奇,所以又找了另一个解决方案,来自CocoaPods的issue,Xcode 14 build failed with manual code sign and app resource bundles ,其中的解决方案有一种是设置CODE_SIGN_IDENTIFY为空,如下:

代码语言:txt
复制
installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
        config.build_settings['CODE_SIGN_IDENTITY'] = ''
    end
end

这种避免了区分设置DEVELOPMENT_TEAM的情况,在两个项目里设置如上代码,都可以编译成功。

Module compiled with Swift 5.6.1 cannot be imported by the Swift 5.7 compiler

这个错误直接一看是Swift版本不兼容,再仔细看错误,应该看到提示的库是三方SDK的,对于笔者的项目来说是使用Carthage集成的SDk的。昂,应该是使用Carthage编译的xcframeworks导致的,所以就去重新编译xcframeworks,但是编译的时候,Moya库一直编译失败,手动去编译Moya发现编译到真机成功,编译到模拟器就失败,报错Could not find module 'Alamofire' for target 'x86_64-apple-ios-simulator';,难搞,这个地方找解决方法找了好久,最后还是在Using Carthage with Xcode 12这里看到了解决方法,这个方法可以remove arm64 simulator architecture from compiled framework

解决方法如下:

remove arm64 simulator architecture from compiled framework
remove arm64 simulator architecture from compiled framework

顺便说一下,笔者的电脑并不是Macs running Apple Silicon,是intel芯片的电脑。

参考

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 背景
  • 解决
    • Xcode 14 bundle code sign error
      • Module compiled with Swift 5.6.1 cannot be imported by the Swift 5.7 compiler
      • 参考
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档