3

I'm using the Firebase and the SDWebImageSwiftUI module in my SwiftUI 2 app with Xcode 12.3 and Cocoapod 1.10.0 on my Apple M1 MacBook Pro.

As long as I don't integrate the Firebase Analytics module via Cocoapod the app works fine but when I integrate it, I get the same error as the guy here: Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64. His solution also works for me (exclude arm64 architecture for the project and pods).

However now the SDWebImageSwiftUI module (included via swift package manager) is complaining "Could not find module 'SDWebImageSwiftUI' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator". If I include the module via Cocoapod then the compiler says "No such module "SDWebImageSwiftUI".

Does anyone of you has an idea on what I could do?

Any help is much appreciated

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
FriendlyGuy
  • 331
  • 5
  • 14
  • It looks like the `pod` is using a workaround that references a Silicon specific version https://github.com/firebase/firebase-ios-sdk/blob/master/AppleSilicon.md . If you want to do it without the `pod` you have to compensate for that. https://firebase.google.com/docs/ios/setup – lorem ipsum Dec 31 '20 at 14:53

5 Answers5

3

Edit March 2023 - Since Firebase 7.5.0, Firebase supports the M1 processor by default. No special instructions are needed.

When specifying which version of Firebase you'd like in your Podfile, append -M1 to the version. See the following examples:

Explicitly require the special M1 tagged Firebase version, locked to the exact version. Note that due to the version scheme, you're required to update this manually for each release otherwise you will revert to the official release (ex. 7.2.0 instead of 7.2.0-M1).

pod 'Firebase/Analytics', '7.2-M1'

Do the same for any other Firebase pod used.

pod 'Firebase/Database', '7.2-M1'

Remember: now you need to manually add -ObjC to avoid a runtime crash. This CocoaPods issue has been fixed in CocoaPods/CocoaPods#10234 and is merged for the upcoming CocoaPods 1.10.1 patch release.

Paul Beusterien
  • 27,542
  • 6
  • 83
  • 139
  • Great, that lets me compile the app again but now if I use any of the analytics logging functions like e.g. Analytics.logEvent("Dashboard clicked", parameters: nil), I get the error "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Swift.__SharedStringStorage apm_UTF32Length]: unrecognized selector sent to instance 0x6000030c4150'" – FriendlyGuy Jan 02 '21 at 14:51
  • See the full set of instructions about adding the `-ObjC` option to the Other Linker Flags in Build Settings to work around a CocoaPods bug for which the bugfix is coming in the 1.10.1 release. – Paul Beusterien Jan 02 '21 at 15:33
  • I followed the instructions on GitHub and used the swift package manager also for the Firebase module so that problem should actually not occur as I'm not using Cocoapods anymore. Do you have any idea what else could be the problem with that? – FriendlyGuy Jan 03 '21 at 15:35
  • 1
    For both CocoaPods and Swift PM, FirebaseAnalytics `-ObjC` needs to be added to the linker options – Paul Beusterien Jan 03 '21 at 21:55
  • https://github.com/firebase/firebase-ios-sdk/blob/master/AppleSilicon.md 404 – Max Base Mar 12 '23 at 21:24
2

Checking the option "Open with Rosetta" (as in the screenshot below) helped me to solve this problem. After the error disappears, you can switch back and open Xcode without Rosetta.

Property dialog for Xcode with "Open with Rosetta" checked

legoscia
  • 39,593
  • 22
  • 116
  • 167
1

You no longer need to append M1 according to the updates from Firebase. You may check it on the link for further instructions.

Starting with Firebase 7.5.0, Firebase supports Apple Silicon Macs via CocoaPods. CocoaPods 1.10.0 is required.

The special M1 versions required for FirebaseAnalytics support for versions 7.2.0 through 7.4.0 are no longer necessary.

https://github.com/firebase/firebase-ios-sdk/blob/master/AppleSilicon.md

Kelvin Tan
  • 327
  • 3
  • 15
1

Try this: In your root sudo arch -x86_64 gem install ffi cd to your project folder and arch -x86_64 pod install

0

Please take a look at this. https://stackoverflow.com/a/68037246/4862289

Go to Application folder -> Right click on Terminal App -> Get Info

Tick Open with Rosetta option.

try pod install now.

Rahul R
  • 184
  • 1
  • 7