Post

Replies

Boosts

Views

Activity

Reply to With regard to SwiftUI apps, what are the differences between an Xcode project with one iOS/macOS target using "Optimize Interface for Mac", and a project with separate iOS and macOS targets?
The "Optimize Interface for Mac" is an option for Catalyst. It allows you to build a more native Mac app, while still using Catalyst libraries (so UIKit). The separate macOS target will build a native Mac app, it uses AppKit APIs. Also, #if os(macOS) Settings { SettingsView() } #endif is only available on SwiftUI on AppKit, so you have to use the native macOS target in order to use this API. In my opinion, it always is better to use the native library and build native apps. Especially when you're building an app completely from scratch using SwiftUI, since so many APIs are shared between native SwiftUI on iOS and SwiftUI on Mac. P.S. Yeah, I do think the SwiftUI's TextEditor is quite limiting. Hopefully it will gain additional features next year. In the meanwhile, consider using NSTextView in NSViewRepresentable if you want to use the native SwiftUI on AppKit.
Jul ’20
Reply to SwiftUI + document based application problems
I came up with this crash in the original question last week. I found a quick fix that works for me. First, make an new file with an extension to the managed object (replace Note with your object name): extension Note {     class func swiftUIFetchRequest() -> NSFetchRequest<Note> {         let request = NSFetchRequest<Note>(entityName: "Note")         request.sortDescriptors = [] /* You can add custom sort descriptors here */         return request     } } Then, start using FetchRequest like this (again, replacing Note with your object name): @FetchRequest(fetchRequest: Note.swiftUIFetchRequest()) var allNotes: FetchedResults<Note> Let me know if it works for you. I think the entity initializer is a little bit broken in beta 1.
Jul ’20