SwiftUI Learning Curve
The SwiftUI learning curve is steep at beginning, but after you overcome it, you will harvest in high efficiency of coding.
Start from this May, due to Covid lockdown, I involved SwiftUI learning. Since then, I finished 3 apps. The third one is for reviewing my coding progress so far and, as a byproduct, presenting the SwiftUI learning curve.
This app is a GitHub OAuth app, it is authenticated and authorized by GitHub. It reads data from GitHub API. Since my XCode uses GitHub for source control, I could read the statistic data of my XCode from GitHub API and draw charts accordingly.
Each bar unit represents one week. There are 24 weeks (about 6 months) in this chart. Blue color represents how many lines of code added. Orange color represents how many lines of code deleted. (In git way of counting, if you update a line of code, it will be counted as one line added and one line deleted). The gray line chart represents the running total and summarize on the right.
My first app (TW Tide) starts with my learning of SwiftUI. It was actually quite frustrated. In the chart, there are several weeks showing none coding activity at all. It was when I got stuck. Especially when handling the SwiftUI's state variables (@State, @Binding, @ObservedObject, etc.), it was very hard to debug. I just knew the state of my app became chaos, but not knowing how to dis-entangle. Luckily, little by little, I grasp the idea and understand how it works.
My second app (Watch Mask) uses CloudKit and CoreData. It was really challenging. I thought CoreData could store in the cloud as Apple suggested. But the reality is, there are lots issues when handling transaction synchronization and merging conflicts. At then end, I decide to separate CoreData with CloudKit. I sill use CloudKit to store data in the cloud for cross device data synchronization, while in local device, I use CoreData locally. And I white code the bridge between CloudKit and CoreData. After solving this main obstacle, coding gets much easier. In the above chart, weekly coding shows increasing with time.
In my third app(vHub), it looks a lot better. It only takes two weeks to finish it. One reason is that GitHub API has many users, sample code and documents. The other reason maybe is that I overcome the most steep part of the SwiftUI learning curve and from now on, things will get better and better. I hope so.
In my third app, I still learn some new topics from my mistakes and bugs. Especially the use of CoreData and the state variables. I find that if I pass NSManagedObject between Views by ObservedObject, I will get invalid property when I delete the NSManagedObject. So I change my code, not to use ObservedObject for NSManagedObject, but to call FetchRequest in each View respectively. This is not a big issue.
List below is my three apps and the main learning points in each of them.
If you want to see your repositories likely, you could get vHub from TestFlight. It is open beta test now. Since TestFlight will not charge anything for the in-app purchase, you could have the complete functional version by click the purchase items for free.
Join the vHub 日日 beta
Help developers test beta versions of their apps and App Clips using the TestFlight app. Download TestFlight on the App…
You could also see the progress of the open source repositories. I pick up some of them as an example. It is incredible to know there are millions lines of code in these open source projects. It reminds me of the Tower of Babel. Or could we say it is one of the new wonders of the modern world.
2021/12/21 updated: This app is online now.