You can upload the source code of your apps (i.e., the files you write in the language Swift) to the GitHub web site. Once there, everybody in the world will be able to read the files of your app. In fact, they will be able to download these files and run your app in their Xcode.
I encourage you to use this list to play with the apps written by your classmates.
Create a free personal account if you have not already done so. Here are the accounts that students in the class have already created.
Follow
these
instructions.
You can skip the first section, About SSH.
In the instructions,
you have to type only the lines that start with a
$
.
(The
$
is called the
prompt.)
But do not type the
$
and the space after it.
For example, the command in
Checking
for existing SSH keys
is the following.
The
ls
(lowercase LS)
stands for “list”.
The
-al
(minus lowercase AL)
stands for “all long”.
The
~
is a tilde.
ls -al ~/.ssh
If the output of the above command shows that you have
any one of the four files
id_dsa.pub
,
id_ecdsa.pub
,
id_ed25519.pub
,
or
id_rsa.pub
,
it means you have already created an ssh key
and you can skip to
Adding a new SSH key to your GitHub account.
Otherwise, proceed to
Generating
a new SSH key and adding it to the ssh-agent.
In Generating a new SSH key and adding it to your ssh-agent, remember your passphrase. You’ll need it to set up the GitHub client, below.
Adding a new SSH key to your GitHub account tells you to type the command
pbcopy < ~/.ssh/id_rsa.pubBut if Checking for existing SSH keys revealed that you already have a file named
id_ecdsa.pub
,
id_ed25519.pub
,
or
id_rsa.pub
,
you will have to change the
id_dsa.pub
in this command to the name of the file that you do have.
In Adding a new SSH key to your GitHub account, substep 2, to see your “profile photo” use your browser to log into your GitHub account. Widen the page until you see your photo in the upper right corner, and click on it.
Download the client from here. Its icon is a silhouette of a purple cat. When you install it, it will ask you if you want it moved to your Applications folder. Say yes. It will also say “Let’s take a minute to set up your computer.” Do not skip this step. It will ask you to login to your GitHub account. Press the “Install command line tools” button.
Let’s say you have created an Xcode project named
Hello
,
stored in a folder named
Hello
on your Mac Desktop.
Remember that when you created this project in Xcode,
you checked the checkbox for
Source Control: ☑ Create Git repository on: My Mac.
Make sure all the files you edited in the project are saved.
The easiest way to do this is to press the triangular run button
in the upper left corner of Xcode.
We will create a repository named
Hello
to hold this project.
Launch the GitHub client and pull down its File menu.
File →
Add Local Repository…
Choose the
Hello
folder on your Desktop and press the Add Repository button.
You should now see your
Hello
project listed in the left pane of the GitHub client.
If you ever wanted to remove the project from the left pane,
you could control-click on it and select Remove.
Repository →
Publish
Name: Hello
Description: type a one-line description of your project.
Press the Push Repository button.
Point your web browser at your GitHub page
(i.e., one of the pages listed
here).
You should see a new repository named
Hello
.
You might have to wait a minute,
or press the Repositories tab in the page,
or even press the browser’s refresh button.
The new repository should
contain several folders and files,
including a
.xcodeproj
file.
But if you look at the
.swift
files,
you will see that they do not yet contain
the Swift statements you typed into Xcode.
Go back to the GitHub client and fill in the one-line Summary of the current state of your project under the Commit & Sync button. You can say “This is my first version of the app.” Then press Commit & Sync.
Go back to your GitHub page in your web browser
and examine at the files in your project again.
Press the browser’s refresh button if necessary.
The
.swift
files should now contain the Swift statements you typed.
You can edit your project in Xcode (hopefully to improve it), and then put the new version on your GitHub page. Go to the GitHub client, type a one-line Summary under the Commit & Sync button, and press the button.
Point your web browser at your GitHub page and select the repository. In the lower right corner of the page, press the Download ZIP button.
If you ever wanted to delete the repository from your GitHub page, point your web browser at your GitHub page and select the repository. In the right side of the page, click on Settings. (It has a screwdriver and wrench.) Scroll down to the Danger Zone.