realm-swift: Can't run project with RealmSwift in iOS simulator after building with Xcode 12 (after beta 3)
Goals
My goal is to run the app in simulator (preferably iOS 14 one) to be prepared for future iOS and Xcode updates. Something’s seem broken in the mapping of arm64 to x86_64 when new build system of Xcode 12 is used.
Expected Results
Application runs in simulator.
Actual Results
Since Xcode 12 beta 3 I can no longer build my project anymore. There are few scenarios:
- When the app was first build with Xcode 11.6 and the build folder wasn’t cleaned prior building with Xcode 12 beta 3 build segfaults compiling the classes with RealmSwift imports.
Example error:
AddressGeorecord.swift:10:8: error: could not find module 'RealmSwift' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, x86_64 import RealmSwift(all the long stack dump is omitted for brevity). - When the build folder is cleaned and derived data removed Xcode 12 beta 3 won’t build at all showing
No such module 'RealmSwift'on imports in classes importing Realm. - When the build folder is cleaned and derived data removed beforehand and then RealmSwift pod scheme built for any of iOS 14 simulators trying to build and run the app afterwards fails with segfault and the same error
could not find module 'RealmSwift' for target 'arm64-apple-ios-simulator'. - Excluding x86_64 in Pods project Build settings
> Excluded Architectures and/or explicitly setting> Architectures helps to build the project. But it can’t be run in simulator with the following message:armv7 armv7s arm64 arm64e i386in Pods project Build settings[Project name] architectures (arm64) include none that iPhone SE (1st generation) can execute (Intel 64-bit).(For whatever simulator is selected).
Steps for others to Reproduce
See ‘Actual results’ section above.
Code Sample
None.
Version of Realm and Tooling
ProductName: Mac OS X
ProductVersion: 10.15.5
BuildVersion: 19F101
/Applications/Xcode-beta.app/Contents/Developer
Xcode 12.0
Build version 12A8169g
/Users/illabo/.rbenv/shims/pod
1.9.3
Realm (5.3.3)
RealmSwift (5.3.3)
/bin/bash
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)
carthage not found
(not in use here)
/usr/local/bin/git
git version 2.24.1
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 18
- Comments: 29 (5 by maintainers)
Commits related to this issue
- https://github.com/realm/realm-cocoa/issues/6685 — committed to oinariman/realm-cocoa by oinariman 3 years ago
Here is how I got rid of the problem, I bet this can not be termed as long term solution but the interesting thing is : Xcode 11 had
Valid Architecture(VALID_ARCHS)while Xcode 12 has Excluded Architectures (EXCLUDED_ARCHS). So if you open the project in xcode12 then if you check-in build settings you will found thatVALID_ARCHSis now moved toUser-Defined. So a quick solution will simply delete the entry ofVALID_ARCHSfromUser-Defined. And this time it should work. I am also looking for a more permanent kind of solution as this solution will break every time we perform pod install or pod updates. So somewhere I found this post pod installation change but I have not tried that yet. ref: https://developer.apple.com/forums/thread/656509Please try and let me know if it helps
As Xcode 12 is GM seed now and release is expected in hours perspective it seem the right time to revive the topic.
Cocoapods 1.10 (at least rc 1) doesn’t remedy this issue no matter Pods Project Base SDK and/or Supported Platform is set to macOS or iOS, Build Active Architectures Only is set to Yes for debug or to No, i386 is in Excluded Architectures or it isn’t. What steps one should take to try mitigate such an issue? BTW: tried building older project with Realm 3.17.3 and it runs in iOS 14 simulator without any problem.
Xcode 12 is not beta anymore, its oficial release and the problem persists. its not compiling anymore.
@tgoyne Sorry to say, but it isn’t a solution. Whenever the project is attempted to be built for debug in simulator (main project and Pods targets architectures are set to ARCHS_STANDARD) excluding arm64 and i386 architectures it can’t be linked as there aren’t anything actually built:
And I’m trying with no success to run the project on old simulators (10.3.1—13.6) not only 14.0, seems Xcode 12 treat them as arm64 simulators too for some reason. E.g. it is an error I’m getting trying to run on iOS 12.1 (when arm64 isn’t excluded):
could not find module 'RealmSwift' for target 'arm64-apple-ios-simulator'. Please check the last two bullets in “Actual Results” section in original issue. This mutually exceptional messages (saying a simulator could run x86 binary but Xcode can’t find arm64 module) are present only when the project imports Realm. It is the reason to file this issue and not just wait for release of production ready Xcode 12.Build Active Architecture Only: Yesnot helping also on my Intel Mac whether I exclude arm64 from build archs or not. I can understand this happens because of Apple tweaked the build system, but it is a coming reality to deal with. Unfortunately it seems the time for new ‘hack’ to force-feed simulator with the correct binary and resolve this contradiction. For now I can perfectly fall back to building with Xcode 11, but I have some worries regarding upcoming releases.Not sure if this is happening for everyone, but for us this is becoming an increasingly time-sensitive situation — iOS 14 is coming out very soon, and we’re not able to compile our app on simulators at all right now due to this issue.
Is the realm team looking into this issue or aware of what may be causing this? cc @tgoyne
In my case applying this as is broke several other Pods, but was otherwise helpful when just restricted to Realm Pods:
When using CocoaPods you will also need to set EXCLUDED_ARCHS on the Pods project.
Supporting the arm simulators requires cocoapods 1.10, which currently is in beta. If they don’t make a non-beta release before Xcode 12 leaves beta then I guess we’ll just bump the minimum req to that anyway, but we’d prefer not to require everyone working on things being released now to use a beta version.
We do not support the new arm64 simulators yet as they break the old “universal” simulator/device libraries hack. Currently you’ll need to exclude arm64 from the simulator architectures:
Build Active Architecture Only: Yesshould also sidestep this unless you’re running on an ARM DTK, as that’s the only place the arm64 simulator is actually used.For SwiftPM, use Realm version 10.5.0.
Anyone has this issue right now?
Every time I tried ‘pod lib lint’ and this is always the error
~/Pods/Realm/core/librealmcore-ios.a(bptree.o), building for iOS Simulator, but linking in object file built for iOS, for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)The following build commands failed: Ld /Users/~/Library/Developer/Xcode/DerivedData/App-bcahkoasabrxnhbthdoimxoxletm/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/Realm.build/Objects-normal/arm64/Binary/Realm normal arm64 (1 failure)And yet I still cannot pass pod lib lint
Xcode: 12.2 Pod: 1.10.0 Realm: 3.21.0 RealmSwift: 3.21.0
@tgoyne we’re seeing a very similar issue. We’re not attempting to use
RealmSwiftat all, justrealm-cocoa. Tried excludingarm64to no avail:The error is:
Builds properly on a real device, just not on the simulator. Laptop has processor
2.9 GHz 6-Core Intel Core i9runningCatalina 10.15.6 (19G73). Let me know if there’s any additional info about our build settings, Podfile, hardware etc. that would be helpful in debugging.I have an MacBook Air M1, What do you suggest if I include Realm using Swift Package Manager?
BUILD Settings -> VALID_ARCHS. add “X86_64” on your project (Prolly you might have arm* series. put it with them to work)I tried this too and it worked great
The latest Realm version 10.4.0 has fixed the
arm64-apple-ios-simulatorcompiler issue for me. My workaround in #6968 should no longer be necessary.Update: The following workaround is no longer required in Realm version 10.4.0
I’ve encountered the same issue in #6968. The Realm project excludes the
arm64architecture when building for the iOS simulator. Please change the following line in your Realm project https://github.com/realm/realm-cocoa/blob/af4b201bb955736f250f5af1c1b6bc335a43c385/Configuration/Base.xcconfig#L65 toREALM_ARM_ARCHS_1200 = ;and build again withsh build.sh xcframework iosHi @danielrobleM, yes I`ve resolved the issue. In my case the following steps works:
@umang-simform Thank you! The Podfile snippet seems to help in our case.