realm-swift
realm-swift copied to clipboard
Error in linking phase when using Realm as SPM dependency for sub-target
How frequently does the bug occur?
All the time
Description
Actual result:
- Try to archive project with a sub-target that has realm-cocoa as SPM dependency.
- Get errors as described here (#7526)
- Apply proposed fix to realm-core
- Receive another linking error
Expected result: Archive process succeeds
Stacktrace & log output
Undefined symbols for architecture arm64
Symbol: realm::ObjKey realm::Table::find_first<realm::StringData>(realm::ColKey, realm::StringData) const
Referenced from: realm::ObjKey realm::Object::get_for_primary_key_in_migration<objc_object* __strong, RLMAccessorContext>(RLMAccessorContext&, realm::Table const&, realm::Property const&, objc_object* __strong&&) in RLMAccessor.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Can you reproduce the bug?
Yes, always
Reproduction Steps
In description
Version
v10.22.0
What SDK flavour are you using?
Local Database only
Are you using encryption?
No, not using encryption
Platform OS and version(s)
Any iOS Device (arm64)
Build environment
Xcode version: 13.2 Dependency manager and version: SPM
Hi @aleyooop , I see the pull request in realm-core for that case. I'll ask core team to check it out
@aleyooop I try to reproduce it locally without any luck. Can you share some details on what library you are using in your project? Could you try to clear derived data and/or reset package cache?
@pavel-ship-it This can be easily reproduced with the same reference project in this related issue (#7526)
- Build project and get issue with Security framework
- Change Realm swift package dependency with fork+applied fixes -> Build fixed
- Try to archive
Derived data cleaning and/or resetting package cache don't help.
Same issue with missing symbols
It seems like linking a sub-dependency is not possible with the current configuration of the Sample project provided. You need to add them as Package.swift modules so it links correctly any sub-dependency (In this case is RealmCore). I updated the Sample project which I used to test archiving the App, and it is working. The missing Security framework should be fixed by this PR. Let me know if you have any question.
Hi,
Same issues here.
I have some internal framework which is dependent to Realm. I added Realm and RealmSwift from SPM. No issues on building but have an error on archive side.
Undefined symbols for architecture arm64: "realm::ObjKey realm::Table::find_firstrealm::StringData(realm::ColKey, realm::StringData) const", referenced from: realm::ObjKey realm::Object::get_for_primary_key_in_migration<objc_object* __strong, RLMAccessorContext>(RLMAccessorContext&, realm::Table const&, realm::Property const&, objc_object* __strong&&) in RLMAccessor.o ld: symbol(s) not found for architecture arm64
Hello, we are also having the same issue.
@emrekarasahin You can apply the changes found in PR5204 in realm-core to SourcePackages/checkouts/realm-core/src/realm/table.cpp
(located in your DerivedData folder for your project) as a work around until that PR is merged.
Hello, is there any update in this?
Any suggestions?