Sharing the Package on GitHub

The easiest way to include your new package in all the projects you’re working on is to load it to a service like GitHub, GitLab, or Bitbucket. In this section we’ll use GitHub, but the other services work in a similar fashion. To follow along you’ll need an account for one of those services, if you don’t already have one.

First, we need to move the package out of the project directory. Press and hold the option key and drag the package from Xcode to somewhere in the file system on your Mac. macOS creates a copy of the package at the drag destination. In Xcode, use the shortcut O to open the directory of the package. Alternatively, you can open the manifest in Xcode to open the package in Xcode.

To put the package under source control, select the Source Control > Create Git Repositories... menu item. In the window that appears, click the Create button. Xcode adds a Git repository to the project. To add all the package files to that repository, select Source Control > Commit. Check the box next to all the files and folders in the package, add the commit message "Initial commit", and click the button Commit 6 Files.

To load the package to GitHub, we need to log in from within Xcode. Open Xcode preferences and add your GitHub (or GitLab or Bitbucket) account.

Now open the source control navigator with the shortcut 2. Press and hold the control key and click the repository in the source control navigator. In the pop-up menu that appears, select Create “LogStore” Remote. In the next window you can decide how the repository should be hosted on GitHub. Check the settings, change them if needed, and then click Create.

The Swift Package Manager needs tags in the repository to work properly. Again, press and hold the control key and click the repository. In the pop-up menu that appears, select Tag “master”.... Type in the tag 1.0.0 and click Create.

Finally we can push the packages to GitHub. Select the Source Control > Push... menu item. Select the “Include tags” check box and click Push.

The package is now on GitHub, and you can use it in all your projects from now on.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.1.239