Package with Git submodule doesn't build correctly

Hello, I work on an open-source iOS framework (https://github.com/smartdevicelink/sdl_ios). I'm testing it out in Xcode 11 Beta 5 to make sure that it can build correctly as a Package. But it doesn't seem to be building correctly.

The framework uses a C submodule (https://github.com/smartdevicelink/bson_c_lib). I'm seeing an error in my test project within my framework when it tries to import a file from the submodule:

#import "bson_object.h" <-- Compiler error "'bson_object.h' file not found"

Has anyone run across this before? Any help on ensuring that the framework will build correctly with SPM?

The package manager does not support submodules. (Unless it started to and I missed the memo.)

If your package is a topā€level one, you can simply resolve the submodules manually with Git before doing any package operations (build, test, generate Xcode project, etc.).

If your package is intended for import by others, you can still use the above strategy during development, but whatever commits you want to be importable (often just semantic versioned releases) will need the source moved out of the submodule and directly into the package repository.

You can certainly pitch submodule support under the evolution category, but I am not sure of all the peripheral implications.

The most common design pattern with respect to this is to add a Package.swift to the C repository (or a fork) and then depend on it as a package instead of as a submodule.

Terms of Service

Privacy Policy

Cookie Policy