Im trying to setup an external library in a SwiftPM Package project. This package (Mockingbird) is only used from within my test target, and therefor my main application target does not depend on this.
On my MacOS host machine, building and executing this test target works perfectly fine. No errors whatsoever.
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.
From within this docker container, building the main target itself works fine, because it does not depends on the Mockingbird lib. But building the test target fails when compiling mockingbird.
When starting this Docker container, i always clean the build folder and resolve the packages first before building the targets.
This is the error im getting:
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/MKBTestUtils.m:1:
/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/MKBMocking.m:1:
/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!
Edit 1: Added dockerfile
FROM swift:5.6.2-focal
WORKDIR /app
RUN apt-get update \
&& apt-get install openssh-client lcov -y
ARG INSTALL_COMMANDS="echo \"No custom install commands provided, proceeding\""
RUN ${INSTALL_COMMANDS}
ARG GITLAB_SSH_PRIVATE_KEY
RUN mkdir -p ~/.ssh \
&& echo "${GITLAB_SSH_PRIVATE_KEY}" > ~/.ssh/id_rsa \
&& chmod 0600 ~/.ssh/id_rsa \
&& eval "$(ssh-agent -s)" \
&& ssh-add ~/.ssh/id_rsa \
&& ssh-keyscan ${GIT_URL} > ~/.ssh/known_hosts
## Copy entire repo into container
COPY ./Package.* ./
RUN swift package resolve
COPY . .
## Remove SSH keys
RUN rm -rf /root/.ssh/
After my image was created containing the source files, i run it like:
docker run ${IMAGE_NAME} \
/bin/sh -c "swift build --target AppTests"