Search code examples
swiftswift-package-manager

swift 4.0 package generate-xcodeproj not work


swift version: 4.0

Xcode version: 9.0

i want to create a swift command line tool. And i want to use CommandLine. This is my Package.swift:

import PackageDescription

let package = Package(
name: "Fengniao",
dependencies: [
    .package(url: "https://github.com/jatoben/CommandLine", from: "3.0.0-pre1")
],
targets: [
    .target(
        name: "Fengniao",
        dependencies: []),
]
)

and then i use the following swift command:

swift package resolve
swift build
swift package generate-xcodeproj

and then i open the .xcodeproj. But there's no CommandLine in my Targets list. There are two Targets instead: FengniaoPackageDescription and Fengniao. And CommandLineKit can not be imported into my main.swift

which step is wrong?


Solution

  • None of your targets actually have a dependency on CommandLine. Change your target declaration to:

    .target(
            name: "Fengniao",
            dependencies: ["CommandLine"])
    

    And then this should work.