XCFramework cannot import other module



Thanks in advance, any help greatly appreciated.

I created an XCFramework from a C Library (say a libc.a and corresponding “include” folder with header files) , lets call it C.xcframework. I want to interact with it from Swift, so I created a modulemap and corresponding header file, like this:

modulemap
Code Block
/// Expose C for Swift usage
module C {
    header "shim.h"
}

shim.h
Code Block
#ifndef shim_h
#define shim_h
// A shim header to bridge C to a Swift modulemap
#include <libc/header.h>
#endif /* shim_h */

As this is a C library, to offer a better interface to my Swift App, I decided I wanted to wrap it in a Swift Framework, let’s call it S framework. This S framework imports C.xcframework within the “Embedded Frameworks” section. The wrapper can now do import C and have access to all the functions exported by the modulemap without any issues. I created all sort of cool functions to wrap my C library and everything is tested and working. Excellent!

wrapper.swift
Code Block
import Foundation
import C
// Wrapper code...



Now it is time for my App to make use of the S framework. To do so, I decided to create another S.xcframework. So I went ahead and archived the different architectures (iOS and iOS simulator). This time the compiler, as it is Swift code, created a Modules folder with the generated Modulemap for S and corresponding interface files. From this two archives I created a S.xcframework with the usual CLI command, referencing both architectures.

My App now imports S.xcframwork, and when I go and do the import S, I receive two build errors:

Failed to build module S
No such module C.

The last one takes me to the ios-simulator.swiftinterface file on module S:

Code Block
import Foundation
import C  // !Error here, No such module C
@_exported import S
import Swift
// header code...


So it seems like the imported S.xcframework cannot be built because it doesn’t have the C module. I went ahead and added C.xcframework to my project as well. And to my surprise, now the App can actually do import C without problem, but still fails when building with the same error. So for some reason the xcframework is not visible to the other xcframework.

Any guidance on how to solve this problem?

Thanks again!
did you find a solution for this problem?
XCFramework cannot import other module
 
 
Q