Script Snippet: Swift Packages

From Coder Merlin

Create a new Swift Package for an Executable[edit]

swift package init --type executable

Remove the build artifacts of a Swift Package[edit]

swift package reset

Build a Swift Package in default debug mode[edit]

swift build

Build a Swift Package for debugging in lldb[edit]

swift build -Xswiftc -g

Build a Swift Package in release mode[edit]

swift build

Create a Library[edit]

swift build -Xswiftc -emit-library

Consume a Library[edit]

swift build -Xswiftc -I -Xswiftc ./.build/debug -Xswiftc -L -Xswiftc ./.build/debug -Xswiftc -lmyDynamicLib

Reference


Designed with pride in Silicon Valley, CA, USA