Running local package's tests in main app's test plan

Hi,

I work on a iOS application which includes several local swift packages containing modularised code. Each of those local swift packages has a test target defined in their respective Package.swift, and when opening a local package folder standalone in Xcode, then the tests run without issues.

However I would like in the main app's test plan to add the local package test targets and have them all run together when the main app's default test plan is run. Xcode allows me to select local package test targets within the main app's test plan (also within Test portion of the main app's scheme), however attempting to build for testing throws a "Module '…' was not compiled for testing".

Any ideas on how to achieve this goal (run local package tests in conjunction with main app's tests) and avoid that error?

Thanks Peter

Did you ever found a solution for this ? I'm running into the main problem and the Xcode (v16.10) doesn't even see the test target of the local package in the test plan.

It does seem that if a local package can be edited, it should be testable too.

My workaround is to use a custom behaviour in Xcode to run a script via a shortcut. (Xcode>behaviors>edit behaviors)

I'm using osascript to display text using the following bash script which is totally AI generated (Gemini)

#!/bin/bash

# Create a temporary file
temp_file=$(mktemp /tmp/swift_test_output.XXXXXX)

# Run swift test and redirect output
cd /Users/will/songket/FontUI
swift test > "$temp_file" 2>&1

# Check the exit code of swift test.
testResult=$?

# Read the output from the temporary file
output=$(cat "$temp_file")

# Clean up the temporary file
rm "$temp_file"

# Format the output for display.
if [[ "$testResult" -ne 0 ]]; then
    message="Swift tests failed:\n$output"
else
    message="Swift tests completed:\n$output"
fi

# Display the output in a dialog box
osascript -e "display dialog \"$message\""

exit $testResult`
Running local package's tests in main app's test plan
 
 
Q