SPM dependency problem - "Missing required module"

I have a problem with Swift package dependencies. My workspace is structured so that I have six frameworks. There are several dependencies between them.

I tried to provide DataTypes and DataService as XCFramework in a local Swift package as targets.

DataTypes has no dependencies. Consequently, I can import DataTypes in all other frameworks without any problem.

The problem is with DataService. Since DataService depends on Apollo and ApolloSQLite, I created a Swift package Target DataServiceDependencies that contains the two dependencies. The DataService framework imports this Swift Package Target. I then archive the framework and create an XCFramework from it, which is inserted into the local Swift Package as a target.

If I now import DataService as Swift Package for the other frameworks, I get the error: "Missing required module 'SQLiteObjc'." in RoutingService. I know that SQLiteObjc belongs to SQLite.swift which is imported by ApolloSQLite.

I am stuck with this error and hope someone can help me...

I think this should explain the problem you are facing: Issue with third party dependencies inside a XCFramework through SPM - #3 by NeoNacho

Thanks for your quick reply. I tried the approach with @_implementationOnly import. For this, I have included Apollo and ApolloSQLite in DataService using the SPM. In the class where ApolloSQLite is imported, I added @_implementationOnly import SQLiteObjc. Now when I generate an XCFramework from DataService and import the binary Swift package into PositionService, I get the error: 'DataService/DataService-Swift.h' file not found.

Is @_implementationOnly import the wrong approach for me or do you know how I can fix the error?

After a long time I tried again with your solutions and got it to work. I have implemented the approach @_implementationOnly. The problem with me was that Apollo generates an API file at runtime which defines public classes and methods and does not use @_implementationOnly. With two additional lines in the shell script I customized this API file and now it works fine.

Thank you very much for your help!

Terms of Service

Privacy Policy

Cookie Policy