Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Mac App Crashing with Illegal Instructions

I have made a Swift App for MacOS 15 under XCode 16.3, which runs fine. I also want to run it under the previous MacOS 14. Unfortunately it crashes without even starting up (it does not even reach the first log output statement on the first view)

The crash reason is

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 4 Illegal instruction: 4
Terminating Process:   exc handler [2970]

I have set the miminium deployment to MacOS 14.0 but to no effect. The XCode machine is a MacOS 15.4 on Arm M3 and the target machine is MacOS 14.7.5 on Intel (MacBook Air)

I think it might be related to the compiler and linker settings.

For some reason, people seem to think they need to make an entirely new thread to add a line of text or correct a spelling mistake...

You have ONE HOUR from posting something to edit it. If you're outside that window, and the edit is necessary - your edit above really wasn't necessary - just reply to your own post.

There is no reason to create duplicate posts within an hour. It just clutters up the forums.

After some digging I found out that SwiftData is causing the problem. More concrete relationships

I have a class Account with has (optional) categories

@Relationship(deleteRule: .cascade, inverse: \Category.account)
var _categories: [Category]?
var categories: [Category] {
    self._categories ?? []
}

in the class Category I have the a simple account variable

var account: Account

The application crahses when I use the following init function in Account (at the last line)

    init(id: Int,
         income: Bool,
         location: String,
         maintainance: Bool,
         special: Bool,
         taxRate: Float,
         tenant: String,
         title: String) {
        self.id = id
        self.income = income
        self.location = location
        self.maintainance = maintainance
        self.special = special
        self.taxRate = taxRate
        self.tenant = tenant
        self.title = title
self._categories = []
    }

or when I use those lines

        // category not found, so create one
        let category: Category = Category(title: categoryName, account: self)
        if self._categories == nil {
            self._categories = [category]
        }

Maybe the underscore in the property name is causing an issue, could you try with a different name? And shouldn't that property be private so you can only access the relationship in one way?

Mac App Crashing with Illegal Instructions
 
 
Q