iOS Realm: file does not start with MH_MAGIC[_64], fat file, but missing compatible architecture (have 'x86_64,i386', need 'x86_64'))
Asked Answered
H

3

9

I have updated mac to 11.6 and xcode to 13.0. Realm could not compile so I updated it with carthage to v10.15.1. Now I get this runtime error just after the app launch:

  Library not loaded: @rpath/Realm.framework/Realm
  Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/appname/Build/Products/Debug-iphonesimulator/RealmSwift.framework/RealmSwift
  Reason: tried: '/Users/username/Library/Developer/Xcode/DerivedData/appname/Build/Products/Debug-iphonesimulator/Realm.framework/Realm' (file does not start with MH_MAGIC[_64], file does not start with MH_MAGIC[_64], fat file, but missing compatible architecture (have 'x86_64,i386', need 'x86_64')), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/Realm.framework/Realm' (no such file), '/usr/lib/swift/Realm.framework/Realm' (no such file), '/Users/username/Library/Developer/CoreSimulator/Devices/33E61712-D8A9-4D7E-A260-5C096BE08A82/data/Containers/Bundle/Application/AC700919-F431-446F-8BEF-FF8D8E5F5BF9/appname.a

I guess the key part here is file does not start with MH_MAGIC[_64], but I could not find anything useful about the error.

I tried embedding the library and turning off the embedding, does not affect anything.

Histone answered 22/9, 2021 at 17:15 Comment(6)
Are you sure your XCode is 10.13? That's an older version at this point - in fact, I don't think there was a 10.13; the versions went from 10.1, 10.2, 10.3 and then 11.Soapstone
yeah mistyped it is 13.0Histone
Do you have any kind of virus protection installed, like Avast? Are you using a free developer account? Did you use Cocoapods? Did you download/update/select you developer certificate in XCode?Soapstone
@Soapstone no I do not have antivirus, how could it affect? I am using payed developer account. And I use carthage. Yes I did.Histone
Can you include your cartfile in the question? For testing, I would also suggest trying CocoaPodsSoapstone
Odd, what is the output of lipo -info /Users/username/Library/Developer/Xcode/DerivedData/appname/Build/Products/Debug-iphonesimulator/Realm.framework/Realm?Premedical
M
5
  • Realm has 3 targets configured to be built with Carthage (Realm, Realm iOS Static and RealmSwift)
  • XCode 13 deprecated a setting for building targets in a manually set order which leads the first 2 targets to be built in a non deterministic order (the 3rd one is always last as it depends on the 1st one). The order and the frequency of it changing seems to be random (it might depend on the specific XCode version)
  • When 'Realm' is build before 'Realm iOS Static', the fat framework replaces the one in the xcframework which leads to that error. In the other case, it's the correct one that's built second and overrides the wrong one.
  • I guess the solution (apart from upgrading Realm) would be to remove the target 'Realm iOS Static' from the project but it's not straightforward to do with Carthage except by forking Realm
Maladroit answered 27/10, 2022 at 9:47 Comment(0)
I
0

The latest version of realm is v10.32.0. xcode 14.1 is also out.

You need to update your toolset.

Isauraisbel answered 24/10, 2022 at 9:23 Comment(0)
B
0

The latest upgrade realm version 10.32.0 is compatible with XCode 13.1 and above. If you use the legacy build system, migrate it to the latest one and clean the derivable folder before rebuilding the code. Most of the time derivable keeps track of the older version files and makes conflicts once you update the project tools. Hope this will help

Bank answered 25/10, 2022 at 5:23 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.