realm-swift
realm-swift copied to clipboard
dyld: missing symbol called in custom XCFramework with pod dependency
How frequently does the bug occur?
All the time
Description
Hi,
I'm trying package a custom xcframework with the RealmSwift pod dependency.
After upgrading to the latest version (10.32.0
), when I import my xcframework into a test app, I'm getting the following error :
dyld[6505]: missing symbol called
And it point that method :
Any ideas on how to fix that?
Can you reproduce the bug?
Yes, always
Version
10.32.0
What SDK flavour are you using?
Local Database only
Are you using encryption?
No, not using encryption
Platform OS and version(s)
iOS 15.5
Build environment
Xcode version: 14.0.1 Dependency manager and version: Cocoapods 1.11.3
I have exactly the same issue with version 10.32.3. The last working RealmSwift version for me was the 10.17.0 but it looks like no compatible with xCode 14 for the watch-os target. Is there any update on this?
Hi @MikePetitfils Can you send us a reproduction app so that we can investigate further?
I has the same issue and was able to determine that it's broken in the 10.21.0
, while 10.20.1
works fine. However to run 10.21.0
#7672 fix should be applied manually.
Unfortunately, I'm not able to reproduce the issue on a sample project.
Well finally I was able to build an example, here are steps to reproduce:
- Switch to the branch
7989-repro
in my fork - Navigate to the
examples/installation/ios/swift/CocoaPodsExample
- Run
./XCF/build.sh
script - Open the
CocoaPodsExample.xcworkspace
and run the app on a Simulator - Observe the app is crashing with
missing symbol called
error - Change version of
RealmSwift
pod inexamples/installation/ios/swift/CocoaPodsExample/XCF/XCF.podspec:21
to10.20.1
- Rerun the script and the app
- Observe the app is not crashing
@leemaguire any update for the example and steps I've provided?
Hi @evnik I'm taking a look at this, and I'm able to reproduce. I also found out that the version that introduces the issue is 10.21.0
. Now I have to check which commit causes the issue.
We've encountered the same issue. Would anyone happen to have a workaround for this problem?
We've encountered the same issue. Would anyone happen to have a workaround for this problem?
I can only say that in the custom framework I had this code and it was crashing, even if I replaced the filter with the where:
public static func getById(_ itemId: String, detached: Bool = true) -> MyObject? { let result = dbRealm.objects(MyObject.self).where { $0.itemId == itemId }.first return detached ? result?.detached() : result }
I have updated the code like this and I do not have the crash anymore:
public static func getById(_ itemId: String, detached: Bool = true) -> MyObject? { let results = dbRealm.objects(MyObject.self).where { $0.itemId == itemId } if results.isEmpty { return nil } return detached ? results[0].detached() : results[0] }
This does not make much sense to me because the code is really the same. But accessing the results array using the index instead of the first solved the issues for me. The attached() method is an utility extension I made to have a reference to the database object that I can modify as I want that does not affect the database.
same issue here
Facing similar issue with one of our library that uses realm which is integrated as part of a native module for a React Native project. Will hit this missing symbol error on first launch of the app but subsequent launches are surprisingly fine.
Hi, I am facing the same issue when I use RealmSwift latest version 10.44.0 as a pod dependency in my custom XCFramework. For me the old version 10.19.0 only works. By going through all the messages It seems that this issue introduced in 10.21.0 onwards. Any idea how this could be resolved?
I'm facing the same issue with my library packed and distributed via cocoapods as xcframework and Realm & RealmSwift installed as dependencies.
Build environment: Xcode: 15.2 iOS: 17.2 Realm: 1.47.0 RealmSwift: 1.47.0 Cocoapods: 1.14.3
I tried to set BUILD_LIBRARY_FOR_DISTRIBUTION
to NO
and build xcframework with -allow-internal-distribution
parameter as was suggested in similar issue. Did not help.
@dianaafanador3 Any updates on this? Does anyone have workaround?
I have a similar issue of missing symbol when I run my app using a framework generated by me that depends on Realm (10.46.0 or any recent version).
I found a workaround to make it working that is based on using xcframeworks in modified podspec. So I took the podspecs for Realm and RealmSwift, modified them to depend on xcframeworks published by Realm as releases and put the podspecs in a repo. For the edited podspec I removed the dependency for source files and related stuff, and set
s.source = { :http => 'https://github.com/realm/realm-swift/releases/download/v10.46.0/Carthage.xcframework.zip' } # for both
s.vendored_frameworks = 'core/realm-monorepo.xcframework', 'Realm.xcframework' # for Realm
s.vendored_frameworks = 'RealmSwift.xcframework' # for RealmSwift
You can look at my repo. More can be optimized and I'm sure there are fields that can be removed, but it works at the moment.
Then the custom version must be specified where needed, so for each podspec depending on Realm I use
s.dependency 'RealmSwift', '10.46.0-xcframework'
.
In Podfile remember to add the source
with the url to the specs.
Thanks @themoonlitknight I will try it out. BTW I came across this post https://hackernoon.com/cocoapod-as-xcframework-with-dependencies that explains putting all XCFramework into one zip and distribute by using this
s.vendored_frameworks = 'MyFramework.xcframework', 'Realm.xcframework' , 'RealmSwift.xcframework'
This solution does not require hosting podspecs into a remote repo and edit them.
Hello! Any leads on this? We're also still facing this issue with any version above 10.20.1
.
The top of the stack trace, starting after our call to realm.objects().filter()
is this, if it helps:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 ??? 0x102771a78 ???
1 ??? 0x10535f644 ???
2 dyld 0x202911bb7 abort_with_payload_wrapper_internal + 82
3 dyld 0x202911be9 abort_with_payload + 9
4 dyld_sim 0x10b0570e5 abort_with_payload + 26
5 dyld_sim 0x10b00a0d8 dyld4::halt(char const*, dyld4::StructuredError const*) + 335
6 dyld_sim 0x10b02d354 dyld4::APIs::_dyld_missing_symbol_abort() + 18
@amirpervaizQI Hi, do you currently have any available solutions for this issue?
@HowardCsie this could be the solution https://github.com/realm/realm-swift/issues/8218#issuecomment-1561294076 you can create a XCframework manually and add to your app. The issue seems be to be related to Xcode or linker issue that throws symbols not found. You can also directly download the XCFramework from 'Releases' tab at: https://github.com/realm/realm-swift/releases/download/v10.49.1/Carthage.xcframework.zip