swhitty/SwiftDraw

SPM Module not found

Closed this issue · 3 comments

Hi,

I've added this library via SPM to a module in our main workspace. If i run it agains the simulator its fine but a soon as i target it against a real device i begin to get an "Module not found" error message.

The package is showing in Framerworks and libraries
image

and in link binary with libraries
image

If i build the module directly its fine but if i build the app using on of the custom schemes that i have it fails.

Are you able to attached a sample project (inc workspace) to reproduce? Or provide steps?

What kind of target are you building? iOS App or Library?

I'm not sure if this "Frameworks and Libraries" section is used within new project files, it looks familiar but I don't see it in any of my projects.

@swhitty This is a library that that is included in our main app using Xcode and i added simply by using the github address in SPM. I'm not doing anything fancy and Xcode is adding the package, as it has with other packages, to the above sections.

For me i could get the samples in your code to build either as the tests failed with the same message.

@swhitty It appears this is due to our slightly odd configuration setup. While we have a "Debug" configuration, we don't use standard "Release" configurations in the main application due to the way the software is built and distributed. We do use them in the sub-projects and this seems to be where the problem lies.

I've added a "Fix SPM" build phase which runs a script(below) that fixes the issue

# Swift Package Manager expects Debug and Release.  If they are different it breaks.
# There are solutions for this.
# https://forums.swift.org/t/no-such-module-combine-when-archiving-app-using-my-swift-package/26372
# But they don't work because the schemes in this sub-project are called Debug and Release.
# This finds directories not called Release or Debug and moves them to Release which fixes it for now.

if [ "${CONFIGURATION}" == "Release" ]; then
    for file in "${SYMROOT}"/*; do
        if [ -d "$file" ] && [[ ${file} != *"Debug"* ]] && [[ ${file} != *"Release"* ]]; then
            echo "$file"
            cp -f -R "$file/" "${SYMROOT}/Release${EFFECTIVE_PLATFORM_NAME}/"
        fi
    done
fi