Restore Window Size on MacCatalyst Apps

Sometimes its easier to just enable MacCatalyst on an iOS app to bring it to the Mac than to fiddle around with a dedicated Mac target or using the Mac version of SwiftUI. The drawback is that you don’t have access to AppKit but have to stick with UIKit / SwiftUI. So some quite useful features of AppKit are not available in MacCatalyst.

E.g. there is this nice AppKit construct to save and restore the window size and position between app launches:

But there is no equivalent in MacCatalyst since iOS apps don’t mess around with windows. In this post I’ll show how to achieve a similar behaviour in MacCatalyst.
Weiterlesen

Text Fields in Lists on macOS SwiftUI

Today’s post is a bug report. I’ve sent a developer feed back to Apple already but got no response yet. I don’t know exactly when Apple introduced this bug. But it may well be with the first release of macOS Ventura (13.0) and it’s still not fixed as of macOS 13.4.1.

At that time I’ve noticed that the text fields of one of my macOS Apps got an unintended left padding when included in a List. Here is a very simple test code to demonstrate the problem:

Weiterlesen

Syncing Reminders between Mac and Synology NAS

Well, for quite a while accessing reminders stored on my Synology NAS from my Mac was broken. Syncing with my iOS devices was no problem but on my Mac I could not see the folders and reminder items. Looking around in the internet showed that it was apparently problem since macOS 10.15. It seems that the Reminders client on the Mac does not accept the LetsEncrypt certificate on the Synology NAS.

Good news: With macOS 13 (Ventura) the sync is back on the Mac. No problems anymore neither on my Intel Mac nor on my Apple Silicon Mac.

Open the last used document on App startup

Did you ever want your app to open the last used document on startup? Well, that’s not too difficult on macOS. In your NSDocumentController subclass you have the array of recentDocumentURLs, and on startup you can try to open the first member if it exists.

But on iOS it’s a little bit more tricky. There is no such array as on macOS. So we have to mimic it by ourself.

This is a review of my post 2 years ago: UIDocumentBrowserViewController and External Storage

Weiterlesen

Creating a macOS document based app with SwiftUI and the new App protocol

Have you already tried to create a macOS document based app with SwiftUI and the new App protocol? Well, there are some problems to solve esp. if you want to use menus focused on the currently open document.

In the old app cycle with AppDelegate / SceneDelegate you still had to use the storyboard to define the menu items and link them to your methods in your document class derived from NSDocument. Enabling and disabling of the menu item according to the open documents was automatically managed by the frameworks.

That’s not the case in the new App protocol of SwiftUI anymore. Instead, you can define your menus and menu items quite nicely in your App struct conforming to the new App protocol but there is no automatic link to the current document in focus.

Weiterlesen