Search results for

swiftui

16,633 results found

Post

Replies

Boosts

Views

Activity

joblinkapp's registerview mistake
I am working on a SwiftUI project using Core Data. I have an entity called AppleUser in my data model, with the following attributes: id (UUID), name (String), email (String), password (String), and createdAt (Date). All attributes are non-optional. I created the corresponding Core Data class files (AppleUser+CoreDataClass.swift and AppleUser+CoreDataProperties.swift) using Xcode’s automatic generation. I also have a PersistenceController that initializes the NSPersistentContainer with the model name JobLinkModel. When I try to save a new AppleUser object using: let user = AppleUser(context: viewContext) user.id = UUID() user.name = User1 user.email = ... user.password = password1 user.createdAt = Date()【The email is correctly formatted, but it has been replaced with “…” for privacy reasons】 try? viewContext.save() I get the following error in the console:Core Data save failed: Foundation._GenericObjCError.nilError, [:] User snapshot: [id: ..., name: User1, email: ..., password: ..., createdAt: ...]
3
0
137
Sep ’25
Reply to .presentationDetents not working on iOS 17
I've just experienced something similar to this with Xcode Version 26.0 (17A321) I don't have any other versions of Xcode I can try this with. Supplying .presentationDetents() with any value, e.g. .presentationDetents([.height(250)]) or .presentationDetents([.medium, .large]), does the following: iOS 17.5 Simulator: The sheet is not displayed at all, effectively freezing the app as there's no sheet displayed and no way to dismiss it. iOS 18.5 Simulator: The sheet is 250px tall. iOS 26.0 Simulator: The sheet is 250px tall. My current workaround is to do this: .sheet(isPresented: $showSheet) { if #available(iOS 18.0, *) { ChooseImageSheet(showSheet: $showSheet) .presentationDetents([.height(250)]) } else { ChooseImageSheet(showSheet: $showSheet) } } It's not elegant having to repeat some code without a modifier on it in this way. Also, this forces the sheet to use the .large detent, which fills the screen and isn't really appropriate for what I need to display in the sheet. Sadly, I can't provide a sample proje
Topic: UI Frameworks SubTopic: SwiftUI
Sep ’25
Reply to Liquid Glass Interaction Bug
Thanks for your reply. Yes, the issue is present in a minimal test project. Here is the full code to demonstrate the bug: import SwiftUI @main struct BugDemoApp: App { var body: some Scene { WindowGroup { NavigationStack { List { } .toolbar { ToolbarItem(placement: .bottomBar) { Button { } label: { Image(systemName: apple.logo) } } } } } } } This behavior is also visible in system apps, for example in Notes and Reminders.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Looking for advice on app architecture
I have an existing Mac app which has evolved through over twenty years of development. It is currently written in a mixture of C++ and Objective-C, with a bit of C and Swift in a few places. For a few years now, I have been tinkering with replacing the UI with SwiftUI. The model has been completely rewritten in Swift and works fine. After a few tries, no version has been working acceptably, so I'm thinking that I need to rethink the architecture. The UI consists of a window with a master-detail view. The detail view is what users spend most of their time with. It contains a lot of subviews, around 100 typically. Keyboard events affect the display, so I've had a dedicated data structure to hold the state that is needed for displaying all the subviews. Using Instruments, I see that the view seems to recreate the subviews three times per keyboard event, so I'm clearly doing something wrong. A second factor is that there are a couple of dozen commands that are applicable to the detail view, driven either
Topic: UI Frameworks SubTopic: SwiftUI Tags:
8
0
164
Sep ’25
Reply to Looking for advice on app architecture
I agree that SwiftUI is not the best to develop complex Mac apps. I have developed some, but they are iOS looking, not MacOS. So, for complex apps, I do prefer AppKit. I wonder if an app like Excel could be developed fully with SwiftUI. IMHO, no. But I would be pleased to be proved wrong.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to Looking for advice on app architecture
I agree that SwiftUI is not the best to develop complex Mac apps. I have developed some, but they are iOS looking, not MacOS. So, for complex apps, I do prefer AppKit. I wonder if an app like Excel could be developed fully with SwiftUI. IMHO, no. But I would be pleased to be proved wrong.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to Looking for advice on app architecture
I agree that SwiftUI is not the best to develop complex Mac apps. I have developed some, but they are iOS looking, not MacOS. So, for complex apps, I do prefer AppKit. I wonder if an app like Excel could be developed fully with SwiftUI. IMHO, no. But I would be pleased to be proved wrong.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to Looking for advice on app architecture
I've been able to develop pretty complex apps for Mac in SwiftUI, but in fact it is more iOS looking than genuine Mac app. In particular, I do not try to use menus. SwiftUI is great to rapidly develop an app (noting that full fledge Mac App with AppKit is pretty complex). But for sophisticated apps, I feel AppKit much more suited. I wonder if Excel could be developed fully in SwifUI. IMHO, I don't think so.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
SwiftUI - AsyncImage causing massive tmp folder?
So I have a perplexing situation. I'm loading multiple SwiftUI AsyncImages according to spec (see code below). For some reason, my 1MB app has over 400+ MBs of documents & data. When I view the app's container, I can see that it is caused by a massive number of the images as .tmp files in the tmp folder all starting with the name CFNetworkDownload. It seems that every time an image is loaded, it's stored in here, but does not delete. This makes the app get bigger every time it's opened. What can I do about this issue? Thanks so much! (P.S. I've tried to condense my code down as much as possible for readability, but there's a few files included because I'm not sure where the problem lies.) Main app Swift file: @main struct MyApp: App { let monitor = NWPathMonitor() @State private var isConnected = true var body: some Scene { monitor.pathUpdateHandler = { path in if path.status == .satisfied { if !isConnected { isConnected.toggle() } } else { if isConnected { isConnected.toggle() } } } let queue =
2
0
1.5k
Sep ’25
Reply to Incorrect color for inline navigation bar title when dark mode AND reduce transparency ON.
You can customize the title text color and the background color of the navigation bar like the following for a workaround. import SwiftUI struct ContentView: View { @Environment(.colorScheme) var colorScheme var body: some View { NavigationStack { VStack { Image(systemName: globe) .imageScale(.large) .foregroundStyle(.tint) } /* .navigationBarItems( trailing: Text(Trailing).foregroundStyle(.yellow) ) */ .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .principal) { Text(GGGGGGG GGGGGGG) .font(.title) .bold() .foregroundColor(colorScheme == .light ? .white : .black) } } .toolbarBackground(colorScheme == .light ? .black: .white, for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to Incorrect color for inline navigation bar title when dark mode AND reduce transparency ON.
You can customize the title text color and the background color of the navigation bar like the following for a workaround. import SwiftUI struct ContentView: View { @Environment(.colorScheme) var colorScheme var body: some View { NavigationStack { VStack { Image(systemName: globe) .imageScale(.large) .foregroundStyle(.tint) } /* .navigationBarItems( trailing: Text(Trailing).foregroundStyle(.yellow) ) */ .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .principal) { Text(GGGGGGG) .font(.title) .bold() .foregroundColor(colorScheme == .light ? .white : .black) } } .toolbarBackground(colorScheme == .light ? .black: .white, for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
virtual game controller + SwiftUI warning
Hi, I've just moved my SpriteKit-based game from UIView to SwiftUI + SpriteView and I'm getting this mesage Adding 'GCControllerView' as a subview of UIHostingController.view is not supported and may result in a broken view hierarchy. Add your view above UIHostingController.view in a common superview or insert it into your SwiftUI content in a UIViewRepresentable instead. Here's how I'm doing this struct ContentView: View { @State var alreadyStarted = false let initialScene = GKScene(fileNamed: StartScene)!.rootNode as! SKScene var body: some View { ZStack { SpriteView(scene: initialScene, transition: .crossFade(withDuration: 1), isPaused: false , preferredFramesPerSecond: 60) .edgesIgnoringSafeArea(.all) .onAppear { if !self.alreadyStarted { self.alreadyStarted.toggle() initialScene.scaleMode = .aspectFit } } VirtualControllerView() .onAppear { let virtualController = BTTSUtilities.shared.makeVirtualController() BTTSSharedData.shared.virtualGameController = virtualController BTTSSharedData.
1
0
339
Sep ’25