Post

Replies

Boosts

Views

Activity

Reply to SwiftUI window aspect ratio
Another solution that seems to work is to use NSViewControllerRepresentable to create a NSViewController based view. When viewDidAppear is called, you can set the NSWindowDelegate to self to receive window events and set the aspect ratio.
Topic: UI Frameworks SubTopic: AppKit Tags:
Dec ’22
Reply to ShareLink + FileRepresentation: Can't Save to Files
I would tend to think that the issue is with the try! statement. write(to:) can throw, which is probably the case here. Force unwrapping probably causes the crash. Here's an example of an implementation that works (at least on my end): static var transferRepresentation: some TransferRepresentation {         FileRepresentation(contentType: .myArchive) { archive in             let url = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true).appendingPathComponent(archive.fileName)             let res = try JSONEncoder().encode(archive)             try res.write(to: url, options: .atomicWrite)             return SentTransferredFile(url)         } importing: { received in             let data = try Data(contentsOf: received.file)             return try JSONDecoder().decode(MyArchive.self, from: data)         }     }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’22
Reply to Set filename to use for "Save to Files" with ShareLink?
Ok so I made some progress. Turns out I was using com.public.data instead of public.data in Exported Type Identifier > Conform To. So now saving to files will use the proper file extension (.cararchive) I've set in Exported Type Identifier > Extensions. However, the filename defaults to what I've set in Exported Type Identifier > Description. I'd like to set a default name myself as the one used by iOS makes no sense.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’22
Reply to Set filename to use for "Save to Files" with ShareLink?
Additionally, if I use my custom type instead of .json when exporting, the "Save to Files" doesn't even show up, even if I did set the export type in the info.plist file. extension UTType {     static var car: UTType = UTType(exportedAs: "com.acme.cararchive") } extension Car: Transferable {     static var transferRepresentation: some TransferRepresentation {         DataRepresentation(contentType: .car) { archive in             try JSONEncoder().encode(archive)         } importing: { data in             try JSONDecoder().decode(Car.self, from: data)         }     } } fefe
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’22
Reply to ShareLink and DataRepresentation
My I add that using FileRepresentation instead of DataRepresentation has the same effect: extension FuelUpsArchive: Transferable {     static var transferRepresentation: some TransferRepresentation {         FileRepresentation(contentType: .commaSeparatedText) {             SentTransferredFile($0.file)         } importing: { received in             try! self.init(csvData: Data())         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to DNSServiceNATPortMappingCreate now just fails on macOS 12
I don't remember their name, sorry. I spoke to an engineer during a WWDC lab and they told me that. But the real issue here is why such a serious regression never got fixed? Do you understand that this bug may render some apps useless? This may impact tens of thousands of users. What do we tell our users when their app stops working when they upgrade to Monterey? In my case I was able to go around the problem but this may not be the case for others.
Topic: App & System Services SubTopic: Core OS Tags:
Oct ’21
Reply to iOS: List selection is reset to nil when app is sent to background
Apple folks: FB11876396
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to SwiftUI window aspect ratio
Another solution that seems to work is to use NSViewControllerRepresentable to create a NSViewController based view. When viewDidAppear is called, you can set the NSWindowDelegate to self to receive window events and set the aspect ratio.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Files.app "On My ..." folder URL?
Turns out all you need to do is set LSSupportsOpeningDocumentsInPlace to true in your app's info.plist
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to ShareLink + FileRepresentation: Can't Save to Files
I would tend to think that the issue is with the try! statement. write(to:) can throw, which is probably the case here. Force unwrapping probably causes the crash. Here's an example of an implementation that works (at least on my end): static var transferRepresentation: some TransferRepresentation {         FileRepresentation(contentType: .myArchive) { archive in             let url = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true).appendingPathComponent(archive.fileName)             let res = try JSONEncoder().encode(archive)             try res.write(to: url, options: .atomicWrite)             return SentTransferredFile(url)         } importing: { received in             let data = try Data(contentsOf: received.file)             return try JSONDecoder().decode(MyArchive.self, from: data)         }     }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to Set filename to use for "Save to Files" with ShareLink?
Ok so I made some progress. Turns out I was using com.public.data instead of public.data in Exported Type Identifier > Conform To. So now saving to files will use the proper file extension (.cararchive) I've set in Exported Type Identifier > Extensions. However, the filename defaults to what I've set in Exported Type Identifier > Description. I'd like to set a default name myself as the one used by iOS makes no sense.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to Set filename to use for "Save to Files" with ShareLink?
Additionally, if I use my custom type instead of .json when exporting, the "Save to Files" doesn't even show up, even if I did set the export type in the info.plist file. extension UTType {     static var car: UTType = UTType(exportedAs: "com.acme.cararchive") } extension Car: Transferable {     static var transferRepresentation: some TransferRepresentation {         DataRepresentation(contentType: .car) { archive in             try JSONEncoder().encode(archive)         } importing: { data in             try JSONDecoder().decode(Car.self, from: data)         }     } } fefe
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to Scrollable Plot Area
Would like to know as well!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’22
Reply to ShareLink and DataRepresentation
My I add that using FileRepresentation instead of DataRepresentation has the same effect: extension FuelUpsArchive: Transferable {     static var transferRepresentation: some TransferRepresentation {         FileRepresentation(contentType: .commaSeparatedText) {             SentTransferredFile($0.file)         } importing: { received in             try! self.init(csvData: Data())         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to ShareLink and PDFDocument
I'd like to know how to share a file as well!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to It says: "There are still screenshot uploads in progress." when submit a new build
I have this issue as well. Not greyed-out screenshots. Fun times.
Replies
Boosts
Views
Activity
May ’22
Reply to Swift UI on iOS 14 not assigning new object to @State property
Duped radar FB9959325
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to Swift UI on iOS 14 not assigning new object to @State property
Still occurs in 13.3 :(
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to DNSServiceNATPortMappingCreate now just fails on macOS 12
Received an email from an Apple engineer and apparently this has been fixed in the latest macOS 12.1 beta.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to DNSServiceNATPortMappingCreate now just fails on macOS 12
Still not fixed in macOS 12.1 beta 1. I guess it's now unofficially deprecated. Can't wait for macOS 13 and see which other APIs get the same treatment.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to DNSServiceNATPortMappingCreate now just fails on macOS 12
I don't remember their name, sorry. I spoke to an engineer during a WWDC lab and they told me that. But the real issue here is why such a serious regression never got fixed? Do you understand that this bug may render some apps useless? This may impact tens of thousands of users. What do we tell our users when their app stops working when they upgrade to Monterey? In my case I was able to go around the problem but this may not be the case for others.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Oct ’21