Using Apple Swift Playground for the first time is actually quite an interesting experience. There are so many different paths to get HERE, especially when nobody actually guides you. You might be on your own, but you can always try Google Search and look for example and video tutorials on YouTube.
Over the past few years, Apple has introduced all these cool tools that probably confuse people at first, but actually make sense today in 2017. I really have to dig into older WWDC as far as 2013 and see what Apple is trying to do.
As a total beginner to App Development environment and all kind of actual coding and building interface, control, logics, there are A LOT to make sense.
SWIFT PLAYGROUND AS JUMPING STONES
I think, THE MOST IDEAL path of actually getting into Apple XCode app development via SWIFT PLAYGROUND is like this:
1) Start with Swift Playground on iPad, not XCode!
For beginner coders, whatever your age, maybe even for those who never code before, it is best for you to start with Swift Playground app on your iPad. This will generate the idea of computational thinking, fun coding, a guided experience of what code can do.
If you are lucky to live in the city with Apple Store, try their "Today at Apple" and sign up for beginner Swift programming.
Swift Playground app on iPad is actually quite robust as it is. Basically a very powerful app with lots of very cool examples in form of playful Playground Books that you can try yourself or together with your teacher, if you have one.
Playground Books is a little bit like Python Jupyter Notebook or Wolfram Alpha Mathematica Notebook. You can use Playground Markup language to basically provide users with some text and reading, articles that explain the code, and also giving user with snippet of codes for them to modify and to use to make their own things. You need an iPad to run Playground Books.
A playground book is a package of Swift files and extra sources in a specific file layout on disk. You can right click on the .playgroundbook file and choose Show Package Contents in Finder to see all of the individual Swift files. The organization of the files is documented in the Playground Book Format Reference. While regular playgrounds can be edited and run within Xcode (regardless if the platform for the playground is iOS or macOS) or in the Swift Playgrounds app, playground books need the Swift Playgrounds app on iPad to run.
A more advanced coders can really help beginners coder to have fun with code inside Swift Playground. But they can also just use Swift Playground to test some algorithm, just to test things.
Swift Playground creates this environment for TEACHER and STUDENTS or MENTORING to help each others.
Now, beginner Swift coders should not feel intimidated, in fact it is very encouraged for beginners to treat yourself, to enjoy and have fun with "simple coding" in Swift Playground that will take you quite far.
See also the Starting TEMPLATES:
Starting templates come with some handy Classes and Objects already to help beginners to actually easily code and quickly present something on screen. Under the hood, you can see some additional codes that actually allow you to do all those functions.
There are some fantastic Playground Books online at Github for you to download, that you can AirDrop into your iPad, or you can use iCloud Drive to do this transfer (if your device does not support AirDrop).
2) Next step: Download XCode, try Swift Playground inside XCode
After you test out the Swift Playground, you can then further explore the Swift coding using the XCode version of Swift Playground, while reading Apple iBook companion. Apple also provided you with this education iBook especially for Swift Playground. This has some great examples that you can follow like interactive book.
3) Finally: Further explore XCode and actual app development
Not everyone actually has further desire continue and make apps, however if you feel so, you can further challenge yourself to the next level, to actually use Swift inside XCode.
XCode will give you all the power to use Swift code and Interface Builder, to actually make apps that you can later publish to the App Store.
iTunes U, Stanford course can be good, but there are many other tutorials out there that can help you to create some basic apps, to understand the process of making app.
This step 3 is actually the most challenging, and the good place to start is to actually use the TEMPLATE code, just to make some super basic app.
My own interest to use XCode is to use iOS ARKit, to hopefully create Augmented Reality app that can present my 3D contents as interactive app for users using device like iPhone and iPad . This is actually a huge undertaking, but very interesting as each basic step can advance you further.
NOTE:
Really, I think doing step 1 and 2 are interesting enough for most people to understand what program can do and can help them to understand the idea of COMPUTING and MOBILE COMPUTING better, what their device can do with code as a fully built app.
It might surprise a lot of people that of what their device can do, even with a very little knowledge of coding.
In fact, like I said, Swift Playground on iPad is actually very powerful, almost like a huge app in itself. With Swift 4 on iPad Playground, you can actually experiment with ARKit, you can control drone, and some robot via bluetooth or wifi.
TESTING SWIFT PLAYGROUND ON IPAD AIR
Ok, now so let's go back to SWIFT PLAYGROUND topic.
Beyond Swift Playground on iPad, you can actually make your own app inside it, maybe with some limitations, but you will be surprised by what you can do inside Swift Playground.
I found that the best to start is to type the TEMPLATE of Swift Playground from XCode into Swift Playground on iPad.
Doing Swift Playground on XCode, on your Mac sometimes is a bit more convenience:
- You can use your normal keyboard
- You can quickly check documentation
Doing Swift Playground on the iPad has its own JOY and interesting quirks. You can actually code using just touch interface. I actually have not purchased iPad keyboard, so doing it on iPad might be slower, but still quite fun.
Swift Playground is actually interesting, as cool as it is, you are presented with BLANK screen. Empty screen where you need to code everything in order to give a result! --- well, unless you start with the TEMPLATE to allow you to draw and do interaction.
If you watch some WWDC presentation and some YouTube videos on Swift Playground, you might soon found out about:
- Playground Book
- Playground LIVE VIEW
Playground Live View is definitely the one that is the most interesting. However, in order to actually be able to display anything inside Live View, you need to use View Controller. Well, with a bit of start up codes, you could actually display some visuals, similar to Processing app. A bit trickier, but it will get there.
Below is my test to basically follow the Swift Playground TEMPLATE from XCode, and modifying few things inside the iPad.
What actually happens below:
- We are creating UIView
- Add UILabel
- Add UIImageView
- Presenting the ViewController
Just the code without Live View:
When the code is run and I am displaying the Live View:
Sure, my image is overlapping with the text, and this is a super weird layout, however, we can see a result, a frame with custom color, with some text (with emoji) and a custom image from my iPad.
Very powerful!
WHAT NEXT?
So, I guess that is pretty good to start. We can perhaps add some kind of INTERACTION or to make it so that user can draw with touch, or making some object ANIMATING.As Visual Artist, the most encouraging part in making app is to see something working. Even a simple thing.
The funny thing about CODING and making actual PROGRAM / APP is like.... this is NOT a linear process. In fact, you might actually start by building some kind of Frankenstein program at first, before later on you tidy things up and build a better app.
Comments
Post a Comment