Xcode SwiftUI Preview Tips

Loved by some, hated by many developers — is the SwiftUI preview. I was also in the latter camp to be honest, until recently.

Here are some things you can do to enjoy your SwiftUI previews again.

When you get an error, tap on the error and read it carefully, often it gives a hint. For example, you have been changing code left and right, then you went to this certain view, and you activated the preview pane with Option+Command+Enter — and getting an error.

Make sure before activating a preview canvas, that your code builds and if not, then fix the error and try again.

If you have done this and you still get an error, make sure you don’t have another tab open with a preview active for another target, close those and try again.

If that also fails you can try to clear the preview cache with this terminal command, I made an alias in .zprofile called simprevdel.

Compiler flag PREVIEW

You can add the PREVIEW compiler flag to use it as a compiler directive to load preview mock data.

Don’t forget to inject the EnvironmentObject model in the Preview View.

Enjoy your previews!

Automate your Xcode workflow / Dev tools with keyboard shortcuts


As developers, we start and switch a lot between common developer applications each day. You can buy some external hardware keyboards to achieve this, like for example with these USB Mini 3-Key Keypad, or the HUION Keydial, 9-Keys USB Mini Keypad, Programming Macro Pad. They work fine but you must always pack them in your bag when going to your workspace, but make sure before purchasing them, that they have macOS software drivers.

macOS Shortcuts

Personally I have the Huion, and use it for general Xcode keyboard shortcuts — like show / hide panes, delete current line, Run, Stop, etc, and to save keys I use macOS Shortcuts to launch applications like Xcode.

To achieve this do the following:

  1. open Shortcuts
  2. tap on the + in the title bar
  3. In the categories tab on the right, select Open App, and drag it on the canvas
  4. Click on App, to select Xcode
  5. Click on the info circle top right > Add keyboard shortcut > Control+Option+Command+x
  6. If you see on the canvas, Receive input from, deselect all
  7. Tap on the default name in the title: Open App, to change it to Open Xcode, and you can optionally assign an icon, but this is not really needed.
  8. Now comes the confusing part, there is no save, you just close this window with the red x
  9. Close Shortcuts
  10. Test by tapping Control+Option+Command+x

Other Dev tools

Now you can repeat this process for your most common developer tools like SourceTree, Interactful, Slack, enjoy!

SwiftUI autocomplete tricks


There are some view properties which you use a lot and are difficult to type like:


here you type .font [ENTER] -> this makes .font(), you have to cursor back into the brackets to type .cap[ENTER]

This you can achieve faster by typing .fontcaption[ENTER], or .fonttitle[ENTER]


You probably know already the properties trick to type the first two characters of the properties to get them preselected like so typing .framewihe[ENTER]:

If you only want one of those sub properties you can type directly


Xcode tip: Fix misplaced compiler directives like #if os(iOS)

When developing for multiple Apple platforms you can use compiler directives to customize properties for each OS, so you can use one View for multiple platforms. However Xcode aligns them in the code but not at the beginning of each line. There is a simple trick to auto align them all at once in a View by deleting the closing bracket of the View and adding it back.

Before delete:

After delete/adding of last bracket at line 128.

Recover your old Pixelmator version in macOS Sonoma

I’m a long term Pixelmator user, it has supported me very well during the times I’ve been developing and needed some image trickery.

Until recent it would not start anymore — after I upgraded to macOS Sonoma 14.x. I found out that the product has been revamped to Pixelmator Pro now, but I didn’t want to pay the license again, I’ve one for my current version.

After some long searches in the inter webs fora, I found a reasonable solution.

  1. Open Terminal
  2. cd ~/Library/Containers
  3. rm -rf com.pixelmatorteam*

Now the app starts again at least, and it saved me another 60 Euros. I’ve still one issue with gradients, when I open the gradients tool, the app crashes, and I’ve to type the terminal commands again to get it booting again. But so far I can live with that. Somewhere along the way I need to purchase a new license I know, but until then I’m happy to have it back for basic image manipulation and icon creation.

Xcode tip – rename

When you start developing an app, you don’t often know yet what the real name of your app will be, even you think you know. What do I mean by that?

Well, say you call your app TrainSleeper. You create the new app like this in Xcode and all is fine. Once you create the app in App Store Connect, it might shout at you that someone else owns this name and you cannot use it. You start searching for an app with this name in the store to see it, but it does not exist. This is because you can add an app with a certain name but never publish it. That name stays locked to the person who did this.

Anyway we need a lot of renaming during each development cycle, there is nothing to be ashamed about, it’s a very common task.

For this reason I added a keyboard shortcut to rename.

Give the rename menu function a shortcut.

Go to Settings with CMD + ,

Go to the Key Bindings tab

In filter type rename

In the key column after the rename word press all the keys you want, I selected;


Why so many keys? Well Xcode has many shortcuts, this avoids conflict with other shortcuts

GP Forecast – Immersive weather race seasonGP

Are you a real racing fan? Do you want to experience the thrill of wet races in immersive VR? Do you want to stay updated on the latest standings, documents, and votes? Do you want to learn more about the cars, the scoring, and the tires? If you answered yes to any of these questions, then this app is for you!

GP Forecast is the ultimate app for racing enthusiasts. With this app, you can:

  • Watch the weather conditions of each race in stunning VR. Feel the raindrops on your face, hear the thunder in your ears in spacial audio, and see the lightning in your eyes. Wet races are more exciting and unpredictable, so you will never get bored of following the weather each race.
  • Get hourly weather forecasts for each race location. Plan your viewing schedule accordingly and never miss a moment of action.
  • See the drivers and constructors standings. Find out who is leading the championship, who is chasing them, and who is falling behind. You can also see the points breakdown for each race and each driver.
  • Preview the track in details with DRS points, and check on the map where the race is located.
  • Access the official race documents, such as the race director’s notes, the stewards’ decisions, the technical regulations, and the sporting regulations. Learn about the rules and regulations that govern the sport and how they are enforced.
  • Vote for the driver of the day after each race. Show your support and appreciation for your favorite driver and see how other fans voted. You can also see the results of previous votes and the reasons behind them.
  • Learn more about the cars, the scoring, and the tires. If you are new to racing or want to refresh your knowledge, this app will help you understand the basics and the details of the sport. You can see how the cars work, how the scoring system works, and how the tires affect the performance and strategy.

It supports the following immersive weather conditions with accompanying spacial audio:

  • Clouds
  • Rain
  • Drizzle
  • Heavy rain
  • Thunder
  • Sleet
  • Hail
  • Fog
  • Snow
  • Sun
  • Moon
  • Wind in three different forces: breeze, wind and storm (Spacial Audio only)

GP Forecast is the app that every race fan needs. Download it today and enjoy the best of high speed racing!

Get it here: https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=6476766627

To get support please contact us by email at 7redbits@gmail.com.

Cannot start iBooks error

Today I was breaking my head on the fact that Books or iBooks like it used to be called, did not want to start. This happens once in a while on my Mac, with much frustration. Most posts in Apple Forums suggest deleting cookies and files in Containers and Preferences folders in your Library, like the BKAgenent folder.

What fixed it for me was to check or uncheck and reboot: System Preferences > iCloud > iCloud Drive Options to make sure that Books is checked.