Search results for

swiftui

16,633 results found

Post

Replies

Boosts

Views

Activity

I need help
I am trying to learn to write swift. I am very proficient MS VB, which I have been using for almost 20 years. The Book I am learning from is: SwiftUI for Masterminds by J.D Gauchat. I have got to chapter 7 with no problem. The exercise I am having a problem with Listing 7-5. The error I am getting is: Thread 1: Fatal error: No Observable object of type ApplicationData found. A View.environmentObject(_:) for ApplicationData may be missing as an ancestor of this view. I have spent the last 2 days rechecking my code. The MacBook I am using was purchased in May this year, is 16 inch, Max 4 pro chip with 128 G Ram I am seeking help here as a last resort, I understand everybody is busy. The main issue I have with the book is the author assumes you know as much as he does. As I stated, I am very proficient MS VB Firstly Is the SwiftUI for Masterminds to advanced for? Secondly What is the best book to start with and then move on to SwiftUI for Masterminds. Thirdly I thank you for reading my
Topic: UI Frameworks SubTopic: SwiftUI
3
0
163
Sep ’25
Learn to write SwiftUI
I am trying to learn to write swift. I am very proficient MS VB, which I have been using for almost 20 years. The Book I am learning from is: SwiftUI for Masterminds. I have got to chapter 7 with no problem. The exercise I am having a problem with Listing 7-5. The error I am getting is: Thread 1: Fatal error: No Observable object of type ApplicationData found. A View.environmentObject(_:) for ApplicationData may be missing as an ancestor of this view. I have spent the last 2 days rechecking my code. The MacBook I am using was purchased in May this year, is 16 in, M4 Max chip, 128 G ram. Firstly I want to thank you for reading this post. Secondly is there a better book to learn SwiftUI. Regards Terry Harrison
Topic: UI Frameworks SubTopic: SwiftUI
1
0
431
Sep ’25
tabViewBottomAccessory inline functionality missing?
Summary As presented in the SwiftUI WWDC video, the new tabViewBottomAccessory should allow for unique contents for .inline. This is what was presented as being used for the Apple Music miniplayer. However, the functionality seems to be either missing or unintuitive. As seen in the photos attached, not only does .inline functionality not seem to do anything, but the inline accessory also has misaligned elements that cannot be fixed by conditionally modifying the contents. Build Target iOS 26.0 Details This problem recurs on physical devices, simulators, and Xcode previews. Here is a view I've constructed for use as a tabViewBottomAccessory: struct FitnessToolbarAccessory: View { @Environment(.tabViewBottomAccessoryPlacement) var placement var body: some View { if (placement == .inline) { Text(hello) } else { HStack { HStack { Image(systemName: dumbbell.fill) VStack(alignment: .leading) { Text(Active Workout) Text(Push Day - Chest) .font(.system(size: 13)) } Spacer() Image(systemName: pause.fill) } .p
2
0
209
Sep ’25
CloudKit and SwiftData not syncing on MacOS
I have a simple app that uses SwiftUI and SwiftData to maintain a database. The app runs on multiple iPhones and iPads and correctly synchronises across those platforms. So I am correct setting Background Modes and Remote Notifications. I have also correctly setup my Model Configuration and ModelContainer (Otherwise I would expect syncing to fail completely). The problem arises when I run on a Mac (M1 or M3) either using Mac Designed for iPad or Mac Catalyst. This can be debugging in Xcode or running the built app. Then the app does not reflect changes made in the iPhone or iPad apps unless I follow a specific sequence. Leave the app, (e.g click on a Finder window), then come back to the app (i.e click on the app again). Now the app will show the changes made on the iPhone/iPad. It looks like the app on the Mac is not processing remote notifications when in the background - it only performs them when the app has just become active. It also looks like the Mac is not performing these sync operations wh
3
0
775
Sep ’25
I need to access information about the apps installed in my system
How do I get the FileManager in SwiftUI to read information about the apps in the Applications folder. Lots of apps do it, Alfred, Raycast. It's not something that is unheard of, and yet I cannot for the life of me, using every kind of guide on the internet figure out how to achieve this. Please somebody help, this is legitimately affecting my mental health.
1
0
166
Sep ’25
Reply to Popovers are broken on macCatalyst
Apple expect us to create bland list apps only; anything beyond that breaks down. SwiftUI is broken from a design point of view, use the old trusty UIKit, designed before Tim, and call it a day. As you can see, Apple doesn't care, no one has answered you for a week.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to Private UIKit code causes a crash when the app moves to the background on iOS 26
CollectionView is a complex API, while I was developing my wrapper for SwiftUI I had similar bug. I don't have a tendency to jump right away on Apple and prefer investigate and see whether I am not doing something that's expected of me. (I work on AppKit app but this is applicable to UIKit as well) I inserted the code below into AppDelegate. This allowed me to catch the moment where NSArray.objectAtIndex returns nil, and after little research it turned out that my layout wasn't implementing some callback and wasn't returning attributes for the item at that index, because I didn't understand well enough the purpose of that callback (delegate method). After implementing that method it worked. I don't remember specific details but this is the code you can modify to swizzle NSArray.objectAtIndex, it has to be done in applicationWillFinishLaunching. // MARK: - swizzling -[NSMutableArray insertObject:atIndex:] #if false func swizzle_NSMutableArray() { let oldClass: AnyClass! = NSClassFromString(__NSArrayM)
Topic: UI Frameworks SubTopic: UIKit Tags:
Sep ’25
joblinkapp's registerview problem
我正在使用 Core Data 开发一个 SwiftUI 项目。我的数据模型中有一个名为 AppleUser 的实体,具有以下属性:id (UUID)、name (String)、email (String)、password (String) 和 createdAt (Date)。所有属性都是非可选的。 我使用 Xcode 的自动生成创建了相应的 Core Data 类文件(AppleUser+CoreDataClass.swift 和 AppleUser+CoreDataProperties.swift)。我还有一个 PersistenceController,它使用模型名称 JobLinkModel 初始化 NSPersistentContainer。 当我尝试使用以下方法保存新的 AppleUser 对象时: 让用户 = AppleUser(上下文:viewContext) user.id = UUID() user.name = “用户 1” user.email = “...” user.password = “密码 1” user.createdAt = Date()【电子邮件格式正确,但已替换为“...”出于隐私原因】 尝试?viewContext.save() 我在控制台中收到以下错误:核心数据保存失败:Foundation._GenericObjCError.nilError, [:] 用户快照: [“id”: ..., “name”: “User1”, “email”: “...”, “password”: “...”, “createdAt”: ...] 所有字段都有有效值,核心数据模型似乎正确。我还尝试过: • 检查 NSPersistentContainer(name:) 中的模型名称是否与 .xcdatamodeld 文件 (JobLinkModel) 匹配 • 确保正确设置 AppleUser 实体类、模块和 Codegen(类定义、当前产品模块) • 删除重复或旧的 AppleUser 类文件 • 清理 Xcode 构建文件夹并从模拟器中删除应用程序 • 对上下文使用 @Environment(.managedObjectContext) 尽管如此,在保存新的 AppleUser 对象时,我仍然会收到 _GenericObjCError.nilError。 我想
2
0
120
Sep ’25
Default document-based app menu items missing icons
In a new document-based macOS app project created in Xcode, some of the default system-provided menu commands appear without their standard icons in the menu bar. Steps to Reproduce: 1. In Xcode, create a new macOS “Document App” project (using Swift/SwiftUI or AppKit template). 2. Build and run the project. 3. Open the app’s main menu bar and examine the default items such as New Document, Open…, Save, Duplicate, etc. Expected Results: System-provided menu items (e.g. Open…, Save, Duplicate) should display their standard SF Symbol–based icons automatically, as they do in TextEdit and other system apps. Actual Results: Some of these menu items display only text, with no icon namely: Services Open Recent Revert To Share This happens even though the items are the system-managed defaults generated by the document-based app template. Notes: • No code modifications were made — this occurs in a fresh, unedited template project. • Behavior seen on macOS 26.0 (25A354). • Xcode Version 26.0 (17A324) used.
1
0
168
Sep ’25
Reply to joblinkapp's registerview mistake
Your post doesn't describe where viewContext is from, but my best guess is that viewContext in your code isn't valid. As an example, if you use SwiftUI and grab viewContext from the environment, it can be that you haven't injected the managed object context as an environment to your SwiftUI view hierarchy. If you can provide a minimal project that demonstrates the issue, I'd probably have a better idea. For how how to create (and save) a Core Data object, see Handling Different Data Types in Core Data. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Sep ’25
Novice SwiftUI developer can't make network call
I'm trying to use URL structure in the foundation framework and it is failing to build, returning a nil value. Could it be trying to evaluate the string I am giving it as a variable for its argument at build time? Is there a test argument I can give URL to see if it can return a non-nil value? (of URL type)?
Topic: Design SubTopic: General
17
0
1.6k
Sep ’25
Using Glass in SwiftUI Crashes with Missing Weak Symbol
My Xcode project fails to run with the following crash log any time I use a new SwiftUI symbol such as ConcentricRectangle or .glassEffect. I've tried using the legacy linker to no avail. It compiles perfectly fine, and I've tried targeting just macOS 26 also to no avail. This is a macOS project that's compiled just fine for years and compiles and runs on macOS going back to 13.0. Failed to look up symbolic reference at 0x118e743cd - offset 1916987 - symbol symbolic _____y_____y_____y_____yAAyAAy_____y__________G_____G_____yAFGGSg_ACyAAy_____y_____SSG_____y_____SgGG______tGSgACyAAyAAy_____ATG_____G_AVtGSgtGGAQySbGG______Qo_ 7SwiftUI4ViewPAAE11glassEffect_2inQrAA5GlassV_qd__tAA5ShapeRd__lFQO AA15ModifiedContentV AA6VStackV AA05TupleC0V AA01_hC0V AA9RectangleV AA5ColorV AA12_FrameLayoutV AA24_BackgroundStyleModifierV AA6IDViewV 8[ ]012EditorTabBarC0V AA022_EnvironmentKeyWritingS0V A_0W0C AA7DividerV A_0w4JumpyC0V AA08_PaddingP0V AA07DefaultgeH0V in /Users/[ ]/Library/Developer/Xcode/DerivedData/[ ]-grf
5
0
319
Sep ’25
Reply to Failed to find a DDI
Many thanks to all of you for the help! @haptic, @jsequoia, @pax26 I was finally able to solve it. I’m incredibly grateful, since it was extremely important and I was running out of time. The final solution was to completely delete Xcode via Terminal and then re-download it. The package remains intact, and now everything runs perfectly. It also works on the devices now. I only had to replace import SwiftCoreUI with import SwiftUI, otherwise everything runs really smoothly.
Sep ’25
RealityKit - How to change camera target in response of a touch event?
Hello, I’m porting my UIKit/SceneKit app to SwiftUI/RealityKit and I’m wondering how to change the camera target programmatically. I created a simple scene in Reality Composer Pro with two spheres. My goal is straightforward: when the user taps a sphere, the camera should look at it as the main target. Following Apple’s videos, I implemented the .gesture modifier and it is printing the tapped sphere correctly, but updating my targetEntity state doesn’t change anything, so the camera won't update its target. Is there a way to access the scene content at that level? Or what else should I do? Here’s my current code implementation: Thanks!
1
0
242
Sep ’25
Reply to RealityKit - How to change camera target in response of a touch event?
Hello @Daniele Citi , thank you for your question! Your code above looks correct, in that you are updating the targetEntity in response to the gesture, but I don't see any SwiftUI code that would observe the change to targetEntity. Try adding an update block to your view that observes changes to this variable, like this: .update { content in content.cameraTarget = targetEntity } Let me know if that helps! Thank you!
Topic: Graphics & Games SubTopic: RealityKit Tags:
Sep ’25