So as I mentioned last week, this weekend I put myself to the task of creating a basic Text Editor app. Let me tell you, it’s not as easy as I thought it would be, despite the ‘basic’ idea.
The first of my problems came as I realised that the basic coding I learned from last week is pretty much useless in what I wanted to achieve this week, as far as I can tell anyway.
So, to try to get at least something I had to trawl Google and YouTube again for various tutorials. Thus came my second major hurdle.
I have the latest non-Beta version of Xcode installed (v12.0.1), which apparently is super new because every tutorial I found was either Xcode 11 or Xcode 12. You’d think there wouldn’t be much difference between them, but holy cow there is.
This tutorial seemed pretty promising however, it was for iOS, which isn’t what I want to do (which is a macOS app). I encountered the same issue on all the YouTube videos, they all program iOS apps (there’s gotta be a market for macOS dev tutorials surely?)
I started to get a little frustrated at this point, so I went back to that first tutorial I linked just so I could get some actual coding practice in. I got a fair bit into it and started enjoying it a little – followed the tutorial exactly (with trial and error on figuring out the type of project in use).
All was fine and well in the ContentView.swift file, but then he said, “let’s go ahead and edit the main swift file.”
I look at where he is looking. I do not have such “main Swift file”. At this point, I kind of wanted to flip my desk. I tried to mimic what he was doing in other files such as the Delegate file – no comprendo. I was out of luck.
So I switched tack.
I decided to Google “Swift 12 macOS develop text editor app”.
I got to the part where it asks to edit the ViewController.swift file. Could I find that file anywhere? Nope. Upon writing this, I decided to go back and see again if I could troubleshoot where I went wrong and I think I’ve found it.
While the tutorial I found has a beginning to check the box for a “document-based application, I didn’t have that option presented to me – instead, there is a dedicated project file called “Document-based app” which I initially thought was the updated version of that tick box.
I was right, BUT, to get the ViewController.swift file, I needed to change the interface to “Storyboard” instead of “SwiftUI”, which is apparently a new thing.
SO, I started all over again with the same tutorial and managed to complete most of it, except for some reason when I open previously saved notes the note contents are gone.
This is what the troublesome screen code looks like in the ViewController.swift file, where I believe the problem must lie:
Let me know if you can spot any errors!
I’ve gone over the tutorial again and again but I’m obviously missing the issue, either way, I’m calling it a day there – I’ve spent a solid 6 hours on this project today.
Main takeaways from this learning session:
Read/watch through the source material completely before following along and potentially wasting a bunch of time.
Coding can be frustrating, but it does fire up my problem-solving desires.
iOS development is more popular than macOS development.
Even ‘basic’ development is pretty hard, I’m likely going to spend more time on this project than I initially set out.
All in all, while I’m happy with what I managed to get out today, I’m not quite happy with my level of understanding of programming. Much of what I did today was a case of “oh okay, type that in,” without really knowing why and what the functions really were.
So next week I’ll stick with my learning plan (albeit, a week behind) and delve more into the language itself.
I hope you’re having a great weekend! Please consider subscribing if you’re interested in learning Swift as well as future projects alongside me!