Xcode can't resolve binary target, suggestions?

Trying to migrate to using .xcframeworks as binary targets within SPM, but running into the following error:

xcodebuild: error: Could not resolve package dependencies:
  target 'SwiftProtobuf' in package 'REDACTED' is outside the package root

This is how I linked the binary targets:

            name: "SwiftProtobuf",
            path: "../../Carthage/Build/SwiftProtobuf.xcframework"

Previously we were doing this, which worked fine:

    dependencies: [
        .package(path: "../../Carthage/Checkouts/swift-protobuf")
    targets: [
            name: "REDACTED",
            dependencies: ["SwiftProtobuf"]

Why does SPM let me add a dependency package from outside the package's directory, but not a binary target? Is this a bug or intended...?

Seems like it's what Apple intended, since there's a verbose error about it. However, what do they expect us to do—put a unique copy of each binary target inside each package's directory structure? Resort to symlinking? Neither option seems particularly practical.

Should I just go ahead and file a radar?

Note: was able to trick it to build by just making a symlink inside a "lib" folder in the package root that links to "../../Carthage/Build/SwiftProtobuf.xcframework", then doing:

            name: "SwiftProtobuf",
            path: "lib/SwiftProtobuf.xcframework"

And yet the linked-in framework is still outside the package root. So why does it let me do this, on the one hand, but I can't just specify the path, on the other hand?

Is there a way to use environment variables within the strings of Package.swift?

Somewhat, you can just use ProcessInfo APIs to get to them as in any Swift program. The problem is rather how to consistently set them since e.g. Xcode won't necessarily inherit the environment from your terminal, it depends on how you launch it.

Well, we're talking about environment variables that would be defined by the scheme or by fastlane.

Environment variables in the scheme are for the runtime of your app, so they can't affect package resolution as that happens much earlier.

The ones defined by fastlane should work as they would be available to xcodebuild throughout the whole process.

Terms of Service

Privacy Policy

Cookie Policy