Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift Package Manager Static Library problem

I have added Realm and RealmSwift libraries in my iOS project. My app was fine till 2 days back. Suddenly it started giving following error.

Error:Swift package target 'Realm' is linked as a static library by 'Project' and 'Realm', but cannot be built dynamically because there is a package product with the same name.

I don't find any static libraries in my app. I tried deleting library from Project->Package Dependencies. But XCode is throwing below compiler Error Missing required modules: 'Realm.Private', 'Realm', 'Realm.Swift'

like image 259
Hari Keerthipati Avatar asked Mar 09 '26 21:03

Hari Keerthipati


2 Answers

This is likely due to a recent change in the Realm SDK and install setup.

Please review the Install & Setup Guide.

If you use Cocoapods, be sure your podfile matches the docs and adjust the iOS/macOS version accordingly.

platform :ios, '12.0'  //or for macOS use platform :osx, '13.0'
target 'MyDeviceSDKProject' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  # Pods for MyDeviceSDKProject
  pod 'RealmSwift', '~>10'
end

If using SPM, be sure to note the info the Dynamic Framework Section

To use the Privacy Manifest supplied by the SDK, build RealmSwift as a dynamic framework.

and be sure you're only adding one package

Changed in version 10.49.3: Instead of adding both, only add one package.

Select either RealmSwift or Realm, then click Add Package.

like image 187
Jay Avatar answered Mar 12 '26 12:03

Jay


For anyone else, as linked to by others, the Install Guide says to link to either Realm or RealmSwift (not too obvious).

In my case, using SPM, I had to link my target to RealmSwift only.

like image 28
VoodooBoot Avatar answered Mar 12 '26 12:03

VoodooBoot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!