Using "MacOS by Tutorials" with Older Versions of Xcode

What kinds of problems might I expect to encounter if I try to use this book, “MacOS by Tutorials”, with older versions of Xcode?

Specifically, the latest version of Xcode that will run on Catalina is 12.4 and Catalina is the latest MacOS that will run on my MacBook Pro. What differences can I expect between Xcode 12.4 and the version of Xcode used in the book, and will they be significant?

These are introductory tutorials so what use do they make of newer features of either MacOS or Xcode?

Thanks.

Hi,

I do not have access to a Catalina system or to the version of Xcode that was available then, but the apps in the book will not compile for Catalina (macOS 10.15).

Swift and SwiftUI have advanced considerably since then, so there are a lot of features in the book and code that were added in macOS 11 (Xcode 12) and more that were added in macOS 12 (Xcode 13).

If you want to learn macOS development using Catalina, then I recommend that you forget about SwiftUI and look for older resources that use AppKit.

As it says on the cover, this book requires Xcode 13.1 and macOS 12 and if you try running the book code with your system, you’ll see a huge list of errors.

1 Like

Thanks. I was afraid of that. It’s nice to not have to figure out the issue the hard way.

Any suggestions on where to start looking?

I found the Kodeco “Hello World” and your “Scriptable Tasks” tutorials, but that’s quite a jump. There’s a LOT in “Scriptable Tasks” that I am having trouble following and because it’s noticeably older than Catalina, there are errors at that level that I sometime have trouble distinguishing from my learning errors.

There are many macOS Tutorials in Kodeco - now archived - that will work with Catalina. However, you may also encounter errors because the compiler and libraries will still differ.

If you are still willing to give it a go, start here:

It would help if we knew what your goal is. Do you want to learn programming or do you want to learn how to write apps for Macs and other Apple devices?

If you want to learn how to write apps for Apple devices, then you’re really going to struggle if you can’t run the latest version of Xcode. Swift has developed a great deal since Catalina and I’m not sure if the App Stores accept apps built with that version of Xcode.

If that is your goal, then I recommend searching for Cocoa programming guides published around 2018.

If you want to learn programming in general, then you might be better with a more general purpose language like Python or JavaScript. They both get new features but not as quickly as the relatively new Swift language. And they tend to allow older styles and syntaxes to work for many years.

1 Like

Well, that opens a can of worms. It’s not a simple goal, but the goal is simplicity.

As Pacal and other have famously said, please forgive the length of this note, I don’t really have time to make it shorter.

I am not trying to “learn how to program” nor am I trying to learn how to write Mac apps to sell or even give away on the App Store. I’m building a tool to help me manage how I work on my Mac. If it develops into something I can share with other people, great, but my first goal is my own use.

As for my programming background, I have a degree in Information Science and I’m “officially” a UNIX Guru because I wrote my own Troff macro set, way back when, that even included macros that redefined other macros. If you know anything about Troff, you probably know that it does not have parentheses or brackets or anything that nests the way we’re used to in modern languages. I was able to write macros that defined a scope and that could end, not with a separate macro for each ending as was the common practice (e.g. a Pull Quote format starts with .PQ and ends with .QP) but rather I could end a macro’s influence with a standard “end of scope” macro that would close out that context because that macro was redefined every time a scope macro was invoked. Essentially I wrote a “context switcher” in Troff. It worked well. I had a half dozen people in my publications team using that macro set on a daily basis for a couple of years.

When I worked at Adobe where we were required to “eat our own dogfood” and do all documentation review using PDFs, I wrote my own tools to tag other people’s PDF comments in the markups with my working status for their comments: To Do, Working, Completed, Postpone, Rejected, Questions to Research, Questions to Delegate. All written in JavaScript for Acrobat. I showed it to Engineering and they incorporated some of my idea into Acrobat, but they had an overly simplified, canned list of statuses rather than letting the user define their own.

I have some experience with programming projects.

But that JavaScript and a little bit of Ruby for SketchUp is basically the limit of my Object Oriented programming. I’m still learning when and how to use a Class is even though I took a course in Lambda Calculus in college.

Just like those two historical examples, what I’m working on now is building a tool to smooth my own workflow to do things that I’ve been unable to find out there.

In this case, I use Mission Control a LOT. Instead of the presumed max of 16 MC Desktop Spaces, where using more than about 5 or 6 becomes awkward, I currently have 45 Desktops, about 22 of which are in daily use.

To manage that, I want to be able to assign text names to those Spaces and be able to change Spaces by menu or hotkey. The hotkey side of things I expect to be able to accomplish with Keyboard Maestro.

For the assigning names and listing them in a menu, I have a very simple app which, when given a text list, will make small windows, titlebar only, stacked in the lower left corner of the screen, with each title being a line from the given list. I can manually move those windows, one at a time, to various MC Desktop Spaces where they become my name for that Desktop Space. With that app active, its Window menu gives me a dropdown menu of all the named Spaces, the current one is checked, and when I pick another, I move over to that particular space. So I can pop from Desktop to Desktop by menu with text names of arbitrary length.

But I want to be able to make the windows not by a hardcoded list but via AppleScript (or maybe the command line), which I will probably invoke with Keyboard Maestro, so that instead of having to make the window titles on startup and having to manually move them to the appropriate Desktop, I can automatically change Desktops and then automatically make the window title for the current Desktop on that Desktop. That not only lets me automate setting up the system, I expect it will let me make tools that I can use to change things on the fly, rename a Desktop Space or add a name to an unnamed one, etc. By having the name of the Desktop Space be determined by an app window, I can rearrange the order of the Desktops and the names move along with the reordering, something the MC Desktop 1, Desktop 2, etc. naming system does not handle.

So I’m trying to learn how to add AppleScript to my existing extremely simple app, or add a command line interface to it, to be able to invoke my little Window-Title-Making function.

I’ve been trying to work my way through Sarah’s old tutorial on “Scriptable Tasks”. But it feels like jumping into the deep end of a pool that’s covered with lily pads.

I just want to add AppleScript commands to my extremely simple window-making app. But every page of documentation and every tutorial that I have found is either too simplistic or else it presumes too much and I can’t follow it enough to sort out the errors.

I was hoping this book might help me that gap.

Phew! Well firstly, thanks for providing all that detail. I don’t really see that my book has anything useful for you, but here are some ideas.

  • You don’t need to make your app scriptable. It seems to me that you need your app to issue AppleScript commands to the system or to Finder. A scriptable app accepts commands from other AppleScripts.

  • I would suggest that you forget about an app for now and concentrate on learning AppleScript. The resources available for this will be old, but they should all still work.

  • Work in Script Editor to make AppleScript do what you need. once you have a script that works, you can bring it into your app and run it from there.

  • I did a search for “applescript mission control” and got several useful looking hits.

I hope this is some help. good luck with your project.

Sarah

1 Like

Thanks for making it clear that I did not communicate that part of my design well enough.

Yes, AppleScript can tell other apps to make a bunch of windows. But AppleScript cannot make windows all by itself. I could, for instance, use TextEdit and place a TE window in each desktop. Or a Finder widow. But if I then used TextEdit (or Finder) for anything else, the Windows menu would be a mix of Desktop names and document (or folder) names.

I can now create a stack of windows like what I want but they all appear in the desktop from which I run the app and I can only create them, so far, in batch mode, all at once. I have not yet gotten how to tell my app to add another window to the set.

I want to be able to create windows one at a time, changing Desktops each time, to get one window on each desktop. Right now, making them in batch mode, I have to move the windows manually, which is awkward and time consuming, but it lets me test the concept of using the app’s Windows menu to list the Desktops and switch between them.

To tell my app to add another window of a given name, I figure I need to use either AppleScript or the command line. If I use the command line, I will invoke another instance of the app, unless I make the app more complex. If I use AppleScript, I can tell the already running app to create a new window. But AppleScript requires it’s own complexity.

So far, the best tutorial that I have found about adding AppleScript to an app is your old “Scriptable Tasks“ tutorial. But it assumes I level of App-creation knowledge that I don’t have to be able to understand the steps and the intent. And simple example commands in it generate errors that I’m having trouble debugging. But I’m pushing forward with it because it’s the best I’ve found.

I don’t really have any more ideas for you, but if you’re using AppleScript, I strongly recommend getting the scrIpts working in isolation first and then putting them into an app.

1 Like

Hi Sarah,

I think you have misunderstood what I’m trying to do. I probably over explained it, forcing you to skim.

I am trying to add AppleScript capabilities to an app That I am creating in Xcode. So it’s not possible for me to test the AppleScript script first.

My app makes windows. When I start the app, depending on what I have coded, it can make one window or several. I want to be able to use AppleScript to tell my app to make a new window.

And then I want to tell it to make another. I want all of the windows that I make to be listed in the app’s Window menu.

It seems simple, but I am missing something key in the concepts. Because of that, I’m not asking the right questions or using the right search terms.

Thanks for trying.

Thanks for the more detailed explanation. I was looking at this the wrong way round.

I would say that the first thing you need is a function in your app that you can call to create a new window and set its title. Any new windows should appear in the Window menu without any further code.

Once that is working how you want it, then you can return to the problem of making that function accessible via AppleScript. My old tutorial should still mostly work, except I think you’ll have to add @objc to anything AppleScript needs access to.

I hope this provides some help.

Sarah

1 Like