AlarmMetadata struct

How can AlarmMetadata be implemented?

I have referenced the sample code from "Scheduling an alarm with AlarmKit" and used the following:

import AlarmKit

struct CookingData: AlarmMetadata {
    let createdAt: Date
    /* other properties */

    init() {
        self.createdAt = Date()
        /* other properties here */
    }
}

But it always has the following errors:

Main actor-isolated conformance of 'CookingData' to 'Decodable' cannot satisfy conformance requirement for a 'Sendable' type parameter of 'Self'

Type 'CookingData' does not conform to protocol 'AlarmMetadata'.

However in the sample App, this error is not there.

Any other guidance on AlarmMetadata protocol besides the documentation?

Answered by tylermack02 in 844128022

I was having the exact same issue, and I found a fix for it.

In the project settings, I went to Build Settings -> Swift Compiler - Concurrency -> Default Actor Isolation

I was only able to get it to work with this set to nonisolated, which is what the sample project also has this set to.

Accepted Answer

I was having the exact same issue, and I found a fix for it.

In the project settings, I went to Build Settings -> Swift Compiler - Concurrency -> Default Actor Isolation

I was only able to get it to work with this set to nonisolated, which is what the sample project also has this set to.

Thanks! Just tested and that’s likely the fix. Or adding nonisolated to the struct works if the Default Actor Isolation is main actor.

AlarmMetadata struct
 
 
Q