Xcode 12 beta 4 - error compiling for Simulator

An existing framework library workspace compiles without error when targeting iOS device architecture, but when targeting Simulator I receive the following error:

Code Block
Code Block
ld: in /Users/macbook/Documents/Projects/iOS/HungerStation/Code/customer-app-ios/Pods/mopub-ios-sdk/MoPubSDK/Viewability/MOAT/MPUBMoatMobileAppKit.framework/MPUBMoatMobileAppKit(MPUBMoatAnalytics.o), building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

As per this https://developer.apple.com/forums/thread/655316

Changing build setting "Build Active Architecture Only" from No to Yes doesn't solve this problem

Has anyone else seen this?
Post not yet marked as solved Up vote post of kiji123 Down vote post of kiji123
51k views
  • Try to install pod again Open terminal change your project directory install pod

Add a Comment

Replies

Hi, I am facing the same issue, I have deleted the variable "VALID_ARCHS" from "build settings", it solved the architecture issue but my project fails to build at last.


Code Block
Showing Recent Messages
Resource "/Users/ikjotsingh/Library/Developer/Xcode/DerivedData/OrderPay-cfxtbumiszxnyohjotjyvymxenhc/Build/Products/Debug-iphoneos/ModularUICore/ModularUICore.framework/ColorAssets.car" not found. Run 'pod install' to update the copy resources script.

it shows the above error, its somehow that my pods are not being installed correctly
/Pods/Target Support Files/Pods-ProjectName/Pods-ProjectName-frameworks.sh: line 144: ARCHS[@]: unbound variable
Command PhaseScriptExecution failed with a nonzero exit code

Anyone knows how to fix this on xcode 12 ? tried all of the above nothing works
Post not yet marked as solved Up vote reply of Dari Down vote reply of Dari
kiji123 Thanks - Work your solution:
I have multiple schemes, I searched in all documents of my project "ONLYACTIVEARCH" and then I changed the parameter ONLYACTIVEARCH = NO in the scheme whit error and fixed the issue.

I build a FAT development framework for distribution which needs to contain arm and intel slices. Forcing it to build just active architecture is not a solution for me. I have been playing with using external myCodeSettings.xcconfig file containing lines like the following:

Code Block
EXCLUDE_ARCHS_FOR_Release_iphoneos=i386 x86_64
EXCLUDE_ARCHS_FOR_Release_iphonesimulator=arm64 arm7s armv7
EXCLUDE_ARCHS= $(__EXCLUDE_ARCHS_FOR_$(CONF)_$(PLATFORM_NAME))

and associate the myCodeSettings.xcconfig in General project settings tab on specific targets that need to build.

Appeared to work, by replacing the subsequent EXCLUDEARCHS dynamically based on what you are trying to build.

There was one build failure so I was looking into applying similiar technique for VALID
ARCHS and ARCHS settings.

Anyone feel they have been successful and post their solution?
I don't believe you can remove all architectures from VALIDARCHS or ARCHS or the build will be successful but Xcode would not compile nor link anything for the framework or library.

The log should contain a message indicating no archs were specified.

Same is true if you exclude all architectures within EXCLUDE
ARCHS .



For a general short term solution to this issue, the exclusion of arm64 arch needs to be specifically tied to iOS Simulator platform build.

If solution is not tied to iOS Simulator platform, you are telling Xcode to never build for the arm64 arch.

This solution doesn't work for me since I need to distribute FAT framework with all the iOS archs and all the iOS Simulator archs.

The newer Xcode 12 is treating arm64 as an iOS Simulator architecture as well as a legacy iOS architecture probably because MacOS Big Sur 11 running on an Arm64 based Mac will be running the iOS Simulator on arm64... But the Xcode folks didn't appear to think thru the affects.

Xcode 12 UX needs to be able to differentiate arm64 iOS Simulator from arm64 iOS in a better way. The generated binary need to include extra metadata so linker can tell choose the correct arch within a FAT library framework without displaying error because it chose unwisely.
@chimcanhcutptit@gmail.com sloved my problem,thank you
Just adding some more info. Xcode 12.2 Beta Release Notes includes this note:

Swift Packages
Known Issues
Swift Packages may not respect the “Build Active Architecture Only” project build setting when you try to build universal binaries. (64344067)

Workaround: Use the “Any Mac”, “Any iOS Device (arm64)”, “Any watchOS Device”, or “Any tvOS Device” destination to build for all applicable devices.

I know it's kinda unrelated because it's Xcode 12.2 (which none of us is probably using yet), and it's related to Swift Packages, but maybe this is also the case on Xcode 12 GM and non-Swift Package builds.
My project used VALID_ARCHS.

Removing only that build setting in Xcode 12 made the app runnable on the simulator.

Removing VALID_ARCHS required first clearing out its setting values. Then I was able to delete the entry itself and successfully build and run on the sim.
As mentioned in the previous replies, the issue appears to be Xcode 12's inclusion of arm64 arch in the iPhone simulator, thus causing a clash between iPhone and Simulator when they are being combined to create the fat library.

So I followed kai_kai and @chimcanhcutptit@gmail.com's recommendation below and appears to have solved the problem (I was able to run my library in both simulator and real device). Basically the solution is to exclude arm645 architecture from the iphone simulator. This could have an impact when testing on arm64 macs later on - or may be not.

Select the project or target -> Build Settings -> Excluded Architecture (if you can't see it make sure [All] properties are selected) and set the Excluded Architecture for 'Any iOS simulator SDK' -> 'arm64'.
Same issue. Nothing has worked so far.
Removing VALID_ARCHS from the build settings (left over from my XCode11) and then excluding arm64 when building for the simulator solved this for me.
Applying the following myProjectSettings.xcconfig settings to the Project Configurations has fixed the issue in my builds and still allows additional .xcconfig settings to be applied to individual targets within the Project. This explicitly sets the architectures for the iphoneos and iphonesimulator Xcode settings that are associated with ARCHS , VALIDARCHS , and EXCLUDEDARCHS.

Code Block
EXCLUDED_ARCHS[sdk=iphoneos*] = x86_64
EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64
ARCHS[sdk=iphoneos*] = arm64
ARCHS[sdk=iphonesimulator*] = x86_64
VALID_ARCHS[sdk=iphoneos*] = arm64
VALID_ARCHS[sdk=iphonesimulator*] = x86_64


NOTE: More architectures (e.g. armv7, armv7s, arm64e, etc) could be added to each of these settings for your build environment. My specific build intel based macOS environment does not include additional architecture because some third party binary frameworks don't include extra architectures.
@mvl-dxie answer helped me! and its the only thing that worked, thanks man!
Code Block
xcodebuild -configuration "Release" -scheme "${TARGETS_NAME}" -arch arm64 -arch armv7 -sdk "iphoneos"