Post

Replies

Boosts

Views

Activity

Crash when triggering sheet presentation from a task
Given the following code, if line 17 isn't present there'll be a crash upon presenting the sheet. Since content shouldn't be nil at the time of presentation, why does this crash? import SwiftUI struct ContentView: View { @State private var isPresented = false @State private var content: String? @State private var startTask = false var body: some View { Text("Tap me") .onTapGesture { startTask = true } .task(id: startTask) { guard startTask else { return } startTask = false // <===== Crashes if removed content = "Some message" isPresented = true } .sheet(isPresented: $isPresented) { Text(content!) } } } iOS 16.4, Xcode 14.3.1
6
0
1k
Aug ’23
SwiftUI LibraryItem instances can produce unexpected results
When passing an empty closure to a LibraryItem's snippet parameter, unexpected extra text is added to the file when the item is dragged in from the Xcode library. Expected: .setAction { } Actual: .setAction /*@START_MENU_TOKEN@*/{ }/*@END_MENU_TOKEN@*/ Full code: import SwiftUI struct ContentView: View {   var body: some View {     MyView()   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } } struct MyView: View {   var action: (() -> Void)?       var body: some View {     Text("MyView")       .onTapGesture {         action?()       }   }       func setAction(_ action: @escaping () -> Void) -> MyView {     var copy = self     copy.action = action     return copy   } } struct LibraryContent: LibraryContentProvider {   func modifiers(base: MyView) -> [LibraryItem] {     [       LibraryItem(         base.setAction {                     },         title: "MyView - Set action"       )     ]   } } FB11936092 macOS 13.0.1 (22A400) Xcode 14.1 (14B47b)
0
0
688
Jan ’23
Settings app crashes on iOS 15 iPhone Simulator
The Settings app crashes on launch for me on the iOS 15 iPhone 15 Pro simulator. Version 15.0 (1015.2)
Replies
1
Boosts
1
Views
593
Activity
Oct ’23
Cannot get Xcode 15 structured logging to work
My problem is similar to this post but switching to an iOS 17 simulator does not fix the issue. As far as I know there should be no OS_ACTIVITY_DT_MODE set anywhere in my project but I'm not sure exactly where to check. I've tried in Beta 6 and 7 so far and I've set all of my minimums to iOS 17.
Replies
2
Boosts
0
Views
2.4k
Activity
Sep ’23
Crash when triggering sheet presentation from a task
Given the following code, if line 17 isn't present there'll be a crash upon presenting the sheet. Since content shouldn't be nil at the time of presentation, why does this crash? import SwiftUI struct ContentView: View { @State private var isPresented = false @State private var content: String? @State private var startTask = false var body: some View { Text("Tap me") .onTapGesture { startTask = true } .task(id: startTask) { guard startTask else { return } startTask = false // <===== Crashes if removed content = "Some message" isPresented = true } .sheet(isPresented: $isPresented) { Text(content!) } } } iOS 16.4, Xcode 14.3.1
Replies
6
Boosts
0
Views
1k
Activity
Aug ’23
SwiftUI LibraryItem instances can produce unexpected results
When passing an empty closure to a LibraryItem's snippet parameter, unexpected extra text is added to the file when the item is dragged in from the Xcode library. Expected: .setAction { } Actual: .setAction /*@START_MENU_TOKEN@*/{ }/*@END_MENU_TOKEN@*/ Full code: import SwiftUI struct ContentView: View {   var body: some View {     MyView()   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } } struct MyView: View {   var action: (() -> Void)?       var body: some View {     Text("MyView")       .onTapGesture {         action?()       }   }       func setAction(_ action: @escaping () -> Void) -> MyView {     var copy = self     copy.action = action     return copy   } } struct LibraryContent: LibraryContentProvider {   func modifiers(base: MyView) -> [LibraryItem] {     [       LibraryItem(         base.setAction {                     },         title: "MyView - Set action"       )     ]   } } FB11936092 macOS 13.0.1 (22A400) Xcode 14.1 (14B47b)
Replies
0
Boosts
0
Views
688
Activity
Jan ’23