7

Seems that after updating Xcode 12 to beta 5, SwiftUI previews are not working anymore when using Firebase/Analytics pod. Previews are failing with error:

linker command failed with exit code 1 (use -v to see invocation)

----------------------------------------

SchemeBuildError: Failed to build the scheme "Boo"

linker command failed with exit code 1 (use -v to see invocation)


Link Boo (arm64):
ld: in /Users/../Boo/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector(FIRAnalyticsConnector_e321ed8e3db06efc9803f6c008e67a34.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/.../Boo/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any suggestions how to fix this?

sash
  • 8,423
  • 5
  • 63
  • 74

5 Answers5

16

To exclude the arm64 architecture only when running on a simulator, add the "Any iOS Simulator SDK" qualifier in the build settings. Then you won't have to remove this setting when testing on a physical device.

enter image description here

To add the qualifier, click on the little plus button, as shown.

enter image description here

trishcode
  • 3,299
  • 1
  • 18
  • 25
  • 2
    This should be the accepted answer! You don't have to deal with adding and removing the flag when switching from simulator to device – Rico Crescenzio Sep 04 '20 at 15:48
  • 2
    Important to say, that you have to clean build and remove derived data after setting this parameter. Thanks for ur answer. – Vlad Pulichev Sep 17 '20 at 19:36
  • 1
    This is great advice and worked for me as well, especially the carful application only to iOS simulators... I wonder what happens to a dev on Apple Silicon Macs? – Kendall Helmstetter Gelner Sep 24 '20 at 03:07
6

The following workaround (credit to user on Apple Developer forums) worked for me:

Add "arm64" to the excluded architectures for the debug scheme for any targets that have Firebase Analytics.

This will cause you problems if you need to debug to an actual iOS device, obviously. But you can remove it when you need to test on a device.

Mike Dattolo
  • 139
  • 2
3

How to Add arm64 as an Excluded Architecture

The accepted answer also worked for me. But I didn't know how to do this as I have never done it before so I wanted to show you the steps I took to accomplish this.

Build Settings

  1. Select your project in the Project Navigator
  2. Select your project in the Project Settings
  3. At the top, select "Build Settings"
  4. Then select "All" to show all build settings
  5. At the top, you will see a section called "Architecture". In this section is "Excluded Architectures". You want to expand this. And then next to Debug, double-click, and type in "arm64".
Mark Moeykens
  • 15,915
  • 6
  • 63
  • 62
1

Add this check at start of didFinishLaunchingWithOptions and preview mod will ignoring external modules

if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" {
    return true
}
X1opya
  • 21
  • 3
0

Xcode 12, beta 6

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.

My Architectures build setting is Standard Architectures.

trishcode
  • 3,299
  • 1
  • 18
  • 25