2

I'm building a command line tool with the Swift Package Manager, using Ink as a dependency.

I'm following this article by John Sundell for reference, and I managed to get the tool to compile and run with swift build -c release.

I also generated a corresponding Xcode project with swift package generate-xcodeproj, so that I can use the debugger and work more effectively.

However, whenever I try to run my tool from Xcode, I get this error:

dyld: Library not loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
  Referenced from: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
  Reason: Incompatible library version: HIToolbox requires version 1.0.0 or later, but Ink provides version 0.0.0
Program ended with exit code: 9

For reference, here's my Package.swift:

import PackageDescription

let package = Package(
    name: "SwiftSiteGen",
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
      .package(
          url: "https://github.com/johnsundell/files.git",
          from: "4.0.0"
      ),
      .package(
          url: "https://github.com/johnsundell/Ink.git",
          from: "0.1.3"
      ),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "SwiftSiteGen",
            dependencies: ["SwiftSiteGenCore"]),
        .target(name: "SwiftSiteGenCore",
                dependencies: ["Files", "Ink"]),
        .testTarget(
            name: "SwiftSiteGenTests",
            dependencies: ["SwiftSiteGen"]),
    ]
)

I'm running on Xcode 11.2.1, on macOS 10.14.4.

Since running swiftc build works, I feel that the problem is with Xcode trying to use dynamic frameworks rather than static libraries. Possibly related question here.

Are there some Xcode project settings I need to change to make this work?

bizz84
  • 1,964
  • 21
  • 34

1 Answers1

2

Verified Solution

Do not run swift package generate-xcodeproj.

Instead, just open Package.swift directly in Xcode.

That way, all packages are statically linked.

bizz84
  • 1,964
  • 21
  • 34