ChatGPT解决这个技术问题 Extra ChatGPT

Xcode building for iOS Simulator, but linking in an object file built for iOS, for architecture 'arm64'

I am trying to get a large (and working on Xcode 11!) project building in Xcode 12 (beta 5) to prepare for iOS 14. The codebase was previously in Objective-C, but now it contains both Objective-C and Swift, and uses pods that are Objective-C and/or Swift as well.

I have pulled the new beta of CocoaPods with Xcode 12 support (currently 1.10.0.beta 2).

Pod install is successful. When I do a build, I get the following error on a pod framework:

building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

and possibly also the error:

Unable to load standard library for target 'arm64-apple-ios11.0'

When I go run lipo -info on the framework, it has: armv7s armv7 i386 x86_64 arm64.

Previously, the project had Valid Architectures set to: armv7, armv7s and arm64.

In Xcode 12, that setting goes away, as per Apple's documentation. Architectures is set to $(ARCHS_STANDARD). I have nothing set in excluded architectures.

What may be going on here? I have not been able to reproduce this with a simpler project yet.

Check out the article: milanpanchal24.medium.com/…
I have an Apple Silicon M1, and am still running into this arm64 error. Why would that be the case?
Same here, Apple M1, just started to happen. None of the solutions I can find seem to work.. any one any idea?? building for iOS Simulator, but linking in object file built for iOS, file '/.............../Pods/GoogleMaps/Maps/Frameworks/GoogleMapsCore.framework/GoogleMapsCore' for architecture arm64
TLDR; XCode 13 + Apple M1: (1) Open Xcode using Rosetta (Applications -> Right-Click Xcode -> Get Info -> Check Open with Rosetta). (2) Add arm64 to excluded architectures (Build Settings) (3) Clean Build Folder (4) Run app

P
Peter Mortensen

Basically, you have to exclude arm64 for the simulator architecture, both from your project and the Pod project,

To do that, navigate to Build Settings of your project and add Any iOS Simulator SDK with value arm64 inside Excluded Architecture.

OR

If you are using custom XCConfig files, you can simply add this line for excluding simulator architecture. EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64 Then You have to do the same for the Pod project until all the Cocoa pod vendors are done adding following in their Podspec. s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } You can manually add the Excluded Architecture in your Pod project's Build Settings, but it will be overwritten when you use pod install. In place of this, you can add this snippet in your Podfile. It will write the necessary Build Settings every time you run pod install. post_install do |installer| installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" end end


The extra detail about CocoaPods here is nice. Note that without [sdk=iphonesimulator*] after EXCLUDED_ARCHS, XCode will fail to find your pods when building for an actual device since none of the pods will be built for arm64.
Worked for me! Note that there is already a post_install do |installer| section in most Podfiles due to flipper. Paste the inner section installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" end behind the flipper_post_install(installer) line.
I am getting building for iOS Simulator, but linking in object file built for macOS, for architecture x86_64. How to fix it?
This solution is excellent and I would add that if you are building your own pod, take note particularly of the 2 lines the author suggests after "...until all the cocoa pod vendors are done adding in their Podspec" as the absence of these in my own framework's Podspec was causing linting failures when I attempted to push it to my private repo. Thanks!
This ends up working sometimes, but is actually wrong and broken. EXCLUDED_ARCHS for arm64 on the simulator means that people with Apple Silicon macs won't be able to use your framework. The fix that actually worked for me was to clear out VALID_ARCHS as per stackoverflow.com/a/63714000/234
P
Peter Mortensen

TL;DR;

Set "Build Active Architecture Only (ONLY_ACTIVE_ARCH)" to Yes for your libraries/apps, even for release mode.

While trying to identify the root cause of the issue I realized some fun facts about Xcode 12.

Xcode 12 is actually the stepping stone for Apple silicon which unfortunately is not yet available (when the answer was written). But with that platform we are going to get an arm64-based macOS where simulators will also run on the arm64 architecture unlike the present Intel-based x86_64 architecture. Xcode usually depends on the "Run Destination" to build its libraries/applications. So when a simulator is chosen as the "Run Destination", it builds the app for available simulator architectures and when a device is chosen as the "Run Destination" it builds for the architecture that the device supports (arm*). xcodebuild, in the Xcode 12+ build system considers arm64 as a valid architecture for simulator to support Apple silicon. So when a simulator is chosen as the run destination, it can potentially try to compile/link your libs/apps against arm64 based simulators, as well. So it sends clang(++) some -target flag like arm64-apple-ios13.0-simulator in --- format and clang tries to build/link against an arm64-based simulator that eventually fails on an Intel based Mac. But xcodebuild tries this only for Release builds. Why? Because, "Build Active Architecture Only (ONLY_ACTIVE_ARCH)" build settings is usually set to "No" for the "Release" configuration only. And that means xcodebuild will try to build all architectural variants of your libs/apps for the selected run destination for release builds. And for the Simulator run destination, it will includes both x86_64 and arm64 now on, since arm64 in Xcode 12+ is also a supported architecture for simulators to support Apple silicon.

Simply putting, Xcode will fail to build your application anytime it tries the command line, xcodebuild, (which defaults to release build, see the general tab of your project setting) or otherwise and tries to build all architectural variants supported by the run destination. So a simple workaround to this issue is to set "Build Active Architecture Only (ONLY_ACTIVE_ARCH)" to Yes in your libraries/apps, even for release mode.

https://i.stack.imgur.com/EwcNf.png

https://i.stack.imgur.com/ryqPU.png

If the libraries are included as Pods and you have access to .podspec you can simply set:

spec.pod_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' }

spec.user_target_xcconfig = { 'ONLY_ACTIVE_ARCH' => 'YES' } # not recommended

I personally don't like the second line since pods shouldn't pollute the target project and it could be overridden in the target settings, itself. So it should be the responsibility of the consumer project to override the setting by some means. However, this could be necessary for successful linting of podspecs.

However, if you don't have access to the .podspec, you can always update the settings during installation of the pods:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
    end
  end
end

One thing I was concerned about that what will be the impact of this when we actually archive the libraries and applications. During archiving applications usually take the "Release" configuration and since this will be creating a release build considering only the active architecture of the current run destination, with this approach, we may lose the slices for armv7, armv7s, etc. from the target build. However, I noticed the documentation says (highlighted in the attached picture) that this setting will be ignored when we choose "Generic iOS Device/Any Device" as the run destination, since it doesn't define any specific architecture. So I guess we should be good if we archive our app choosing that as a run destination.


This is really a surprising change from Apple and costed me half a day to figure out that I feel Apple should compensate :). This is not a documented update (at least as I know of) and certainly going to affect everyone upgrading to Xcode 12. I only hope everybody finds their own way to get over with it once they know the basics.
If multiple pod specs use user_target_xcconfig and the values don't match exactly, CocoaPods will emit warnings like this [!] Can't merge user_target_xcconfig for pod targets: [... list of pods ...]. Singular build setting EXCLUDED_ARCHS[sdk=<...>] has different values. The podspec syntax reference says this attribute is "not recommended" guides.cocoapods.org/syntax/podspec.html#user_target_xcconfig. So please don't use user_target_xcconfig for this to save many developers the trouble.
Right! And I think I already have mentioned that in my answer.
I managed to get it all working in the end with 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' but only in pod_target_xcconfig, and only on the problem pod (which included a prebuilt library) and the single pod which depended on the problem pod. Everything else was left clean. I decided I preferred that to the active arch solution.
On Apple Silicon, doing this lead to another error. This may be due to some specific pods. I opened a specific question for theses cases. stackoverflow.com/questions/65364886/…
P
Peter Mortensen

I found a solution! SwiftUI Previews not working with Firebase

If you set excluded architectures for the simulator to arm64 it will compile.

https://i.stack.imgur.com/tISvF.png


Fair enough, the issue I was having was with a manually linked library however it did not cause a problem with our pods we're using either.
I was testing on Release mode so I had to add it to Release too
I think we are back in the business after this post. thank you it helped.
This worked for me, but only when I build for arm64; simulators don't work. Small rant: xCode is ridiculous, 12.5 gigs, tons of pods. Building for Android is a walk in the park compared to this experience.
This won't work on M1 mac
P
Peter Mortensen

The proposed answers are outdated/incorrect.

You should initially try to update both CocoaPods and the dependencies for your library/app, and then, if that doesn't work, contact the vendors of any dependencies you are using to see if they have an update in progress to add support for arm64 Simulator slices on M1 Macs.

There are a lot of answers on here marked as correct suggesting that you should exclude arm64 from the list of supported architectures. This is at best a very temporary workaround, and at worst it will spread this issue to other consumers of your libraries. If you exclude the arm64 Simulator slice, there will be performance impacts on apps that you're developing in the Simulator (which in turn can lead to reduced battery time for your shiny new M1 kit while you're developing your amazing ideas).


That's true, as mangling with excluding or including architectures works solely on i386-based machines.
Tell that to GOOGLE... They still don't support SPM. It'll be years.
this answer should be the correct accepted answer. @BeauNouvelle Google recently opened sourced lots of their SDKs (like GoogleSignIn) which now supports xcframework with arm64 simulator slices ;)
I agree, this is the correct answer, however, sometimes you have to deal with legacy stuff. On Intel I had to go with the answer from @AyanSengupta to being able to test my debug build.
This is correct, but still doesn't offer a workable alternative for unmaintained projects unfortunately 😅
P
Peter Mortensen

The Valid Architectures build setting has been removed in Xcode 12. If you had values in this build setting, they're causing a problem and need to be removed.

I was able to "clear out" the VALID_ARCHS build setting by adding it back in as a user-defined build setting (with no values), running the project (which failed), and then deleting the VALID_ARCHS build setting. After that, I was able to run on the simulator.

My Architectures build setting is Standard Architectures.

You can add a user-defined setting from the plus button in Build Settings:

https://i.stack.imgur.com/h9hUk.png


This should be the accepted answer. Make sure the app project is selected not the Target. Otherwise, you won't be able to delete the VALID_ARCHS from Build Settings. :)
@trishcode Even after doing this i'm getting same error(xcode12 beta4), any work arounds
@SivakrishnaPerla If you can open the project in Xcode 11, then you can see exactly which targets Valid Architectures is used on. You could even clear the setting in Xcode 11, and then try the project again in Xcode 12. If you still need a workaround and you're getting the error on an embedded framework, then SlashDevSlashGnoll's answer should work. If you need a workaround and you're getting the error on a Cocoapod, then exclude the arm64 architecture in the Podfile post install.
@trishcode Thanks, Setting arm64 in excluded architecture and removing VALID_ARCHS worked.
If I remove VALID_ARCHS and add arm64 to Excluded architecture, I get this error - Check dependencies No architectures to compile for (ARCHS=arm64 x86_64, VALID_ARCHS=, EXCLUDED_ARCHS=( arm64 )).
R
RunesReader

Xcode 12.3

I solved this problem by setting Validate Workspace to Yes

https://i.stack.imgur.com/QcYW4.png


Solved my issue. Easiest fix! I'm glad this is resolved, but can someone explain how this fixes the issue?
I had the issue with UI Tests and KIF library (it's an Xcode Unit Test using KIF). I tried all the other solutions and nothing worked until I enabled the "Validate Workspace" just for those Unit Tests.. thanks!
This is the only solution that worked for me, however it does keep a "Target Integrity" warning in the debugger.
After trying all other solutions over last few days with no success, this one worked for me on my Xcode 12.2.
What is it supposed to do? Why does it work? Preferably, update your answer. (But without "Edit:", "Update:", or similar - the answer should appear as if it was written today.)
T
Tomas Ward

Hidden Gem in all these answers

https://i.stack.imgur.com/SEYAV.png


Will this affect the build in production for some devices?
@MohamedAbdou arm64 is used for physical devices, so I assume there might be a conflict when trying to simulate it on a real iPhone. Either way, you could try it as is, and in any case, you remove arm64 as an Excluded Architecture. For actual production and release, I suggest you simulate it successfully on both physical and virtual devices and use those settings for the release.
not perfect answer either, now your project doesn't compile on M1 & simulator, because all pods are excluded
Remember to set excluded archs for the project and not the targets so that all targets inherit the excluded archs setting
8
8HP8

Easy fix

Right click on xcode in Applications folder Get info Select "Open using Rosetta"

Run.

Xcode get info


This was enough for me! Cordova project with many plugins (including Firebase) started getting this error when we moved to the M1 mac.
This is the only answer that works for me on the Apple M1 processor.
This is the only answer works for me on M1 and xCode 13. The other options suggested doesn't even exist in xCode 13.
not great, now you are running Xcode on Rosetta emulator, which means your stuff runs slow
C
Camsoft

After trying and searching different solutions, I think the most safest way is adding the following code at the end of the Podfile

post_install do |pi|
   pi.pods_project.targets.each do |t|
       t.build_configurations.each do |bc|
          bc.build_settings['ARCHS[sdk=iphonesimulator*]'] =  `uname -m`
       end
   end
end

This way you only override the iOS simulator's compiler architecture as your current cpu's architecture. Compared to others, this solution will also work on computers with Apple Silicon.


It's great to see someone at least understands the issue and is not suggesting just removing Apple Silicon support for the iOS Simulator.
For Apple Silicon, it's the only one that works
P
Peter Mortensen

For me the following setting worked:

Build Settings → Excluded Architectures.

I added "arm64" to both Release and Debug mode for the "Any iOS Simulator SDK" option.

https://i.stack.imgur.com/7Oe6S.png


This fixed my issue with the error: Framework not found Pods_OneSignalNotificationServiceExtension. Was working on the simulator but not the device. Thanks!
it's help me, thanks!
p
programmer

Go to Targets section, select each target and do the following:

Set Build Active Architecture Only to YES

Add Excluded Architectures and set its value to arm64 (See attached)

Set Active scheme (on toolbar next to project name) to any iOS Simulator

Clean Build folder from Product Menu and build.

https://i.stack.imgur.com/HRVFd.jpg


Shouldn't "Build Active Architecture" be "Build Active Architecture Only"?
@PeterMortensen yes, you're right. fixed that.
Excluding arm64 conflicts with Facebook SDK. It wants arm64, and if arm64 is excluded, it says "Could not find module 'FBSDKCoreKit' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator"
Architecture is not visible in most targets. Why is that?
B
Bosco Domingo

I found that

Using Rosetta (Find Xcode in Finder > Get Info > Open using Rosetta) Build Active Architecture Only set to YES for everything, in both Project and Target (You might not need it, read comment below) And including this in the podfile:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
    end
  end
end

worked for me.

We had both Pods and SPM and they didn't work with any of the combinations of other answers. My colleagues all use Intel MacBooks and everything still works for them too!


The podfile code might not be necessary. I have found I no longer need it by some magic power when its absence would once make Xcode fail to build. As of today it is no longer in the podfile and everything still works, so FYI. "Build to Active Arch only" is still set to yes for Project and Target (for my Dev builds since that's all I do as I'm not in charge of releases, but I doubt it would break much to use it for Release builds too)
OMG, after 4 hours of digging, your answer solved my issue! I am on a M1 Mac and using CocoaPods and SPM too. I think all above answers are for fixing CocoaPods only, but does not fix issues for SPM. And you are right, I did not actually need your step 3, just first 2 steps and it's all working! Thank you!
P
Peter Mortensen

I solved the problem by adding "arm64" in "Excluded Architectures" for both the project target and pod target.

Xcode → Target Project → Build Setting → Excluded Architectures → *"arm64"

Xcode → Pod Target → Build Setting → Excluded Architectures → *"arm64"


P
Peter Mortensen

If you have trouble in Xcode 12 with simulators, not real device, yes you have to remove VALID_ARCHS settings because it's not supported anymore. Go to "builds settings", search "VALID_ARCHS", and remove the user-defined properties. Do it in every target you have.

Still, you may need to add a script at the bottom of your podfile to have pods compiling with the right architecture and deployment target:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
      config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
     end
  end
end

Removing the VALID_ARCHS from my project worked fine. I changed nothing to the podfile nor the pods project.
Thanks @ÁngelTéllez worked for me as well. saved my time
then any solution for iphone device?
N
Navigator

After upgrading to Xcode 12 I was still able to build for a real device, but not the simulator. The Podfile build was working only for the real device.

I deleted VALID_ARCHS under Build Settings > User-Defined and it worked! Bashing my head for some time before finding this.


M
Martin Brisiak

1.Add arm64 to Build settings -> Exclude Architecture in all the targets.

https://i.stack.imgur.com/8RYFH.png

2.Close Xcode and follow the steps below to open

Right-click on Xcode in Finder Get Info Open with Rosetta


This worked for me. It's scary, but it worked.
Works, thanks, open with rosetta was the key
a
azeem usmani

Xcode Version 13.2.1 and macOS Monterey 12.0.1

Almost everybody is facing the same issue with old projects and pods after switching to new M1 chip system.

"in /Users//Desktop/_iOS_app/Pods/iOS/framework/(CLSInternalReport.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/y/Desktop/_iOS_app/Pods/iOS/.framework/for architecture arm64"

I have come to a solution which is working perfectly.

First thing first, to all the developer who are suggesting exclude arm64 for your project will work yes it will compile but after installation when you try to open it, it will show a popup with the message, "the developer of this App needs to be update it to work with this version of iOS". This is because as per apple "In iOS 11 and later, all apps use the 64-bit architecture" and if you exclude arm64 for your project it will not open App on iOS 11 and later.

https://i.stack.imgur.com/nBDBS.jpg

So instead of selecting whole project only excluded architectures for the simulator to arm64.

Steps: On top of project files, Select target > build setting > architecture > excluded architecture. now add select "any iOS simulator SDK" and give it a value arm64.

See the image below for refrence.

https://i.stack.imgur.com/2C1qf.png


this one worked for me
P
Pratik Sodha

Xcode 12

Removing VALID_ARCH from Build settings under User-Defined group work for me.

https://i.stack.imgur.com/y4Yog.png


Removing? Do you mean changing its value to something empty'ish?
Yeah, Remove it from the build setting. It's worked for me.
Finally got this working, thank you. I deleted from the project.pbxproj file.
P
Peter Mortensen

I was having issues building frameworks from the command line. My framework depends on other frameworks that were missing support for ARM-based simulators. I ended up excluding support for ARM-based simulators until I upgrade my dependencies.

I needed the EXCLUDED_ARCHS=arm64 flag when building the framework for simulators from the command line.

xcodebuild archive -project [project] -scheme [scheme] -destination "generic/platform=iOS Simulator" -archivePath "archives/[scheme]-iOS-Simulator" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES EXCLUDED_ARCHS=arm64

Same here. Key "problem" in this scenario is actually building for a generic destination via -destination "generic/platform=iOS Simulator". This leads to building for all available architectures, which includes arm64 since Xcode 12.
b
btxios

I believe I found the answer. Per the Xcode 12 beta 6 release notes:

"The Build Settings editor no longer includes the Valid Architectures build setting (VALID_ARCHS), and its use is discouraged. Instead, there is a new Excluded Architectures build setting (EXCLUDED_ARCHS). If a project includes VALID_ARCHS, the setting is displayed in the User-Defined section of the Build Settings editor. (15145028)"

I was able to resolve this issue by manually editing the project file (I could not figure out how to remove the item from the project file using Xcode) and removing all lines referring to VALID_ARCHS. After that, I am able to build for the simulator fine.


Using Xcode, VALID_ARCHS is in select Project (not Target) then `Build Setting -> User-Defined". select it and delete it.
This solution worked for me. The solution suggested by some others didn't work as just adding value 'arm64' to the 'Exclude Architecture' field started giving some 'File Permission' error for the generated .app file.
Thanks @btxios and Akshay. Worked like a charm, Its party time
P
Peter Mortensen

After trying almost every answer to the question and reading through Apple developer forums I found only one solution worked for me.

I am building a universal framework that is consumed in a Swift app. I was unable to build to the simulator without architecture errors.

In my framework project I have a Universal Framework task in my build phases. If this is the case for you:

Add the following to your xcodebuild task inside the build phase: EXCLUDED_ARCHS="arm64"

Next you have to change the following project Build Settings:

Delete the VALID_ARCHS user defined setting

Set ONLY_ACTIVE_ARCH to YES ***

*** If you are developing a framework and have a demo application as well, this setting has to be turned on in both projects.


P
Peter Mortensen

I was facing the same issue and trying to launch a React Native app on an M1 Mac. Note that my Intel Mac with the same project worked well without this error.

What solved the problem for me was to force Xcode to open through Rosetta.

To achieve this:

Right click on Xcode in Applications folder* → Get Info → check 'Open using Rosetta' checkbox.


This worked for me
duplicate to 8HP8 answer
v
vidalbenjoe

I was also experiencing the same issue with specific library that was installed through carthage. For those who are using Carthage, as Carthage doesn't work out of the box with Xcode 12, this document will guide through a workaround that works for most cases. Well, shortly, Carthage builds fat frameworks, which means that the framework contains binaries for all supported architectures. Until Apple Sillicon was introduced it all worked just fine, but now there is a conflict as there are duplicate architectures (arm64 for devices and arm64 for simulator). This means that Carthage cannot link architecture specific frameworks to a single fat framework.

You can follow the instruction here. Carthage XCODE 12

https://i.stack.imgur.com/3aozP.png

Try to run your project using simulator. Simulator should run without any errors.


Y
YazanGhafir

Please, don't forget to clean the build folder after you add arm64 to excluded architecture.


How? By some menu command? By manually deleting files or folders? Can you elaborate? Please respond by editing (changing) your answer, not here in comments (without "Edit:", "Update:", or similar - the answer should appear as if it was written today).
P
Peter Mortensen

In your xxx.framework podspec file, add the following configuration. Avoid a pod package that contains arm64 simulator architectures.

s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }

It worked! However this means that the Pod cannot be used in Apple Silicon based Macs?
Is it confirmed @tomacco?
@FernandoReynoso I have just received an Developer Transition Kit, (ARM MacMini) will test and report later today
@tomacco Have you been able to test it?
If multiple pod specs use user_target_xcconfig and the values don't match exactly, CocoaPods will emit warnings like this [!] Can't merge user_target_xcconfig for pod targets: [... list of pods ...]. Singular build setting EXCLUDED_ARCHS[sdk=<...>] has different values. The podspec syntax reference says this attribute is "not recommended" guides.cocoapods.org/syntax/podspec.html#user_target_xcconfig. So please don't use user_target_xcconfig for this to save many developers the trouble.
r
rexsheng

Xcode 13.2.1, Monterey, target iOS 14.0, cocoapod 1.11.2

I had a similar issue when including LogRocket and/or Plaid -- they are xcframeworks, works fine on my local but can't be built on bitrise, I'd tried all answers above:

EXCLUDED_ARCHS arm64

setting ONLY_ACTIVE_ARCH to YES in Podfile

VALIDATE_WORKSPACE to YES

setting ARCHS[sdk=iphonesimulator*] to uname -m in Podfile

none of them works

but by specifying target iOS version or delete it would work:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
      # OR
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
    end
  end
end

Do you know how can we do the same but for SPM?
H
Hassan

Go to finder -> Applications -> Xcode -> Right click on Xcode -> Select open using rosetta

https://i.stack.imgur.com/Zd4se.png


While this will allow you to build your project is definitely NOT advisable. You will be running Xcode in an x86 emulated environment. This will likely be much slower and not take advantage of your M1 processor.
S
Sunil Targe

Updates: Oct 2020

You can simply set arm64 only for Debug > Simulator - iOS 14.O SDK under Excluded Architecture.

https://i.stack.imgur.com/w9iig.png


Are you sure? Doesn't this mean it won't actually run on a machine with Apple Silicon?
On Apple Silicon it will try to build and run with Rosetta if arm64 is excluded
P
Peter Mortensen

The problem here are the Valid architectures in Xcode 11. Open the project in Xcode 11 and change the Valid architectures value to $(ARCHS_STANDARD) for both your project, target and Pods. Reopen the project in Xcode 12 and build.


Thank you for your mention of the pods! in my case, I had to exclude the arm64 architecture from the Pods project for it to work, but thanks for the hint 🙏
P
Peter Mortensen

Issue when compiling for the simulator:

Building for the iOS simulator, but linking in an object file built for iOS, for architecture arm64

Xcode 12.1, Pod 1.9.1

My project structure

Main Target

Share Extension

Notification service extension

Submodule, Custom Framework

Podfile

Add arm64 to Build settings -> Exclude Architecture in all the targets. Removed arm64 from VALID_ARCHS and added x86_64 in all the targets. Add following code in podfile post_install do |installer| installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" end end Did pod update, deleted podfile.lock, and did pod install Do a clean build.


What is "Pod"? CocoaPods?
Yes Pod means Cocoapods