Set up Swift environment on Raspberry Pi (part 1/2)
Why not? It’s so much fun.
I have spent the weekend to try out. My target was to set up the environment to enable programming in Swift on my Raspberry Pi 3B+. I bought it from Amazon a few days before the weekend.
My first attempt was with Ubuntu Core 16 or Ubuntu snappy. Because there’s no apt-get in there, you have to stick to the Snap ecosystem rather than apt-get. The other choice is switch back to Classic mode, which is not in stable release right now. I paid the patient with Snap, found some appropriate software. But got no luck on Swift setup. I could go ahead with more effort, but my time was up. I walked away.
The second try was with Raspbian Stretch Lite OS. The outcome is fantastic. I had spent haft day with Ubuntu Core OS, however, it just took me less than an hour to set up all the stuff on Raspbian Stretch Lite OS, because of some reasons.
- The community is so active. More supports, more resources, more guidelines are available
- Raspbian Strech Lite OS has apt-get in place, you’re able to set up all needed parts very quickly without trouble, even with Swift.
- Set up a Raspbian OS is more convenient because you don’t even need an additional monitor or keyboard.
- The other thing to consider is boot time. The Ubuntu Core take up to 5 mins to completely boot up. It just takes less than 30 seconds with Raspbian, although the Raspbian Stretch Lite OS image is 5 times larger than Ubuntu Core. It seems smaller not meaning faster.
Ok, Let’s get started off to set up Raspbian OS in this quick tutorial.
Raspbian OS setup
Keep in mind that this tutorial is done on Raspberry Pi 3 B+, and MAC OS
- First, download Raspbian stretch lite -> download here
- Second, We have to flash the image to the micro SD card. I use this Balena Etcher, download it here. Open the app, choose the disk which is your SD card and flash it.
- Third, Open the disk directory, config Wifi if needed (Raspberry Pi 3 B+ comes along with Wifi and Bluetooth built-in).
Create a file named wpa_supplicant.conf with the following content
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1network={
ssid=”YourNetworkSSID”
psk=”Your Network’s Passphrase”
}
- Lastly, Open SSH by putting an empty file named ssh in there (with no dot, no extension at all)
Bootup
Now put back the sd card into your Raspberry Pi, plug the power cord. Wait about 30 seconds
Open the terminal in your Macbook, type the following command to connect the machine
pi@yourIpAddessHere
Keep this in mind, the default account is pi and password is raspberry
Use this command to change the password if you want
passwd
What’s next
The little pi machine is completely set up in a very short and simple manner. In the next part post, We’ll finish configuring the Swift programming environment on the Raspberry Pi.
Learn more here -> Set up Swift environment on Raspberry Pi (part 2/2)
Originally published at http://swiftreviewercom.wordpress.com on December 18, 2018.