Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
382 views
in Technique[技术] by (71.8m points)

cocoapods - Xcode 12 build target in wrong order for simulator?

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 .

enter image description here

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

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

enter image description here

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####


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...