Xcode 9 beta, GitHub and JSon

Welcome to Xcode 9 Beta

Xcode 9 beta and JSon objects

Actually I had in mind writing on JSon in Swift 3(Xcode 8.3.3), but scope creep occurred as Xcode 9 was released (on me). This creep turned into one big Xcode and GitHub lesson.  So this blog is about several Swift JSon projects -now in a supporting role, because the main star of this blog is Xcode 9.  Xcode is also the star because it’s faster than it’s predecessor 8 as the same counts for the new Simulator version 10. Next GitHub is integrated a a step further. And on top Swift 4 handles JSon far more elegant than ‘old fashioned’ JSONserialise-way. Probably making SwiftyJSon obsolete too.

New Simulator

To my surprise Apple paid attention to the Simulator. In comparison to it’s predecessor it starts up much faster, it is extended with the home, volume, mute and on/off buttons. Another issue I had former Simulator was pictures not showing up in the Viewer. The images did appear on my iPhone as I installed the app, yet not in the old Simulator. The new Simulator shows the images immediately. A second -layout- issue not showing the last TableView row properly without maximum pulling the page, was also solved(small chance of being caused by my View constraints settings in Swift 3).

XCode’s new simulator

Decodable JSon

Main reason for me to install Xcode 9 was because of the new way it parses JSon. In Swift 3 you have to serialise your objects and I knew it had some issues I wanted to avoid. Swift 4 parses JSon files in one line using the ‘decodable protocol’.

I know ‘programming’, but I consider myself as a noob on mobile development so I wanted to avoid any future pitfalls. With Xcode 9 there’s no need for SwiftyJSon anymore. Most probably. The Swift 3 projects contain the traditional way of parsing JSon. In the Swift 4 project the JSon serialisation code is commented and replaced by the new JSon object decoder. You’ll absolutely prefer this way (Thanks to Brian Voong’s early vlog about this new way of parsing). The examples are at the bottom of this page.

GitHub Integration

Once Xcode 9 installed I discovered Apple also integrated GitHub in it’s environment. There’s the official presentation you can only watch using Safari. My experience. To be honest: as a noob it took me several hours and project setups before I got everything right. As a true testerik at the wrong moment I managed to f’d up my environment I lost my recent project list in the Welcome screen. Using Xcode 6 and GitHub got me on the right track: “Don’t incorporate the readme at the beginning!”. Besides you need to create an ssh key for this to work, but I don’t consider this a problem for most developers. Concerning the use of ssh-keys and GitHub: I wasn’t there before, but this site helped me out. I used this integration to upload my Swift JSon projects.

Nothing to complain?

Well, my time between blogs certainly soared beyond acceptance. Indexing of a copy project made me kill Xcode 9 for multiple hangs on some localized.rsrc-thing. Bothering more than sending three Crash reports on opening a duplicate and mistreated project would become too much scope creep. Biggest bug was me recalling the ‘stupid’ actions I did.  Testers know: ‘Never trust a user!” He/she/it can be a hacker, he can be stupid.
If you’re new to GitHub and want to give it a try by doing you think you should intuitively do: Don’t! You can really mess up things. Don’t just add files to versioning as they may be missing because of a earlier mistake you made. At one point Xcode crashed and all my former Xcode 8 projects -at the first start up listed- had gone. No more recent history as the upper picture shows containing only 2 projects. Xcode 9 doesn’t’ provide any help on GitHub topics on this feature yet, so you have to rely upon internet sources. The links above can help you managing GitHub.
My first impression on XCode 9 beta is a nice piece of work worth installing.

Swift JSon projects

At last where it all started. The uploaded projects are the end result the completing the YouTube-tutorials. You can use the code to compare it with your own code in case you got stuck or use them basically as code snippets -hopefully- saving you time setting up your own JSon parser.

Swift 3 JsoN

Easy. JSon API showing Countries and their Capitals including basic search. The easiest tutorial (start of part 1 of 3). Filled from a free accessible JSon file containing country info. Plus basic search. *three hails to Yash aka yp.py*. The uploaded project is the end result of his tutorial part 3. Project: countryCapital

Easy. JSon tutorial containing hyperlinked images (which only showed up on my iPhone and not in Simulator 3 -still don’t know why. Works fine in Xcode 9 though. *Bless you Sheldon* Project: Swift3.JSON.ImageView

Swift 4 Json

Easiest! From Lets build that app. *Yo Brian Voong. Well prepared, smooth typing. Thanks for the early bird show*. Project: Swift4_JSon-Part1 and Swift_JSon-Part2.