Skip to content

Instantly share code, notes, and snippets.

@loganwright
Created February 2, 2016 04:15
Show Gist options
  • Save loganwright/7d8dc3b45a5158cb29b2 to your computer and use it in GitHub Desktop.
Save loganwright/7d8dc3b45a5158cb29b2 to your computer and use it in GitHub Desktop.
SPM Command Line
  1. Install Swift development toolchain: https://swift.org/getting-started/#installing-swift

  2. Check install successful by running swift --version

  3. Check Package Manager install swift build --version

  4. Create Command-Line Project

  5. Put project aside for now

  6. In terminal, cd to project directory

  7. Create Source/ folder and create a main.swift file

  8. main.swift is a ruse to get the package manager to build, put only print("Build Successful")

  9. Create Package.swift file and add dependencies

import PackageDescription

let package = Package(
    name: "TestPackage",
    dependencies: [
        .Package(url: "../Swift-JsonSerializer", majorVersion: 1),
    ]
)

  1. Run swift-build

  2. Run swift-build --configuration release

  3. Run executable .build/debug/<#TestPackage#> // Should see Build Successful

  4. Completely quit Xcode and any Simulators

  5. Start Xcode from command-line utils: xcrun launch-with-toolchain /Library/Developer/Toolchains/swift-latest.xctoolchain

  6. Navigate to Project Settings

  7. In Import Paths add:

$(SRCROOT)/.build/debug
$(SRCROOT)/.build/release
  1. Go to the main.swift in Xcode project
  2. Import library

// TODO:

I'm pretty sure that main.swift could be the same file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment