Xcode 12 build target in wrong order for simulator? Xcode 12 build target in wrong order for simulator? xcode xcode

Xcode 12 build target in wrong order for simulator?


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 informationfor you:

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

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

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

  • So, we suspect what you should do is delete VALID_ARCHS from yourproject altogether, and make sure Architectures (ARCHS) is set toStandard 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####


I was able to solve the problem both in simulator and on device by using $(ARCHS_STANDARD) not only for ARCHS in the Architecture settings but also in VALID_ARCHS as well. I am not sure what possible side effect changing the archs in this way might have but so far I have not experiencend any new problems.

enter image description here

Details:

The excellent answer by @ximmyxiao got me on the right track. However, the solution proposend by him (remove VALID_ARCHS) did not work for me. This led to a new problem when compiling the Pod targets (Command PhaseScriptExecution failed with a nonzero exit code and ARCHS[@]: unbound variable in Pods script).

Instead replacing arm64 with x86_64in VALID_ARCHS solved the problem when building for simulator. It seems that arm64 was never a correct platform and was translated to x86 by Xcode. As Apple has announced their shift to ARM processors, this translation is not correct anymore and thus one has to use the the correct platform x86_64 instead.

Regarding to Apple VALID_ARCHS should not be used any more. However, this fix did not work when building for devices. Eventually using $(ARCHS_STANDARD) instead (both for simulator and device) did the trick in both cases.

Good look to others who encounter this kind of problems. Never gets boring working with Xcode....


** For XCode 12.4 **

I have Apple MB Pro with M1 and the project with Moya POD and lot of others.App builds perfectly in old intel-based macbook with the same version of XCode (12.4).But for M1 it won't compile says: "Moya not found". What??

It said: "Could not find module 'Moya' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator".

No suggestions worked for me. So what helped me is:

  • (not sure whether this is necessary): reinstall all pods by pod install
  • clear build data
  • launch via Rosette (check this in XCode app properties cmd+i)

in App's Project:

  • "Architectures": add x86_64
  • "Build Active Architecture Only": YES

in "Pods" project, conflicting pod section (Moya in my case):

  • "Build Active Architecture Only": YES

Then rebuild. Probably next rebuild also required.