The Swift Dojo

A learning space for Swift and the Apple iOS tools.

Welcome to The Swift Dojo!

A learning space for practicing with the Swift language and iOS toolsets.
With the intent to develop world class Apps.
Via developing people with proven skills.

Neo:  "I know kung-fu."
Morpheus:  "Show me." 


SwiftData
better OR Mapping

I'm currently thrilled to be learning SwiftData.  It appears this is the last major component of the SwiftUI tool chain.  It is working very smoothly with the UI and makes the case for why Apple never got behind any of the popular MVC or MVVM patterns.

When your View want's to use data - SwiftData is the perfect abstraction to use.

Want to dive in - here are two learning paths to Learning SwiftData.

Learning the new framework Swift Charts

My attempt to learn the new iOS 16 Swift Charts has lead me to learn a lot. Yet, sadly not so much about the ability to make a Chart.  I've tried to understand the Apple Docs - I've RTFM!  But it has not helped.  I've developed WrapRage with Charts.  I've captured a lot of notes on useful constructs for chart code.  I'm still learning...
In iOS17 the Charts framework was updated to include the simplest of diagrams - the Pie Chart & Donut Chart. 
How to modify charts - lots of code example to search thru for the modifier that does the thingy you want.  The Charts view was never constrained to 10 sub-views like normal views before the Parameter Pack enhancement to Views.  However - there are many examples that practice poor Chart Structure; the chart data loop is important to understand.

Learning, learning, and more learning... the trick to learning...

Always be learning - that's the only trick I know that seems to work 100% of the time.

Here's one ... explorations in looping ...  the modern for statement.  Or when/how to keep it swifty when passing View data.

Xcode [or should it be written: xCode?] Tips / Tricks / Notes

Speed Boost for Testing;    AutoComplete for a Test Case;    How to create Code Snippets; Do you use MVC or MVVM in SwiftUI?    Setup xCode Code Coverage.  Placeholder Type.

New Tricks in v14   Passing Data to a View   The Singleton Pattern   Xcode Cloud Unit Test   Extract a Package

Videos on TDD using Cyber Dojo Live Coding - 100 Doors Kata

100 doors in a row are all initially closed. You make 100 passes by the doors. The first time through, you visit every door and toggle the door.  The second time you only visit every 2nd door (door #2, #4, #6, ...).  The third time, every 3rd door (door #3, #6, #9, ...), etc, until you only visit the 100th door.
After all is done - how many doors are OPEN?

Learning Swift Videos

Will video tutorials replace the programmer's bookshelf... I don't think so - but I have been wrong before.  I still like reference books and continue to purchase them.  Yet I've enjoyed learning by watching also.

TDD.Academy @ Twitch.TV  and YouTube

We think a TDD session to learn Swift - Baseball - Test-Driven Development - Xcode - the XCTest framework - all of these and more  will be a wonderful way to kick off learning here.  Follow along with us... every Friday afternoon (3:30 PT, 5:30 CT,  6:30 ET) on Twitch.TV/TDD.Academy in Feburary we pulled a designed hitter and sent in the InspireMe! Cards App to get refactored and spawn a new app  Agile Coaching Toolbox.




Our first Learning Example - Baseball

We think a TDD session to learn Swift - Baseball - Test-Driven Development - Xcode - the XCTest framework - all of these and more  will be a wonderful way to kick off learning here.  Follow along with us... every Friday afternoon (3:30 PT, 5:30 CT,  6:30 ET) on Twitch.TV/TDD.Academy

We are just getting in a grove with this format - streaming on Twitch - while we code live, mistakes, stumbling blocks, blockers, and revelations... live and unedited.  Taking suggestion and tips form the audence chat window and making our App.



A suggestion on getting Started Programming with Swift

A great way to start coding in Swift on the iOS platform or Mac is to take an introductary course on one of the many learning sites.  If you do this and have a recommendation - please let us know - we'd love to include your recommendation.

I did a Udemy course with Angela  -  Complete iOS App Development Bootcamp - I can highly recommend this for the novice programmer.

From Beginner to iOS App Developer with Just One Course! Fully Updated with a Comprehensive Module Dedicated to SwiftUI! The Complete iOS App Development Bootcamp. With over 39,000 5 star ratings and a 4.8 average my iOS course is the HIGHEST RATED iOS Course in the history of Udemy! By the end of this course, you will be fluently programming in Swift 5.1 and be ready to make your own apps or start a freelancing job as an iOS 13 developer.

---

I will also recommend Getting Started with macOS Programming by Gabriel Theodoropoulos

100 days of OSX Development video tutorials - Learn to build Mac App using Swift by Harry Ng

Any writing or video by Paul Hudson - Hacking with Swift site:

 Building a SwiftUI app for iOS  - YouTube 

SwiftUI by Example is the world's largest collection of SwiftUI examples, tips, and techniques giving you over 400 pages of hands-on code to help you build apps, solve problems, and understand how SwiftUI really works.

100 Days of Swift This is a free collection of videos, tutorials, tests, and more, all drawn from around my work here on Hacking with Swift, and all designed to help you learn SwiftUI effectively.  It’s aimed squarely at beginners who want to learn to build real iOS apps, but struggle to find a good, free course that can help them achieve their goals. If that’s you, welcome – I hope you’re ready to show the iOS world what you’re made of!

“Programming is an art. Don't spend all your time sharpening your pencil when you should be drawing.” -- Paul Hudson

A really nice book - almost like a coffee table book is SwiftUI Views Quick Start by Mark Moeykens.


You may want to create a mind-map of SwiftUI and figure out what interest you most and start there.  I forsee one BIG problem with this... creating a reasonable mind-map of SwiftUI will be very difficult if you don't know it very well yet... so start with someone else's map:  Karin Prater has a nice one: On the road to learn SwiftUI


XCTest framework and XCode integration.

Notes on XCTest Framework 

Want to know what calls/methods are avaliable in the UI portion of XCTest?  Try Paul Hudsons' Cheat Sheet ( https://www.hackingwithswift.com/articles/148/xcode-ui-testing-cheat-sheet ).

Notes on Testing Views

Testing a view is hard.  Even harder is Test-Driven view design.  It may be easier to code the view and then imediately write the test.  But one thing is sure - ViewInspector should be in your toolbox.
ViewInspector ( https://github.com/nalexn/ViewInspector ) is a unit testing framework/library for working with SwiftUI views.  It allows the developer to inspect a view, traverse the view hierarchy down to an interesting view under test and access that structure.  Pulling out values, strings, properties and testing them for validation.  With ViewInspector the integrations/system test that might take seconds with XCTest-UI will run in microseconds; converting the test into a quick to execute test is worth lots of effort never wasted on slow UI-Tests.




A TDD Example for the Fibonacci Sequence - for Swift using XCode

The classic Kata that I learned many moons ago is the Fibonacci Kata.  First described to me in Kent Beck's TDD book, appendix II p211.

Start with this peusudo code.

Fib(0) should return 0

Fib(1) should return 1

Fib(1) should return 2

Fib(2) should return 3

Fib(3) should return 5

Fib(5) should return 8

... continue until you have a well factored and concise Fib() function... Red-Green-Refactor.  Here is a Starter Project on gitHub.

My last attempt at this Kata the implementation code started like this:

step 0:

static func fib(_ number: Int) -> Int {

        return 0

    }

step 1:     

static func fib(_ number: Int) -> Int {

        return number

    }

my next implementation was an infinite recursive function - it failed....

The Ultimate Portfolio App

I'm going to follow along with Paul Hudson's Ultimate Portfolio App.  See his site: Hacking with Swift - for more info.


Day one - watching his intro videos... trying to decide on the App I will build - he's attempting to design in enough flexibility to allow the viewer to write a unique app as we follow along... (will it work?).  Come along and see...

Paul's got 16 videos up in part 1 of the Ultimate Portfolio App series and continuing to write and film more.  I was doing great following along until #13 Custom sorting for items... that video has quite a few options... and it got confusing what code I should use, what I should leave in, vs what to pull out.  It's going to take me some time to rewatch and fix my mess.

I can enthusiastically recommend this purchase.


Source Revision Control

If you are like most developers - solo or on a team - you practice some form of version control; most likely GIT.  XCode will easily help you along this path to a great practice - the new Integration menu is packed full of Git goodness.

If you want a great video series on learning to use version control - see Stewart Lynch's series (released later in 2024).

I've started practicing the Mikado method.  A software versioning practice that relies heavily upon the ability to revert your code to a known good state!  It is a practice of focusing on the one small change that improves the code.  And when that change starts to branch off into yet another thing that needs to change (a dependency) - then you STOP - revert to the known good state, and start again upon the dependency.  This practice keeps one from chasing too many rabbits.

I've also developed a good practice to keep my plan flowing... I've used the inverted todo list - inside a BuildPlan,md (MarkDown file).  This allows me to defer (and not forget) some ideas while I'm coding - and not chasing that particular rabbit.   I also record my Mikado Revert process steps - because I feel that one day I may reflect and realize the poor patterns that lead to wasting time.