Post

Replies

Boosts

Views

Activity

UIDevice: Main actor-isolated class property 'current' can not be referenced from a non-isolated context
I have a Safari Web Extension for visionOS that reads from UIDevice.current.systemVersion in order to provide the OS version number back to the JavaScript context utilizing beginRequest(with:). When switching my project to use Swift 6, I received this obscure error: Main actor-isolated class property 'current' can not be referenced from a non-isolated context Class property declared here (UIKit.UIDevice) Add '@MainActor' to make instance method 'beginRequest(with:)' part of global actor 'MainActor' Adding @MainActor causes another issue (Main actor-isolated instance method 'beginRequest(with:)' cannot be used to satisfy nonisolated protocol requirement) which suggests adding @preconcurrency to NSExtensionRequestHandling which then breaks at Non-sendable type 'NSExtensionContext' in parameter of the protocol requirement satisfied by main actor-isolated instance method 'beginRequest(with:)' cannot cross actor boundary. What's the proper solution here? Here's a simplified snippet of my code: class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { func beginRequest(with context: NSExtensionContext) { // ... var systemVersionNumber = "" systemVersionNumber = UIDevice.current.systemVersion // ... } }
3
0
1.2k
Jun ’24
Opening an ics on iOS with an ATTENDEES property doesn't show any attendees
I am trying to create a simple online calendar where a user can create an event and schedule it on my calendar themselves. One of the options is to generate an .ics iCalendar file, which has me as an attendee. This works on macOS, but on iOS an "Attendees" line appears with 0 attendees (see screenshots below). I have tried all sorts of changes to the ATTENDEE property to no avail. Am I doing something wrong, or is this a limitation or bug on iOS? Tested on iOS 16. Here's the .ics contents: BEGIN:VCALENDAR PRODID:-//Wes.dev//WesCal//EN VERSION:2.0 CALSCALE:GREGORIAN METHOD:REQUEST BEGIN:VTIMEZONE TZID:America/New_York BEGIN:DAYLIGHT DTSTART:20070311T020000 RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3 TZNAME:EDT TZOFFSETFROM:-0500 TZOFFSETTO:-0400 END:DAYLIGHT BEGIN:STANDARD DTSTART:20071104T020000 RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11 TZNAME:EST TZOFFSETFROM:-0400 TZOFFSETTO:-0500 END:STANDARD END:VTIMEZONE BEGIN:VEVENT LAST-MODIFIED:20230322T095917 DTSTART;TZID=America/New_York:20230322T150000 DTEND;TZID=America/New_York:20230322T153000 DTSTAMP:20230322T095917 CREATED:20230322T095917 SUMMARY:Virtual Coffee TRANSP:OPAQUE SEQUENCE:0 ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP= true;CN=wes@example.com;X-NUM-GUESTS=0:mailto:wes@example.com UID:0.9585827676919431@example.org END:VEVENT END:VCALENDAR
1
0
799
Mar ’23
watchOS 9: Error getting network data status Error Domain=NSPOSIXErrorDomain Code=19 "Operation not supported by device"
I have an app that stopped working properly on watchOS 9, although it works perfectly fine on simulators. It uses WebSocket on an HTTPS server hosted on DigitalOcean behind an nginx proxy. The error I receive is "The Internet connection appears to be offline" but that does not make sense as other applications are able to use the internet properly on the device. Here are logs from Xcode running on device: 2022-09-17 16:22:40.409850-0400 Watch Mirror Watch App[354:11674] Connection 1: received failure notification 2022-09-17 16:22:40.413273-0400 Watch Mirror Watch App[354:11674] Connection 1: failed to connect 1:50, reason -1 2022-09-17 16:22:40.413318-0400 Watch Mirror Watch App[354:11674] Connection 1: encountered error(1:50) 2022-09-17 16:22:40.436009-0400 Watch Mirror Watch App[354:11677] Error getting network data status Error Domain=NSPOSIXErrorDomain Code=19 "Operation not supported by device" 2022-09-17 16:22:40.436497-0400 Watch Mirror Watch App[354:11677] Task <03D663EF-3CD1-4906-9343-C6B9DD112B11>.<1> HTTP load failed, 0/0 bytes (error code: -1009 [1:50]) 2022-09-17 16:22:40.449161-0400 Watch Mirror Watch App[354:11678] [] Error while receiving The Internet connection appears to be offline. 2022-09-17 16:22:40.449134-0400 Watch Mirror Watch App[354:11677] Task <03D663EF-3CD1-4906-9343-C6B9DD112B11>.<1> finished with error [-1009] Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={NSErrorFailingURLStringKey=[redacted], NSErrorFailingURLKey=[redacted] NSLocalizedDescription=The Internet connection appears to be offline., _NSURLErrorRelatedURLSessionTaskErrorKey=(     "LocalWebSocketTask <03D663EF-3CD1-4906-9343-C6B9DD112B11>.<1>" ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalWebSocketTask <03D663EF-3CD1-4906-9343-C6B9DD112B11>.<1>}
10
2
2.2k
Sep ’22
SwiftUI's userActivity(_:isActive:_:) doesn't work
I have a standalone watchOS 7 app and want to implement handoff for a URL the user can open on their browser. Nothing happens, and the update block is not even executed. Here's the relevant code, with the URL removed: import SwiftUI @main struct MyApp: App {   @SceneBuilder var body: some Scene {     WindowGroup {       NavigationView {         ContentView()       }         .userActivity(           "MyAppBundleId.watchkitapp.install-plugin",           isActive: true         ) { activity in           activity.isEligibleForHandoff = true           activity.webpageURL = URL(string: "[redacted]")       }     }   } } And the Info.plist for the WatchKit App: <key>NSUserActivityTypes</key> <array>     <string>MyAppBundleId.watchkitapp.install-plugin</string> </array> Am I doing anything wrong here?
1
0
1.1k
Aug ’20