Search results for

“swiftui”

17,106 results found

Post

Replies

Boosts

Views

Activity

Challenges using SwiftUI views inside an NSToolbarItem
I'm trying to use SwiftUI views inside an NSToolbarItem, and I feel like I'm fighting the system. The goal is to create custom toolbar controls. I don't want AppKit or SwiftUI to recognize that there's a SwiftUI view in the toolbar and then try to style it automatically, which is what I think is happening. Consider this hierarchy: - NSToolbar - NSToolbarItem - view -> MyCustomNSView - addSubview(NSHostingView) So CustomView is inside an NSHostingView, which is inside an NSView, which is assigned to the .view property of an NSToolbarItem. For a while, I struggled to get this working at all because SwiftUI's layout metrics appeared to be affected by safe area insets. SwiftUI's ignoresSafeArea() only seemed to move the problem around. For now, I've disabled full-size content view, which I don't really need anyway. However, a SwiftUI Button or Menu still doesn't behave or style the way I would expect when placed inside an NSToolbarItem. They don't seem to h
0
0
13
1h
SwiftData crash on new property (Could not cast...)
I have a small example where adding a new property to a persisted Codable struct causes a crash on launch instead of decoding the missing property using its default value. Steps Run this app once and press Insert Event to persist data: import SwiftUI import SwiftData @main struct SwiftDataCrash: App { var body: some Scene { WindowGroup { ContentView() } .modelContainer(for: Event.self) } } struct ContentView: View { @Environment(.modelContext) private var modelContext @Query private var events: [Event] var body: some View { VStack(spacing: 12) { Text(Events: (events.count)) Button(Insert Event) { let event = Event( recurrence: Recurrence( interval: 1 ) ) modelContext.insert(event) try? modelContext.save() } List(events) { event in Text(String(describing: event.recurrence)) } } .padding() } } @Model final class Event { var recurrence: Recurrence? = nil init(recurrence: Recurrence? = nil) { self.recurrence = recurrence } } struct Recurrence: Codable { var interval: Int // STEP 2: // After first run + i
0
0
33
12h
SwiftUI navigation bar button color changes depending on whether the root view is a ScrollView or VStack
I have a SwiftUI view inside a NavigationStack with a custom navigation bar background color. I want the navigation bar buttons to have a consistent color throughout the app. The issue is that the navigation bar button color changes depending on the first/root view in the body. When the root view is a ScrollView var body: some View { ScrollView { // content } .toolbarBackground(Color(red: 0.02, green: 0.27, blue: 0.13), for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar) .toolbarColorScheme(.dark, for: .navigationBar) } The navigation bar buttons appear white. However, if I replace the ScrollView with a VStack, while keeping the same modifiers, the navigation bar buttons appear black: var body: some View { VStack { // content } .toolbarBackground(Color(red: 0.02, green: 0.27, blue: 0.13), for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar) .toolbarColorScheme(.dark, for: .navigationBar) } The navigation bar buttons appear black. How can I make the navigation bar
0
0
97
21h
Changing systemImage value for Image, logs "fopen failed for data file".
I'm getting a log error and a slight delay in the UI when displaying a system image that changes at the end of a sequence. I'm using a ternary operator to determine the image; the fact that the image changes seem to be the issue, rather than the value itself. The issue only occurs for a newly installed app, and not when the app is rerun. (I'm using similar code to display an onboarding sequence after installation.) This happens on device (iphone 15 pro v25.6) and simulator (iphone 17 pro v25.6 and iphone 16 pro v18.5); xcode 26.5 (17F42). Console errors (device and iphone 17 simulator): fopen failed for data file: errno = 2 (No such file or directory) fopen failed for data file: errno = 2 (No such file or directory) Repro Code: import SwiftUI struct ContentView: View { // NOTE: error only occurs with new install. @State private var currentItem = 0 @State private var totalItems: Int = 4 var body: some View { VStack(spacing: 0) { Spacer() Text(totalItems: (totalItems)) TabView(selection: $currentItem)
1
0
37
1d
Unintended X-axis layout shift of a Button when sibling views animate and keyboard appears
Hello everyone, My name is Keita Tomizu. I'm a university student in Japan, currently developing a personal app. I am facing a tricky SwiftUI layout issue that I have spent hours trying to solve, and I would really appreciate your insights. Context & Goal: I have an overlay UI layer (zIndex(4)) consisting of a VStack that contains top and bottom HStacks. • In the top-left, there is a back button (<). • In the top-right and bottom-right, there are action buttons. • When a user taps the bottom-right button, a state isShowingAddView becomes true. This brings up a keyboard and a custom view in the background. • My Goal: When isShowingAddView is true, the right-side buttons should scale up and fade out (opacity to 0) in place. The top-left < button should remain completely static and anchored in its exact position. The Issue: When the state toggles, the < button unexpectedly shifts horizontally (along the X-axis) and sometimes behaves erratically, moving off-screen or losing its static positi
Topic: Design SubTopic: General
0
0
219
1d
Reply to SwiftUI Button with Image view label has smaller hit target
Thanks for the post. When you use a custom label: closure containing only an Image, SwiftUI sizes the button exactly to the intrinsic bounds of that image. If the image is small, like a standard SF Symbol, the minimum tap target size of 44x44. You can explicitly define a minimum frame for the image. However, when you expand the frame of an image, the empty space around it might not register taps. To fix this, apply .contentShape(Rectangle()) to tell SwiftUI that the entire bounding box should be interactive. In place code using your code above without using Xcode. Button { print(Button 3 tapped) } label: { Image(systemName: 3.square.fill) .frame(minWidth: 44, minHeight: 44) .contentShape(Rectangle()) } Albert
  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
1d
Reply to iOS app will not auto-sleep
Thanks for your post and congratulations on your SwiftUI app. Is the iPhone is plugged into your Mac and running through Xcode? The debugger alters the device's power management and prevents it from sleeping normally so you don't lose your debugging session. There are a few things that prevents the device for going to sleep that you may be using without knowing. On top of my head. If you are using the camera, you likely have an AVCaptureSession running, make sure the camera session is not actively running, because it assumes the user is framing a shot or recording. Even if the camera view is hidden behind another SwiftUI view or you navigated to a different tab, if you didn't explicitly tell the session to stop, it keeps running in the background and keeps the screen awake. Temporarily comment out the code that calls session.startRunning() and see if the phone sleeps. If it does, you know the camera is the issue. Another one, do a global search in your Xcode project for isIdleTimerDisabled S
2d
iOS app will not auto-sleep
Hello, I am working on a iOS app. This is my first big project in SwiftUI which it is going well besides I can not get my phone to auto-sleep/auto-lock when I am in the app. I am testing the app on my phone through xcode. As I am checking my energy report on idle it is saying Low and is almost to the very bottom, and my memory is idling at 90MB~115MB which seems very low. Now If I just leave the app it works right away even if I do not clear the app. I am wondering if anyone has any ideas on how to help me with this issue. I am using HealthKit, a Timer and the camera. I am making a workout app to give some information. I can also give more info if needed I will appreciate any help or ideas. I have tried to use AI to see if it can find any issues and it said that it didn't see anything wrong with my code that will cause it not to sleep now that is AI and it isn't perfect so I would appreciate any help.
1
0
35
2d
How to align a newly opened volumetric window with the center of an existing 2D window in visionOS?
I’m building a visionOS app that starts with a regular 2D SwiftUI window. From that 2D window, the user can enter a volumetric mode, where I want to open a large volumetric WindowGroup and have it appear centered around the same spatial position as the original 2D window. The volumetric window is physically large, roughly over 1m × 1m × 30cm. Because of that, placement behavior is very noticeable. My intended behavior is: User is interacting with a regular 2D window. User taps a button. A large volumetric window opens. The volumetric window appears in front of the user, ideally centered on or near the original 2D window’s position. The original 2D window is dismissed or replaced. My current workaround is to call openWindow(id:) for the volumetric window, then dismiss the original 2D window. This works in the sense that the volume is created, but its initial position is noticeably offset from the original 2D window. I also tried using defaultWindowPlacement to control the placement of the volumetric w
Topic: Design SubTopic: General Tags:
1
0
333
3d
FamilyActivityPicker missing search bar when embedded inline on iPad
When FamilyActivityPicker is used as an embedded view (not via the .familyActivityPicker sheet modifier), the search bar that normally appears at the bottom is not rendered on iPad. The same code shows the search bar correctly on iPhone. Environment Frameworks: SwiftUI, FamilyControls Device: iPad (reproduces on multiple models / iPadOS versions — 26.2, 26.5) iPhone: search bar appears as expected Usage The picker is placed directly inside a SwiftUI view hierarchy: import SwiftUI import FamilyControls struct ContentView: View { @State private var selection = FamilyActivitySelection() var body: some View { FamilyActivityPicker(selection: $selection) } } Expected A search field is visible at the bottom of the sheet (same as iPhone), allowing the user to search for apps/categories/websites. Actual On iPad, no search field is rendered. The picker only shows the category/app list. There is no way to search. Notes I would like the embedded FamilyActivityPicker to show the same search affo
1
0
130
3d
Reply to Custom Keyboard help
import UIKit import SwiftUI class KeyboardViewController: UIInputViewController { private var customHeightConstraint: NSLayoutConstraint? private let targetHeight: CGFloat = 450.0 private var systemDefaultHeight: CGFloat = 228.0 // Safe fallback override func viewDidLoad() { super.viewDidLoad() setupSwiftUIContent() // Initialize the constraint at default high priority to avoid layout warnings customHeightConstraint = view.heightAnchor.constraint(equalToConstant: targetHeight) customHeightConstraint?.priority = UILayoutPriority(999) customHeightConstraint?.isActive = true } override func viewIsAppearing(_ animated: Bool) { super.viewIsAppearing(animated) // Dynamically find iOS's system-encapsulated height constraint if let encapsulatedConstraint = view.constraints.first(where: { $0.firstItem === view && $0.firstAttribute == .height && $0 !== customHeightConstraint }) { systemDefaultHeight = encapsulatedConstraint.constant } // Apply the offset trick: target (450) - system default (22
Topic: UI Frameworks SubTopic: UIKit Tags:
4d
Reply to Custom Keyboard help
I was able to find a fix after 2 intense days troubleshooting this with Claude and GPT. Eventually Gemini solved the problem for me! Sending 2 messages due to 7k char limitation Problem: Custom iOS keyboard extension (UIInputViewController, SwiftUI content via UIHostingController). On every appearance, the keyboard window visibly resizes — the host app's UI reacts to it. Happens in every host app (Instagram, iMessage, etc.), not app-specific. The desired behaviour is what Bitmoji/Wispr do — keyboard just appears cleanly with no visible resize. What the logs show (captured via in-keyboard debug overlay — Xcode console doesn't work for extensions): Every single appearance, without exception, produces this sequence in viewDidLayoutSubviews: viewDidLoad: bounds.height = 0.0 viewDidLayoutSubviews: 844.0 viewDidLayoutSubviews: 844.0 (multiple passes) viewDidLayoutSubviews: 678.0 (multiple passes) viewDidLayoutSubviews: 450.0 ← our target viewDidAppear fires at 678, not 450. The final 678→450 snap happens a
Topic: UI Frameworks SubTopic: UIKit Tags:
4d
WeatherKit WeatherService fails to generate JWT with WDSJWTAuthenticator Code=2 despite valid entitlement/profile
Hi Apple Developer Support / WeatherKit team, I’m trying to use native iOS WeatherKit through WeatherService.shared in a SwiftUI app. Every request fails before weather data is returned because WeatherDaemon cannot generate the WeatherKit JWT. I am not using the REST API or manually generating a JWT. This is the native Swift WeatherKit API. import WeatherKit import CoreLocation let current = try await WeatherService.shared.weather( for: CLLocation(latitude: 25.76, longitude: -80.19), including: .current ) I also tested the same pattern used in Apple’s sample project, “Fetching weather forecasts with WeatherKit,” which calls: WeatherService.shared.weather(for: location, including: .current) The error I get is: Failed to generate jwt token for: com.apple.weatherkit.authservice with error: Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 (null) Encountered an error when fetching weather data subset; error=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors 2 Error Domain=W
2
0
145
5d
ControlCenter blocks a MenuBarExtra item due to foreign trackedApplications entry
I am seeing a reproducible issue with macOS ControlCenter's per-app menu bar tracking state in a SwiftUI MenuBarExtra app. On launch the app creates its menu bar status item. ControlCenter then reads group.com.apple.controlcenter / trackedApplications, moves the app's status item host to the blocked list, sends NSStatusItemChangeVisibilityAction with visibility=0, and the app terminates because its only status item is removed. Two observations: Changing only the bundle identifier makes the menu bar item appear normally. In trackedApplications, the affected app has its own entry with isAllowed: true; a separate entry for another app has isAllowed: false, and that disallowed foreign entry's menuItemLocations contained an entry referencing the affected app. Removing only the affected app's reference from the other app's disallowed entry fixed the issue: the app launched normally, and ControlCenter no longer sent visibility=0. ControlCenter appears to associate one app's menu item identity with another a
Topic: UI Frameworks SubTopic: SwiftUI Tags:
0
0
215
5d
Gesture causing AGGraphGetValue
I have a custom UIGestureRecognizerRepresentable that causes a crash. Only happens about once a week, and that’s with about a thousand times it gets invoked. But it’s persistent and annoying when it happens. The code looks like func handleUIGestureRecognizerAction(_ recognizer: Recognizer, context: Context) { let startLocation = context.converter.convert(globalPoint: recognizer.startLocation, to: coorinateSpace) coorinateSpace is set in init and has crashed on .global, .local, and .named(foo) The convert function gets caught in a AGGraphGetValue loop before finally failing. It has happened while attached to the debugger, but there is not any more information than is in the logs. I don’t even know why it would invoke AttributeGraph in the first place. Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libsystem_kernel.dylib 0x23aedd1d0 __pthread_kill + 8 1 libsystem_pthread.dylib 0x1eb0cf7dc pthread_kill + 268 2 libsystem_c.dylib 0x197a89c98 abort + 148 3 AttributeGraph 0x1befffef0 AG::pr
Topic: UI Frameworks SubTopic: SwiftUI
0
0
170
6d
Challenges using SwiftUI views inside an NSToolbarItem
I'm trying to use SwiftUI views inside an NSToolbarItem, and I feel like I'm fighting the system. The goal is to create custom toolbar controls. I don't want AppKit or SwiftUI to recognize that there's a SwiftUI view in the toolbar and then try to style it automatically, which is what I think is happening. Consider this hierarchy: - NSToolbar - NSToolbarItem - view -> MyCustomNSView - addSubview(NSHostingView) So CustomView is inside an NSHostingView, which is inside an NSView, which is assigned to the .view property of an NSToolbarItem. For a while, I struggled to get this working at all because SwiftUI's layout metrics appeared to be affected by safe area insets. SwiftUI's ignoresSafeArea() only seemed to move the problem around. For now, I've disabled full-size content view, which I don't really need anyway. However, a SwiftUI Button or Menu still doesn't behave or style the way I would expect when placed inside an NSToolbarItem. They don't seem to h
Replies
0
Boosts
0
Views
13
Activity
1h
SwiftData crash on new property (Could not cast...)
I have a small example where adding a new property to a persisted Codable struct causes a crash on launch instead of decoding the missing property using its default value. Steps Run this app once and press Insert Event to persist data: import SwiftUI import SwiftData @main struct SwiftDataCrash: App { var body: some Scene { WindowGroup { ContentView() } .modelContainer(for: Event.self) } } struct ContentView: View { @Environment(.modelContext) private var modelContext @Query private var events: [Event] var body: some View { VStack(spacing: 12) { Text(Events: (events.count)) Button(Insert Event) { let event = Event( recurrence: Recurrence( interval: 1 ) ) modelContext.insert(event) try? modelContext.save() } List(events) { event in Text(String(describing: event.recurrence)) } } .padding() } } @Model final class Event { var recurrence: Recurrence? = nil init(recurrence: Recurrence? = nil) { self.recurrence = recurrence } } struct Recurrence: Codable { var interval: Int // STEP 2: // After first run + i
Replies
0
Boosts
0
Views
33
Activity
12h
SwiftUI navigation bar button color changes depending on whether the root view is a ScrollView or VStack
I have a SwiftUI view inside a NavigationStack with a custom navigation bar background color. I want the navigation bar buttons to have a consistent color throughout the app. The issue is that the navigation bar button color changes depending on the first/root view in the body. When the root view is a ScrollView var body: some View { ScrollView { // content } .toolbarBackground(Color(red: 0.02, green: 0.27, blue: 0.13), for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar) .toolbarColorScheme(.dark, for: .navigationBar) } The navigation bar buttons appear white. However, if I replace the ScrollView with a VStack, while keeping the same modifiers, the navigation bar buttons appear black: var body: some View { VStack { // content } .toolbarBackground(Color(red: 0.02, green: 0.27, blue: 0.13), for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar) .toolbarColorScheme(.dark, for: .navigationBar) } The navigation bar buttons appear black. How can I make the navigation bar
Replies
0
Boosts
0
Views
97
Activity
21h
Changing systemImage value for Image, logs "fopen failed for data file".
I'm getting a log error and a slight delay in the UI when displaying a system image that changes at the end of a sequence. I'm using a ternary operator to determine the image; the fact that the image changes seem to be the issue, rather than the value itself. The issue only occurs for a newly installed app, and not when the app is rerun. (I'm using similar code to display an onboarding sequence after installation.) This happens on device (iphone 15 pro v25.6) and simulator (iphone 17 pro v25.6 and iphone 16 pro v18.5); xcode 26.5 (17F42). Console errors (device and iphone 17 simulator): fopen failed for data file: errno = 2 (No such file or directory) fopen failed for data file: errno = 2 (No such file or directory) Repro Code: import SwiftUI struct ContentView: View { // NOTE: error only occurs with new install. @State private var currentItem = 0 @State private var totalItems: Int = 4 var body: some View { VStack(spacing: 0) { Spacer() Text(totalItems: (totalItems)) TabView(selection: $currentItem)
Replies
1
Boosts
0
Views
37
Activity
1d
Unintended X-axis layout shift of a Button when sibling views animate and keyboard appears
Hello everyone, My name is Keita Tomizu. I'm a university student in Japan, currently developing a personal app. I am facing a tricky SwiftUI layout issue that I have spent hours trying to solve, and I would really appreciate your insights. Context & Goal: I have an overlay UI layer (zIndex(4)) consisting of a VStack that contains top and bottom HStacks. • In the top-left, there is a back button (<). • In the top-right and bottom-right, there are action buttons. • When a user taps the bottom-right button, a state isShowingAddView becomes true. This brings up a keyboard and a custom view in the background. • My Goal: When isShowingAddView is true, the right-side buttons should scale up and fade out (opacity to 0) in place. The top-left < button should remain completely static and anchored in its exact position. The Issue: When the state toggles, the < button unexpectedly shifts horizontally (along the X-axis) and sometimes behaves erratically, moving off-screen or losing its static positi
Topic: Design SubTopic: General
Replies
0
Boosts
0
Views
219
Activity
1d
Reply to SwiftUI Button with Image view label has smaller hit target
Thanks for the post. When you use a custom label: closure containing only an Image, SwiftUI sizes the button exactly to the intrinsic bounds of that image. If the image is small, like a standard SF Symbol, the minimum tap target size of 44x44. You can explicitly define a minimum frame for the image. However, when you expand the frame of an image, the empty space around it might not register taps. To fix this, apply .contentShape(Rectangle()) to tell SwiftUI that the entire bounding box should be interactive. In place code using your code above without using Xcode. Button { print(Button 3 tapped) } label: { Image(systemName: 3.square.fill) .frame(minWidth: 44, minHeight: 44) .contentShape(Rectangle()) } Albert
  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
1d
Reply to iOS app will not auto-sleep
Thanks for your post and congratulations on your SwiftUI app. Is the iPhone is plugged into your Mac and running through Xcode? The debugger alters the device's power management and prevents it from sleeping normally so you don't lose your debugging session. There are a few things that prevents the device for going to sleep that you may be using without knowing. On top of my head. If you are using the camera, you likely have an AVCaptureSession running, make sure the camera session is not actively running, because it assumes the user is framing a shot or recording. Even if the camera view is hidden behind another SwiftUI view or you navigated to a different tab, if you didn't explicitly tell the session to stop, it keeps running in the background and keeps the screen awake. Temporarily comment out the code that calls session.startRunning() and see if the phone sleeps. If it does, you know the camera is the issue. Another one, do a global search in your Xcode project for isIdleTimerDisabled S
Replies
Boosts
Views
Activity
2d
iOS app will not auto-sleep
Hello, I am working on a iOS app. This is my first big project in SwiftUI which it is going well besides I can not get my phone to auto-sleep/auto-lock when I am in the app. I am testing the app on my phone through xcode. As I am checking my energy report on idle it is saying Low and is almost to the very bottom, and my memory is idling at 90MB~115MB which seems very low. Now If I just leave the app it works right away even if I do not clear the app. I am wondering if anyone has any ideas on how to help me with this issue. I am using HealthKit, a Timer and the camera. I am making a workout app to give some information. I can also give more info if needed I will appreciate any help or ideas. I have tried to use AI to see if it can find any issues and it said that it didn't see anything wrong with my code that will cause it not to sleep now that is AI and it isn't perfect so I would appreciate any help.
Replies
1
Boosts
0
Views
35
Activity
2d
How to align a newly opened volumetric window with the center of an existing 2D window in visionOS?
I’m building a visionOS app that starts with a regular 2D SwiftUI window. From that 2D window, the user can enter a volumetric mode, where I want to open a large volumetric WindowGroup and have it appear centered around the same spatial position as the original 2D window. The volumetric window is physically large, roughly over 1m × 1m × 30cm. Because of that, placement behavior is very noticeable. My intended behavior is: User is interacting with a regular 2D window. User taps a button. A large volumetric window opens. The volumetric window appears in front of the user, ideally centered on or near the original 2D window’s position. The original 2D window is dismissed or replaced. My current workaround is to call openWindow(id:) for the volumetric window, then dismiss the original 2D window. This works in the sense that the volume is created, but its initial position is noticeably offset from the original 2D window. I also tried using defaultWindowPlacement to control the placement of the volumetric w
Topic: Design SubTopic: General Tags:
Replies
1
Boosts
0
Views
333
Activity
3d
FamilyActivityPicker missing search bar when embedded inline on iPad
When FamilyActivityPicker is used as an embedded view (not via the .familyActivityPicker sheet modifier), the search bar that normally appears at the bottom is not rendered on iPad. The same code shows the search bar correctly on iPhone. Environment Frameworks: SwiftUI, FamilyControls Device: iPad (reproduces on multiple models / iPadOS versions — 26.2, 26.5) iPhone: search bar appears as expected Usage The picker is placed directly inside a SwiftUI view hierarchy: import SwiftUI import FamilyControls struct ContentView: View { @State private var selection = FamilyActivitySelection() var body: some View { FamilyActivityPicker(selection: $selection) } } Expected A search field is visible at the bottom of the sheet (same as iPhone), allowing the user to search for apps/categories/websites. Actual On iPad, no search field is rendered. The picker only shows the category/app list. There is no way to search. Notes I would like the embedded FamilyActivityPicker to show the same search affo
Replies
1
Boosts
0
Views
130
Activity
3d
Reply to Custom Keyboard help
import UIKit import SwiftUI class KeyboardViewController: UIInputViewController { private var customHeightConstraint: NSLayoutConstraint? private let targetHeight: CGFloat = 450.0 private var systemDefaultHeight: CGFloat = 228.0 // Safe fallback override func viewDidLoad() { super.viewDidLoad() setupSwiftUIContent() // Initialize the constraint at default high priority to avoid layout warnings customHeightConstraint = view.heightAnchor.constraint(equalToConstant: targetHeight) customHeightConstraint?.priority = UILayoutPriority(999) customHeightConstraint?.isActive = true } override func viewIsAppearing(_ animated: Bool) { super.viewIsAppearing(animated) // Dynamically find iOS's system-encapsulated height constraint if let encapsulatedConstraint = view.constraints.first(where: { $0.firstItem === view && $0.firstAttribute == .height && $0 !== customHeightConstraint }) { systemDefaultHeight = encapsulatedConstraint.constant } // Apply the offset trick: target (450) - system default (22
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
4d
Reply to Custom Keyboard help
I was able to find a fix after 2 intense days troubleshooting this with Claude and GPT. Eventually Gemini solved the problem for me! Sending 2 messages due to 7k char limitation Problem: Custom iOS keyboard extension (UIInputViewController, SwiftUI content via UIHostingController). On every appearance, the keyboard window visibly resizes — the host app's UI reacts to it. Happens in every host app (Instagram, iMessage, etc.), not app-specific. The desired behaviour is what Bitmoji/Wispr do — keyboard just appears cleanly with no visible resize. What the logs show (captured via in-keyboard debug overlay — Xcode console doesn't work for extensions): Every single appearance, without exception, produces this sequence in viewDidLayoutSubviews: viewDidLoad: bounds.height = 0.0 viewDidLayoutSubviews: 844.0 viewDidLayoutSubviews: 844.0 (multiple passes) viewDidLayoutSubviews: 678.0 (multiple passes) viewDidLayoutSubviews: 450.0 ← our target viewDidAppear fires at 678, not 450. The final 678→450 snap happens a
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
4d
WeatherKit WeatherService fails to generate JWT with WDSJWTAuthenticator Code=2 despite valid entitlement/profile
Hi Apple Developer Support / WeatherKit team, I’m trying to use native iOS WeatherKit through WeatherService.shared in a SwiftUI app. Every request fails before weather data is returned because WeatherDaemon cannot generate the WeatherKit JWT. I am not using the REST API or manually generating a JWT. This is the native Swift WeatherKit API. import WeatherKit import CoreLocation let current = try await WeatherService.shared.weather( for: CLLocation(latitude: 25.76, longitude: -80.19), including: .current ) I also tested the same pattern used in Apple’s sample project, “Fetching weather forecasts with WeatherKit,” which calls: WeatherService.shared.weather(for: location, including: .current) The error I get is: Failed to generate jwt token for: com.apple.weatherkit.authservice with error: Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 (null) Encountered an error when fetching weather data subset; error=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors 2 Error Domain=W
Replies
2
Boosts
0
Views
145
Activity
5d
ControlCenter blocks a MenuBarExtra item due to foreign trackedApplications entry
I am seeing a reproducible issue with macOS ControlCenter's per-app menu bar tracking state in a SwiftUI MenuBarExtra app. On launch the app creates its menu bar status item. ControlCenter then reads group.com.apple.controlcenter / trackedApplications, moves the app's status item host to the blocked list, sends NSStatusItemChangeVisibilityAction with visibility=0, and the app terminates because its only status item is removed. Two observations: Changing only the bundle identifier makes the menu bar item appear normally. In trackedApplications, the affected app has its own entry with isAllowed: true; a separate entry for another app has isAllowed: false, and that disallowed foreign entry's menuItemLocations contained an entry referencing the affected app. Removing only the affected app's reference from the other app's disallowed entry fixed the issue: the app launched normally, and ControlCenter no longer sent visibility=0. ControlCenter appears to associate one app's menu item identity with another a
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
0
Boosts
0
Views
215
Activity
5d
Gesture causing AGGraphGetValue
I have a custom UIGestureRecognizerRepresentable that causes a crash. Only happens about once a week, and that’s with about a thousand times it gets invoked. But it’s persistent and annoying when it happens. The code looks like func handleUIGestureRecognizerAction(_ recognizer: Recognizer, context: Context) { let startLocation = context.converter.convert(globalPoint: recognizer.startLocation, to: coorinateSpace) coorinateSpace is set in init and has crashed on .global, .local, and .named(foo) The convert function gets caught in a AGGraphGetValue loop before finally failing. It has happened while attached to the debugger, but there is not any more information than is in the logs. I don’t even know why it would invoke AttributeGraph in the first place. Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libsystem_kernel.dylib 0x23aedd1d0 __pthread_kill + 8 1 libsystem_pthread.dylib 0x1eb0cf7dc pthread_kill + 268 2 libsystem_c.dylib 0x197a89c98 abort + 148 3 AttributeGraph 0x1befffef0 AG::pr
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
170
Activity
6d