0

I created a 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:

module.modulemap

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

Shim.h

#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 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.

wrapper.swift

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 error:

No such module C.

ios-simulator.swiftinterface file on module S

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

Thanks in advance for your suggestions or help

Pravin Kulkarni
  • 253
  • 2
  • 9

0 Answers0