0

I have an old project Objective-C iOS app I've been updating to Swift. It used to use Carthage, but now uses only SPM for dependencies. One such dependency is TrueTime (which was updated to support SPM by that author).

It has two products, TrueTime, a Swift library, and CTrueTime a header-only C library with some packed, byte-aligned structs used when parsing NTP responses.

I’m adding unit tests to my project, and when I import the app module with @testable import MyApp, the build fails on that line with

@testable import MyApp
                 ^
<unknown>:0: error: missing required module 'CTrueTime'

The app itself builds and runs just fine.

If I don’t import the app, then I have to expressly add code I want to test to the test target, which is not the right way to do these things. The other dependencies I have all work fine, but none have a C library product.

I get a warning about implicitly including a bridging header, but I don’t think that has anything to do with this.

Is there something more I need to add to my test target config?

Update: I also just tried adding TrueTime to a modern, pure SwiftUI iOS app, and I get the same issue.

Update2: This answer helped me a bit. It seems the build stage is not putting the required CTrueTime.modulemap and associated header file in the build products location like it does for the other modules. If I manually copy it into place, and I add the OTHER_SWIFT_FLAGS value -Xcc -fmodule-map-file=$(PROJECT_TEMP_ROOT)/GeneratedModuleMaps-iphonesimulator/CTrueTime.modulemap to the test target, it works.

Rick
  • 3,298
  • 3
  • 29
  • 47

0 Answers0