Adding Swift 3 packages to Xcode 8 using the Swift package manager

后端 未结 2 1052
生来不讨喜
生来不讨喜 2020-12-23 21:31

I am new to Swift and Xcode. I am running macOS Sierra and Swift 3.

For my first forays in Swift, I am developing a simple command line tool. There are a couple of

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-23 22:13

    Xcode and the SPM can work together, but as far as I can tell you do need to take one step on the command line.

    Put your package manifest file into the same directory as the Xcode project, and then invoke swift package generate-xcodeproj

    The package manager will pull down your dependencies and rewrite the .xcodeproj file to refer to them.

    It will preserve any existing source, but the directory structure will be reconfigured to SPM's preferred arrangement:

    PROJECT_DIR
    ├── Sources
    │   └── ProjectName
    │       ├── YourCode.swift
    │       └── YourOtherCode.swift
    ├── Dependencies
    │   └── SomeDependency
    │       ├── DependencyCode.swift
    │       └── OtherDependencyCode.swift
    └── Package.swift
    

    N.B., I haven't tested this extensively on a live project; given the fact that SPM docs still say WIP, please make sure you've made a recent commit.

提交回复
热议问题