Xcode 12为模拟器建立目标的顺序错误? [英] Xcode 12 build target in wrong order for simulator?

查看:169
本文介绍了Xcode 12为模拟器建立目标的顺序错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目始终在使用Xcode 11的所有设备上正常运行,但是在我安装Xcode 12 beta 4之后,它无法在模拟器上进行构建.

我比较了Xcode 11和Xcode 12的构建日志,在Xcode 12中似乎我的主要目标是在可可豆荚目标之前建立的,因此该链接将失败,因为找不到可可脂类库. >

如何确定构建目标的顺序?

在Xcode 11中,一切都很好. 我自己的目标是在cocoapods目标之后建立的.

在Xcode 12中,构建乱序我的目标是在cocoapods目标之前构建的.

解决方案

好,我有一个使构建工作生效的解决方案(这种解决问题的方法不正确,在我的解决方案中添加了正确的解决方法更新):

1,您需要将Pods项目作为外部项目添加到主项目中

2在主项目的构建阶段中显式添加所有cocodpods目标作为依赖项

但是我仍然认为xcode 12的新beta版将解决此问题.因为它似乎是xcode 12的错误(我的项目在xcode 11和xcode 12 + ios设备中运行完美,仅在xcode 12 +模拟器中失败)

### 2020-08-17更新###

我找到了一个更确切的原因来重现此问题,看来我在xcode 12中打开的项目文件将在User-Defines中自动生成VALID_ARCHS宏,并且此宏将使构建失败

我发现,使用此宏,在建筑物的LINK期间,链接目标类型将为未知类型 " arm64-apple-ios11.0-simulator " 这会导致构建失败,并且所有目标似乎都以错误的顺序构建的问题只会在添加此宏后才会发生

XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-ios11.0-simulator 

删除此VALID_ARCHS宏后,链接目标类型将为' x86_64-apple-ios11.0-simulator ',一切正常

XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-ios11.0-simulator 

#### 2020-09-11 add添加有关此宏的Apple反馈####

更新苹果对VALID_ARCHS的反馈
  • 查看您的反馈后,我们还有一些其他信息 为您:

  • Xcode不会将VALID_ARCHS添加到您的项目中.确实,我们建议 反对使用VALID_ARCHS.也许某些CocoaPod正在将其设置在您的 项目出于某种原因? CocoaPods不是Xcode的一部分,所以我们不 对他们的工作有任何控制权.

    要注意的一件事是,在Xcode 11中,VALID_ARCHS显示在 体系结构部分.由于我们强烈建议您反对 使用它,它不再在那里显示,现在显示在用户中 定义的部分(如果已定义的话).

  • Xcode 11用于自动翻译arm64的构建 模拟器已针对x86_64构建,但现在arm64是有效的 模拟器架构(这是Apple Silicon架构), 翻译不再发生.

  • 因此,我们怀疑您应该从您的帐户中删除VALID_ARCHS 项目,并确保将架构(ARCHS)设置为 标准体系结构(ARCHS_STANDARD)而非特定内容 (除非您确切地知道为什么不使用ARCHS_STANDARD).

####反馈结束####

#### 2020-10-10添加####

在删除某些人的VALID_ARCHS宏之后,该构建可能仍无法正常工作,您可以在下面查看添加的Apple反馈的答案以及@Andrei Herford的答案:

确保将架构(ARCHS)设置为标准架构 (ARCHS_STANDARD)

然后删除该宏,希望这两个步骤对所有用户都有效:)

#### 2020-10-10添加结束####

My project always runs correctly on all devices using Xcode 11, but after I installed Xcode 12 beta 4, it is failing to build on the simulator.

I compared the build logs of Xcode 11 and Xcode 12 and it seems in Xcode 12 that my main target is being built before the cocoa pods target, and so the link will fail because the cocoapods library will not be found.

How to fix the order of the build target?

In Xcode 11, everything is fine. My own target is built after the cocoapods target .

In Xcode 12, the build is out of order My own target is built before the cocoapods target .

解决方案

OK, i got a solution to make the build work (this way to fix problem is not correct , the right way to fix is added in my update):

1 you need to add the Pods project to your main project as a external project

2 add all the cocodpods target as dependency explicitly in your main project 's build phase

But i still think may be the new beta version of xcode 12 will fix this. because it seem a bug of xcode 12 (my project work perfect in xcode 11 and xcode 12 + ios device , failed in xcode 12 + simulator only)

###2020-08-17 update###

i found a more exactly reason to reproduce this problem , it seems my project file open in xcode 12 will auto generate a VALID_ARCHS macro in User-Defines , and this macro will make the build failed

And i found that ,with this macro , During in the LINK of building,the link target type will be a unknown type 'arm64-apple-ios11.0-simulator' which cause the build faild and the problem that all the targets build in wrong order seems will only happen when this macro is being added

XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-ios11.0-simulator 

after i delete this VALID_ARCHS macro, the link target type will be 'x86_64-apple-ios11.0-simulator' , and everything goes well

XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-ios11.0-simulator 

####2020-09-11 add Add Apple's Feedback about this macro####

update Apple's Feedback on VALID_ARCHS
  • After reviewing your feedback, we have some additional information for you:

  • Xcode does not add VALID_ARCHS to your project. Indeed, we recommend against using VALID_ARCHS. Maybe some CocoaPod is setting it in your project for some reason? CocoaPods are not part of Xcode so, we don’t have any control over what they do.

    One thing to note is that in Xcode 11 VALID_ARCHS showed up under the architectures section. Since we are strongly recommending against using it, it no longer shows up there and now appears in the User Defined section if it is defined at all.

  • Xcode 11 used to automatically translate building for arm64 for the simulator into building for x86_64, but now that arm64 is a valid simulator architecture (it’s the Apple Silicon architecture), that translation no longer occurs.

  • So, we suspect what you should do is delete VALID_ARCHS from your project altogether, and make sure Architectures (ARCHS) is set to Standard Architectures (ARCHS_STANDARD) and not to something specific (unless you really know exactly why you’re not using ARCHS_STANDARD).

####Feedback end####

####2020-10-10 added####

the build may still not working after deleting the VALID_ARCHS macro for some guys , you may check the answer of Apple's feedback added and @Andrei Herford's answer below:

make sure Architectures (ARCHS) is set to Standard Architectures (ARCHS_STANDARD)

and then delete the macro ,hope these two steps works for all:)

####2020-10-10 added end####

这篇关于Xcode 12为模拟器建立目标的顺序错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆