Before we even think about writing code, you'll need a certain basic setup. This chapter will walk you through the process of getting set up. We will cover the following topics:
Creating an account on GitHub and importing an SSH key
Setting up the Git version control system
Getting and using the elementary developer "SDK"
We’re going to assume that you’re working from a clean installation of elementary OS 5.1 Hera or later. This is important as the instructions you’re given may reference apps that are not present (or even available) in other GNU/Linux based operating systems like Ubuntu. It is possible to apply the principles of this guide to Ubuntu development, but it may be more difficult to follow along.
GitHub is an online platform for hosting code, reporting issues, tracking milestones, making releases, and more. If you're planning to publish your app through AppCenter, you'll need a GitHub account. If you already have an account, feel free to move on to the next section. Otherwise, sign up for a GitHub account and return when you're finished.
To download and upload to GitHub, you'll need the Terminal program git
. Git is a type of version control system that allows multiple developers to collaboratively develop and maintain code while keeping track of each version along the way.
If you're ready, let's get you set up to use Git:
Open the Terminal and install Git
We need to inform Git who we are so that when we upload code it is attributed correctly. Inform Git of your identity with the following commands
To authenticate and transfer code securely, you’ll need to generate an SSH key pair (a kind of fingerprint for your computer) and import your public key to GitHub. Type the following in Terminal:
When prompted, press Enter to accept the default file name for your key. You can choose to protect your key with a password or press Enter again to use no password when pushing code.
Now we're going to import your public key to GitHub. View your public SSH key with the following command, then copy the text that appears
Visit your SSH keys page and click the green button in the upper right-hand corner that says "New SSH key". Paste your key in the "Key" box and give it a title.
We're all done! Now you can download source code hosted on GitHub and upload your own code. We'll revisit using git
in a bit, but for now you're set up.
For a more in-depth intro to Git, we recommend Codecademy's course on Git.
For more details on uploading your SSH public key to GitHub, please see GitHub's official guide.
At the time of this writing, elementary OS doesn't have a full SDK like Android or iOS. But luckily, we only need a couple apps to get started writing code.
The first piece of our "SDK" is Code. This comes by default with elementary OS. It comes with some helpful features like syntax highlighting, auto-save, and a Folder Manager. There are other extensions for Code as well, like the Outline, Terminal, Word Completion, or Devhelp extensions. Play around with what works best for you.
We’re going to use Terminal in order to compile our code, push revisions to GitHub (using git
), and other good stuff. Throughout this guide, we’ll be issuing Terminal commands. You should assume that any command is executed from the directory “Projects” in your home folder unless otherwise stated. Since elementary OS doesn’t come with that folder by default, you’ll need to create it.
Open Terminal and issue the following command:
In order to build apps you're going to need their development libraries. We can fetch a basic set of libraries and other development tools with the following terminal command:
On elementary OS you will already have the required Flatpak remote and platform pre-installed. On other Linux OSes, you can add the remote and install the Flatpak platform and SDK:
And with that, we're ready to dive into development! Let's move on!