8

My project has Swift Package Dependencies by third parties. I need to change the EXCLUDED_ARCHS build setting on a handful of these.

Is there a way to do this? And if so, is there a way to do this in the Xcode UI?

enter image description here

Ethan Allen
  • 14,425
  • 24
  • 101
  • 194
  • I'm not sure if this answers your question, but SPM doesn't use any project files to build the dependency but rather the `Package.swift` file which you can find by expanding any of the dependencies in the list above. But perhaps you can share more info about what you're trying to accomplish. I don't think you can play with excluded architectures in packages. I sense your problem lies somewhere else. – Jacob Nov 19 '20 at 02:59
  • 6
    @Kubee I have a new M1 Mac and the packages I use can only build to x86 Simulator currently (until the authors update them). If I do `EXCLUDED_ARCHS=arm64` for All Simulators then I can get it to build. But I can only set that setting with my Pod dependancies (because I can modify the Target Build Settings for any library), not SPM. – Ethan Allen Nov 19 '20 at 03:02
  • I don't have an m1 myself. So I'm not the best source...just spitballing here. Are you sure you're not doing it backwards? The m1 uses an arm64 based processor and you technically should enable it for your MacBook. I just don't know if rosetta 2 works with the simulator. When people switched to Xcode 12 they responded to the fact that CocoaPods and Carthage could not build for arm64 anymore by disabling support for arm64. I think they shot themselves in the foot. They should have worked to get rid of cocoa pods and Carthage instead. I think that's your problem. But I'm not sure. – Jacob Nov 19 '20 at 06:42
  • Try making a simple project with just an SPM package. Alamofire for example (make sure you import it somewhere too) and see if you can build. I'm actually personally curious...since I don't have an M1 yet. – Jacob Nov 19 '20 at 06:45
  • It looks like the problem was actually being caused by my Pods conflicting. As soon as I removed all of my Pods, the SPM stuff built just fine. I completely removed the Pods using https://stackoverflow.com/questions/16427421/how-to-remove-cocoapods-from-a-project then re-added it as if it were a new project one by one. Sure enough, things are working fine. Must have been some odd build settings in my Pods. – Ethan Allen Nov 19 '20 at 07:05
  • Oh, I'm glad you figured it out. Are you still excluding arm64 in your pods and for the simulator? – Jacob Nov 19 '20 at 07:10
  • Nope. Not excluding arm64. – Ethan Allen Nov 19 '20 at 07:17
  • This post really helped me. We moved from Pods to SPM. When we were using Pods we had set up excluded arch: arm64 which is a problem in SPM land for M1 without rosetta. Removing all excluded arch stuff did the trick. Now compiling a large project on M1/M1 max without rosetta. – VaporwareWolf Oct 27 '21 at 20:31
  • @VaporwareWolf How were you able to exclude architecture for SPM packages, is there a way to do it in their package.swift ? – Badrinath Jun 12 '22 at 22:57
  • @EthanAllen did you add them back as pods or spm? – fangmobile Jun 17 '22 at 19:15
  • @Badrinath No easy way to do that in Package.swift. I excluded in app -> build settings -> architecture -> excluded architectures, then added 'Any iOS' and added the excluded architecture. For the pod targets, we had a snippet at the end of Podfile which applied that same setting to each pod target. This has all been reverted now though as it was what was causing our issues. – VaporwareWolf Jun 23 '22 at 01:24

0 Answers0