Spm gotchas

My notes on SPM

Basic gotchas:

swift package init Creates the init spm project swift package init --type library ⚠️️ Untested ⚠️️ swift build Builds dependencies swift package generate-xcodeproj Makes xCode proj swift package update Updates dependencies

Other gotchas:

  • Use a framework target in your app project as an umbrella framework so that you don’t have to rebuild src code on every build. (Because SPM only handles src code)
  • Make sure packages build, before you add them as dependencies. Or else xCode may crash etc
  • Instead of adding SPM dependencies to xcode, one by one. You could add a local SPM repo with dependencies, now you have a package.swift you can edit with an editor. even test with terminal 👌

Target branch:

dependencies: [
	.package(url: "https://github.com/eonist/B.git", .branch("master"))

Define os version

Sometimes some API is only available above some OS version. Specify this in the platforms variable

import PackageDescription

let package = Package(
    name: "TodoSwiftUIComponents",
    platforms: [.iOS(.v12), .macOS(.v10_13)],


SPM and Commandline targets Sundell on SPM https://developer.apple.com/documentation/xcode/creating_a_swift_package_with_xcode