Hands-On Full:Stack Development with Swift
上QQ阅读APP看书,第一时间看更新

Publishing a Swift package

Publishing a Swift package is as simple as committing code, tagging it, and pushing it up to a git repository. To publish the package, perform the following steps:

  1. Create a public git repository on github.com.
  2. Open the Terminal and change your directory to your package's path, cd /path/to/your/swift/package. Then initialize the git repository by running the git init command.
  3. Add a remote origin to the local git repo by running this command:
git remote add origin git@github.com:<repoaccount>/<reponame>.git 
  1. Make sure to replace the repo account and repo name with the one you created in Step 1.

 

  1. Add all files to this repo using git add . and commit them using git commit -m "Initial Commit".
  2. Tag it with a version. Since it is our first package we will tag it 1.0.0,
    git tag 1.0.0.
  3. Publish it by pushing it up to the repo along with the tag:
 git push origin master --tags

It is that easy to make a Swift package and publish it. All you need is a git repository to push your code to and tag your code appropriately so that whoever uses your package as a dependency can point to a specific version.