realm-swift: Error in linking phase when migrating from Cocoapods to Swift Package Manager
Expected results
Migrate from Cocoapods to Swift Package manager and build my project.
Actual Results
Error during linking phase while building RealmCore
Steps & Code to Reproduce
Getting this error when trying to build after deintegrating pods and adding Realm to the project via SPM:
Undefined symbols for architecture x86_64:
"_SecTrustSetAnchorCertificates", referenced from:
realm::util::network::ssl::Stream::verify_peer() in RealmCore.o
"_SSLWrite", referenced from:
realm::util::network::ssl::Stream::do_ssl_write(char const*, unsigned long) in RealmCore.o
"_SecTrustEvaluate", referenced from:
realm::util::network::ssl::Stream::verify_peer() in RealmCore.o
"_SecTrustGetCertificateCount", referenced from:
realm::util::network::ssl::Stream::verify_peer() in RealmCore.o
"_SecTrustGetCertificateAtIndex", referenced from:
realm::util::network::ssl::Stream::verify_peer() in RealmCore.o
"_SSLCopyPeerTrust", referenced from:
realm::util::network::ssl::Stream::verify_peer() in RealmCore.o
"_SSLHandshake", referenced from:
realm::util::network::ssl::Stream::do_ssl_handshake() in RealmCore.o
"_SSLClose", referenced from:
realm::util::network::ssl::Stream::do_ssl_handshake() in RealmCore.o
realm::util::network::ssl::Stream::do_ssl_shutdown() in RealmCore.o
"_SSLSetPeerDomainName", referenced from:
realm::util::network::ssl::Stream::ssl_set_host_name(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::error_code&) in RealmCore.o
"_SSLRead", referenced from:
realm::util::network::ssl::Stream::do_ssl_read(char*, unsigned long) in RealmCore.o
"___llvm_profile_runtime", referenced from:
___llvm_profile_runtime_user in RealmCore.o
___llvm_profile_runtime_user in Bid.o
"_SecCertificateCreateWithData", referenced from:
realm::util::network::ssl::Context::load_pem_file(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::nullptr_t, std::__1::error_code&) in RealmCore.o
"_SSLSetIOFuncs", referenced from:
realm::util::network::ssl::Stream::ssl_init() in RealmCore.o
"_SSLCreateContext", referenced from:
realm::util::network::ssl::Stream::ssl_init() in RealmCore.o
"_SSLSetSessionOption", referenced from:
realm::util::network::ssl::Stream::ssl_init() in RealmCore.o
"_kSecAttrAccessibleAfterFirstUnlock", referenced from:
realm::keychain::(anonymous namespace)::set_key(std::__1::vector<char, std::__1::allocator<char> > const&, __CFString const*, __CFString const*) in RealmCore.o
"_kSecAttrService", referenced from:
realm::keychain::(anonymous namespace)::build_search_dictionary(__CFString const*, __CFString const*, realm::util::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >) in RealmCore.o
"_SecTrustSetAnchorCertificatesOnly", referenced from:
realm::util::network::ssl::Stream::verify_peer() in RealmCore.o
"_kSecClassGenericPassword", referenced from:
realm::keychain::(anonymous namespace)::build_search_dictionary(__CFString const*, __CFString const*, realm::util::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >) in RealmCore.o
"_kSecValueData", referenced from:
realm::keychain::(anonymous namespace)::set_key(std::__1::vector<char, std::__1::allocator<char> > const&, __CFString const*, __CFString const*) in RealmCore.o
"_kSecAttrAccount", referenced from:
realm::keychain::(anonymous namespace)::build_search_dictionary(__CFString const*, __CFString const*, realm::util::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >) in RealmCore.o
"_kSecReturnData", referenced from:
realm::keychain::(anonymous namespace)::build_search_dictionary(__CFString const*, __CFString const*, realm::util::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >) in RealmCore.o
"_SecCertificateCopyData", referenced from:
realm::util::network::ssl::Context::ssl_use_verify_file(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::error_code&) in RealmCore.o
realm::util::network::ssl::Stream::verify_peer() in RealmCore.o
"_SecItemCopyMatching", referenced from:
realm::keychain::(anonymous namespace)::get_key(__CFString const*, __CFString const*) in RealmCore.o
"_SecCopyErrorMessageString", referenced from:
realm::util::network::SecureTransportErrorCategory::message(int) const in RealmCore.o
"_kSecAttrAccessible", referenced from:
realm::keychain::(anonymous namespace)::set_key(std::__1::vector<char, std::__1::allocator<char> > const&, __CFString const*, __CFString const*) in RealmCore.o
"_kSecClass", referenced from:
realm::keychain::(anonymous namespace)::build_search_dictionary(__CFString const*, __CFString const*, realm::util::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >) in RealmCore.o
"_SSLSetConnection", referenced from:
realm::util::network::ssl::Stream::ssl_init() in RealmCore.o
"_SecTrustEvaluateWithError", referenced from:
realm::util::network::ssl::Stream::verify_peer() in RealmCore.o
"_SecItemAdd", referenced from:
realm::keychain::(anonymous namespace)::set_key(std::__1::vector<char, std::__1::allocator<char> > const&, __CFString const*, __CFString const*) in RealmCore.o
"_SSLGetSessionState", referenced from:
realm::util::network::ssl::Stream::ssl_read(char*, unsigned long, std::__1::error_code&, realm::util::network::Service::Want&) in RealmCore.o
realm::util::network::ssl::Stream::do_ssl_shutdown() in RealmCore.o
"_SSLSetProtocolVersionMin", referenced from:
realm::util::network::ssl::Stream::ssl_init() in RealmCore.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Same error appears for building on device but for arm, The Apple Security framework is present in the project that we are trying to build. The workspace has multiple modules, one of which is able to build without this failure while all the others that are included in the workspace fail at the linking phase.
Core version
Core version: 10.17.0
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (4 by maintainers)
HI @chunyang-wen Seems like the Security framework is not been linked if we have different modules sharing the same dependency. I tested forcing this on the Package.swift file on Realm Core and seems like it is working. I added a PR to fix on Core, you can follow this here (https://github.com/realm/realm-core/pull/5111)
Fixed by this https://github.com/realm/realm-core/pull/5254
@spenceralderson i’ll try that one today and get back with my results.