Realm XCFramework nested in another XCFramework error

I’m trying to use a XCFramework built with a private pod, that have another public dependencies inside. In that dependencies, all of them seem to work fine, except RealmSwift. When I try to import the XCFramework I built in my class, the following errors appear:

  • ‘RealmSwiftObject’ is not a member type of struct ‘RealmSwift.Realm’
  • ‘RealmSwiftObject’ is not a member type of struct ‘RealmSwift.Realm’
  • ‘RealmSwiftObject’ is not a member type of struct ‘RealmSwift.Realm’
  • Type ‘Element’ does not conform to protocol ‘RealmCollectionValue’
  • ‘RealmSwiftObject’ is not a member type of struct ‘RealmSwift.Realm’
  • ‘RealmSwiftObject’ is not a member type of struct ‘RealmSwift.Realm’
  • ‘RealmSwiftObject’ is not a member type of struct ‘RealmSwift.Realm’
  • ‘RealmSwiftObject’ is not a member type of struct ‘RealmSwift.Realm’

I have been searching but I don’t know why this error is showing because it doesn’t seem like it has anything related to my problem, but I ran out of ideas.

I have tried install Realm both by Cocoapods and XCFramework. Same result

1 Like

I had the same issue, and I came across this formum post
https://developer.apple.com/forums/thread/123253

There’s Realm framework and also there’s Realm class in RealmSwift framework, this confuses the linker. According to the post, I added the script at the bottom of Run Script section in Build Phases in building xcframework script:

find [Path to .xcframework] -name “*.swiftinterface” -exec sed -i -e ‘s/Realm.RealmSwiftObject/RealmSwiftObject/g’ {} ;