Setup
iOS, xCode 13, Realm 10.20
MainProject integrates two swift packages using Swift Package Manager: LayerPersistence and LayerNetwork.
LayerPersistence packages has a dependency on
- Realm
LayerNetwork packages has a dependency on
- Alamofire
MainProject builds and runs without issues. Tests for MainProject do not build. Generates the following:
Error: Missing required modules: 'Realm.Private', 'Realm'
When I exclude LayerPersistence from the MainProject -> Tests run with no issues.
What I tried and it didn't work
I have tried to manually map the module with: -fmodule-map-file=.....some path to file.....Realm.modulemap
but without success.
I have tried to include Realm manually in link binary with libraries of the test targets.
What works
Downgrading to Realm Version 5.5.2 in the LayerPersistence and manually linking Realm to all tests targets of the MainProject via
Build Phases -> Link Binary With Libraries
does the trick, but keeps me out of new Realm Versions.
Objective
To have the most recent version of Realm in the package integrated via SPM and still be able to run test in the MainProject
Note:
Tests in LayerPersistence and LayerNetwork run without issues.
There are some solutions in Internet but they do not resolve issues with the newer versions of Realm:
https://github.com/apple/swift-nio/issues/1128
https://github.com/realm/realm-swift/issues/6301
"Missing required module 'XYZ'" on Unit Tests when using Swift Package Manager