Post

Replies

Boosts

Views

Activity

ToolbarItem has a bug in XCode 15 beta 8.
When I run the following code on my iPad and select an item in the sidebar, the ToolbarItem button shows up, but when I go to the home screen and return to the app, the ToolbarItem button disappears. struct ContentView: View { @State var selection: Int? = nil var body: some View { NavigationSplitView { List(selection: $selection) { ForEach(0...10, id: \.self) { value in NavigationLink(value: value) { Text("\(value)") } } } } detail: { ZStack { Text("Select : \(selection ?? -1)") } .toolbar { ToolbarItem(placement: .topBarTrailing) { Button { } label: { Text("ToolbarItem") } } } } } }
1
0
600
Sep ’23
ColorPicker has a bug in XCode 15 beta 8.
ColorPicker has a bug in XCode 15 beta 8. There is an issue where ColorPicker pop-up window layout is pushed to the left. You cannot even select a color in the ColorPicker pop-up window where the problem occurred. After checking, it does not occur on most iPads and iPhones. For iPhone SE2 and SE3, problems occur with both the device and the simulator. XCode 15.0 beta 8 (15A5229m) iOS 17.0 (21A5326a)
2
0
636
Aug ’23
@Observable crashes in Xcode, iOS Beta 7 on iPad
If you update the code using @Observable, it works normally on macOS, but an error occurs on iPad. Simultaneous accesses to 0x60000300c9a0, but modification requires exclusive access. The first time I select it from the list, it works fine, but the second time I select it, an error occurs. original source code struct ContentView: View { @StateObject private var envProfile = ProfileEnvironment() var body: some View { NavigationSplitView { List(selection: $envProfile.selection) { NavigationLink("One", value: "1") NavigationLink("Two", value: "2") } } detail: { Text(envProfile.selection ?? "nil") } } } class ProfileEnvironment: ObservableObject { @Published var selection : String? } Updated code using @Observable struct ContentView: View { @State private var envProfile = ProfileEnvironment() var body: some View { NavigationSplitView { List(selection: $envProfile.selection) { NavigationLink("One", value: "1") NavigationLink("Two", value: "2") } } detail: { Text(envProfile.selection ?? "nil") } } } @Observable class ProfileEnvironment { var selection : String? }
3
0
758
Aug ’23
There is a problem that the selection value is initialized when NavigationSplitView operates on the iPad.
Run the attached source on the iPad. Rotate your iPad in landscape orientation. Select one of 1,2,3 from the list on the left. Press the Home button to exit to the home screen. You can check that the "selectedID" value is initialized after the app enters the background state. When I go back to the app I was running, the selected row in the list is cancelled. Proceed with the same action once more. In the second process, the "selectedID" value is not initialized. The "selectedID" value is always initialized on the first run. I would like to know how to deal with this problem. import SwiftUI struct ContentView: View { @Environment(\.scenePhase) var scenePhase @State var selectedID: UUID? let profiles = [Profile(name: "1"), Profile(name: "2"), Profile(name: "3")] var body: some View { NavigationSplitView { List(profiles, id: \.id, selection: $selectedID) { profile in NavigationLink(value: profile.id) { Text(profile.name) } } } detail: { Text(selectedID?.uuidString ?? "nil") } .task(id: selectedID) { print("Selection changed to \(selectedID?.uuidString ?? "nil")") } .onChange(of: scenePhase) { newPhase in if newPhase == .active { print("Active :", selectedID ?? "nil") } else if newPhase == .inactive { print("Inactive :", selectedID ?? "nil") } else if newPhase == .background { print("Background :", selectedID ?? "nil") } } } } struct Profile: Identifiable, Hashable { let id = UUID() let name: String }
0
0
470
May ’23
WidgetKit / SwiftUI Text Timer Bug. This has remained a bug for a very long time.
Normal behavior in apps and widgets : [.date, .time] Use "multilineTextAlignment" on widgets : [.relative, .offset, .timer] As of iOS 16.0 (20A5358a), ".timer" does not work in widgets and does not alignment. There was a problem that the Timer was not aligned in the widget for a long time. I thought this bug would be fixed someday, but one more bug was added. This is a really disappointing result. struct WZEntryView : View {   var entry: Provider.Entry   var body: some View {     VStack(alignment: .trailing) {       Text(entry.date, style: .date)       Text(entry.date, style: .time)               Text(entry.date, style: .relative)       Text(entry.date, style: .offset)       Text(entry.date, style: .timer) //<- not work on iOS 16.0 (20A5358a) widget     }     .multilineTextAlignment(.trailing) // Bypass bugs in widgets     .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)     .background(Color.gray)   } } [Test environment] macOS : 13.0 (22A5331f) XCode : 14.0 beta 6 (14A5294g) iOS : 16.0 (20A5358a)
9
13
3.9k
Aug ’22
Failed to build the scheme on Preview canvas
I am developing a multi-platform app. Added a package that imports UIKit to the project under development. Changed "Allow any platform" to "iOS" in the framework settings of the project. In the source using the library, "#if os(iOS)" is applied to iOS only. The project compiles without errors on iOS and macOS and runs normally. It works normally in the preview canvas of iOS. The preview canvas on macOS throws a UIKit error in the library. With just a few lines of code you can check this error. [Package] import UIKit <-------- public struct MyLibrary {   public private(set) var text = "Hello, World!"   public init() {   } } [Project] import SwiftUI #if os(iOS) <--------------- import MyLibrary #endif struct ContentView: View {   var body: some View {     VStack {       Image(systemName: "globe")         .imageScale(.large)         .foregroundColor(.accentColor)       Text("Hello, world!")     }   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } }
0
0
1.4k
Jul ’22
SwiftUI NavigationView Bug on iPad
Execute the code below in iPad landscape mode. Go to the home screen and launch another app. When you return to the app again, you can see that the layout of the left menu is wrong. This doesn't happen every time, but it does happen about 80% of the time. As a first aid, if you specify .frame(width: 320) in the List, the problem no longer occurs. Please let me know if you have a solution macOS : 12.1 Beta (21C5031d) XCode : Version 13.1 (13A1030d) iPad : 15.2 (19C5036e) struct ContentView: View {   var body: some View {     NavigationView {       List {         ForEach(1...9, id: \.self) { item in           NavigationLink("\(item)") {             Text("\(item)")           }         }       }     }   } }
0
0
600
Nov ’21
SwiftUI toolbar bug on Monterey
The code below works normally on macOS Big Sur. However, after compiling with Xcode 13 and running in Monterey, an error occurs. This is an issue with "toolbar". If I comment out the toolbar part of ProfileView, it works without error. What part is wrong? Or is it a bug in Xcode13? If the way you use the toolbar changes in the future, please let me know the correct way. PLATFORM AND VERSION macOS Monterey 12.0 beta (21A5506j) Xcode 13.0 beta 5 (13A5212g) STEPS TO REPRODUCE Run Xcode 13.0 beta 5 Create macOS project Paste the above code into ContentView & ProfileView. Run debug Error when selecting "Profile 1" from the list struct ContentView: View {     var body: some View {         NavigationView {             ScrollViewReader { scrollProxy in                 List {                     ForEach([1,2,3], id: .self) { id in                         NavigationLink("Profile (id)", destination: ProfileView())                     }                 }                 .navigationTitle("Profile List")                 .toolbar {                     ToolbarItemGroup(placement: .confirmationAction, content: {                         Button(action: {                             print("Settings...")                         }) {                             Image(systemName: "gearshape.fill")                         }                         Button(action: {                             NSApp.keyWindow?.firstResponder?.tryToPerform(#selector(NSSplitViewController.toggleSidebar(_:)), with: nil)                         }, label: {                             Image(systemName: "sidebar.left")                         })                     })                 }             }         }     } } struct ProfileView: View {     var body: some View {         ZStack {             VStack {                 Text("ProfileView")             }         }         .toolbar {             ToolbarItemGroup(placement: .confirmationAction, content: {                 Button("Save", action: {                     print("Save...")                 })             })         }     } }
0
0
589
Sep ’21