Building SwiftPM package in docker

Hello everyone!
I added a library to my test target dependency, which builds and runs perfectly fine on a MacOS host machine. The library itself is Mockingbird, which only my application tests rely on.

However, i'm also building this application within a dockerized container within a CI process. Im using the official swift docker images (swift 5.5) for this.

Building and running tests on my local MacOS machine works fine, but within the linux docker container it doesn't seem to work.

When building the docker container, i always clean the build folder and resolve packages before building the target.

This is the error im getting when building within the docker container. The command im using is simply:
$ swift build --target AppTests

In file included from /app/.build/checkouts/mockingbird/Sources/MockingbirdFramework/Objective-C/Bridge/sources/MKBTypeFacade.m:1:
/app/.build/checkouts/mockingbird/Sources/MockingbirdFramework/Objective-C/Bridge/sources/../include/MKBTypeFacade.h:1:9: fatal error: 'Foundation/Foundation.h' file not found
#import <Foundation/Foundation.h>
In file included from /app/.build/checkouts/mockingbird/Sources/MockingbirdFramework/Objective-C/Bridge/sources/MKBTestExpectation.m:1:
/app/.build/checkouts/mockingbird/Sources/MockingbirdFramework/Objective-C/Bridge/sources/../include/MKBTestExpectation.h:1:9: fatal error: 'XCTest/XCTest.h' file not found
#import <XCTest/XCTest.h>
/app/.build/checkouts/mockingbird/Sources/MockingbirdFramework/Objective-C/Bridge/sources/../include/MKBTestUtils.h:1:9: fatal error: 'Foundation/Foundation.h' file not found
#import <Foundation/Foundation.h>
/app/.build/checkouts/mockingbird/Sources/MockingbirdFramework/Objective-C/Bridge/sources/../include/MKBMocking.h:1:9: fatal error: 'Foundation/Foundation.h' file not found
#import <Foundation/Foundation.h>

Maybe im missing out on something?
Thanks in advance!

What does your Package.swift look like? Unless you're setting the MKB_BUILD_EXECUTABLE environment variable, Mockingbird exposes a single product which relies on the Objective-C target - mockingbird/Package.swift at master · birdrides/mockingbird · GitHub

Objective-C is not available on Linux, so it looks like Mockingbird does not work on Linux

1 Like

If im correct the MKB_BUILD_EXECUTABLE compiles the CLI application for generating mock classes when using this framework. Tried that already, but it is not what im looking for.

So, there is simply no way to get this to work because of the Objective-C source code within this library?

Might remove the entire dependency and go back to writing my own mocks then, if it turns out there is nothing that can be done to fix this.

As Tim said, it’s likely just that Mockingbird isn’t Linux compatible. FWIW, we’re detecting the same failure in the Swift Package Index and mark it as incompatible:

If it helps, you can see the build command we’re using at the top of the page.


Correct - the library does not support Linux

1 Like

Thanks @0xTim and @finestructure for helping me out on this.

When selecting a 3rd party library, we simply have to check now whether it works on linux since we are building server-side apps with swift. The Swift Package Index is something i didn't know of, very helpful!

1 Like