When I toggle a panel like navigationsidebar, I get a message in the console. I guess it's not a big issue, but is there a way to fix this message? because it appears in every project.
Unable to open mach-O at path: /AppleInternal/Library/BuildRoots/d187757d-b9a3-11ef-83e5-aabfac210453/Library/Caches/com.apple.xbs/Binaries/RenderBox/install/TempContent/Root/System/Library/PrivateFrameworks/RenderBox.framework/Versions/A/Resources/default.metallib Error:2
Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi! I'm seeing some weird animation issues building the Food Truck sample application.^1 I'm running from macOS 15.4 and Xcode 16.3. I'm building the Food Truck application for macOS. I'm not focusing on iOS for now.
The FoodTruckModel adds new Order values with an animation:
// FoodTruckModel.swift
withAnimation(.spring(response: 0.4, dampingFraction: 1)) {
self.orders.append(orderGenerator.generateOrder(number: orders.count + 1, date: .now, generator: &generator))
}
This then animates the OrdersTable when new Order values are added.
Here is a small change to OrdersTable:
// OrdersTable.swift
- @State private var sortOrder = [KeyPathComparator(\Order.status, order: .reverse)]
+ @State private var sortOrder = [KeyPathComparator(\Order.creationDate, order: .reverse)]
Running the app now inserts new Order values at the top.
The problem is I seem to be seeing some weird animation issues here. It seems that as soon as the new Order comes in there is some kind of weird glitch where it appears as if part the animation is coming from the side instead of down from the top:
What's then more weird is that if I seem to affect the state of the Table in any way then the next Order comes in with perfect animation.
Scrolling the Table fixes the animation.
Changing the creationData sort order from reverse to forward and back to reverse fixes the animation.
Any ideas? Is there something about how the Food Truck product is built that would cause this to happen? Is this an underlying issue in the SwiftUI infra?
I have a few crash report from TestFlight with this context and nothing else. No symbols of my application.
Crash report is attached.
crashlog.crash
It crashes at 16H25 (local time paris) and a few minutes after (8) I see the same user doing task in background (they download data with a particular URL in BGtasks) with a Delay that is consistant with a background wait of 5 or 7 minutes.
I have no more information on this crash and by the way Xcode refuses to load it and shows an error. ( I did a report via Xcode for this).
iPhone16ProMax
通过[UIScreen mainScreen].bounds.size获取屏幕宽高
使用XCode15获取屏幕宽高为430 * 930
使用XCode16获取屏幕宽高为440 * 956
这是为什么?
We've seen a spike in crashes on iOS 18.4 across both iPhone & iPad. We can't reproduce it, but it looks like it happens when the app goes into the background.
Crash Log
I'm implementing a Map with user location customization in SwiftUI using iOS 17+ MapKit APIs. When using the selection parameter with Map, the default blue dot user location becomes tappable but shows an empty annotation view. However, using UserAnnotation makes the location marker non-interactive.
My code structure:
import SwiftUI
import MapKit
struct UserAnnotationSample: View {
@State private var position: MapCameraPosition = .userLocation(fallback: .automatic)
@State private var selectedItem: MapSelection<MKMapItem>?
var body: some View {
Map(position: $position, selection: $selectedItem) {
// UserAnnotation()
}
.mapControls {
MapUserLocationButton()
}
}
}
Key questions:
How can I replace the empty annotation view with a custom avatar when tapping the user location?
Is there a way to make UserAnnotation interactive with selection?
Should I use tag modifier for custom annotations? What's the proper way to associate selections?
When a parent view is selected for the detail pane of a NavigationSplitView subviews appear as expected but not with the dimensions set by .frame on the subview.
Toggling the flag works as expected, appearing the subview with the idealWidth. I persist the flag in a SwiftData @Model class so that on restart and first appearance of the parent view the Right View subview presence is as it was left. The problem is that the .frame size is ignored, apparently. No manner of programatic view refresh seems to trigger a resize to the preferred values, only toggling the flag.
Is there a better way to handle a collapsing subview in an HSplitView? Why is the .frame not respected?
In this example I've added the else clause so HSplitView always has two views with .frame settings but the result is the same without it.
VStack {
HSplitView {
VStack {
Text("left view")
}
.frame(
minWidth: 100,
idealWidth: .infinity,
maxWidth: .infinity,
maxHeight: .infinity
)
if documentSettings.nwIsPieChartShowing {
VStack {
Text("right view")
}
.frame(
minWidth: 100,
idealWidth: 200,
maxWidth: .infinity,
maxHeight: .infinity
)
}
else {
Text("")
.frame(
minWidth: 0,
idealWidth: 0,
maxWidth: 0,
maxHeight: .infinity
)
}
}
HStack {
Button("Right View",
systemImage: { documentSettings.nwIsPieChartShowing ? "chart.pie.fill" : "chart.pie"}(),
action: { documentSettings.nwIsPieChartShowing.toggle() }
)
}
}
}
}
MacOS Sequoia 15.3.1, Xcode 16.2
Hello.
I'm building an iOS application that builds a framework named Design.framework using Xcode 16.1. When I launch my application on iOS 17.X, i get the following runtime error
dyld[47899]: Library not loaded: /System/Library/Frameworks/SwiftUICore.framework/SwiftUICore
Referenced from: <E625A246-E36B-351A-B077-CC38BAB5E07B> /Users/v/Library/Developer/Xcode/DerivedData/iScribd-bexojbdreldwkvbpzioqueldnvng/Build/Products/Debug_AppStore-iphonesimulator/Design.framework/Design
Reason: tried: '/Users/v/Library/Developer/Xcode/DerivedData/iScribd-bexojbdreldwkvbpzioqueldnvng/Build/Products/Debug_AppStore-watchsimulator/SwiftUICore.framework/SwiftUICore' (no such file), '/Users/v/Library/Developer/Xcode/DerivedData/iScribd-bexojbdreldwkvbpzioqueldnvng/Build/Products/Debug_AppStore-iphonesimulator/SwiftUICore.framework/SwiftUICore' (no such file), '/Users/v/Library/Developer/Xcode/DerivedData/iScribd-bexojbdreldwkvbpzioqueldnvng/Build/Products/Debug_AppStore-watchsimulator/PackageFrameworks/SwiftUICore.framework/SwiftUICore' (no such file), '/Users/v/Library/Developer/Xcode/DerivedData/iScribd-bexojbdreldwkvbpzioqueldnvng/Build/Products/Debug_AppStore-iphonesimulator/PackageFrameworks/SwiftUICore.framework/SwiftUICore' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21C62/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/SwiftUICore.framework/SwiftUICore' (no such file), '/System/Library/Frameworks/SwiftUICore.framework/SwiftUICore' (no such file, not in dyld cache), '/Library/Developer/CoreSimulator/Volumes/iOS_21C62/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/SwiftUICore.framework/SwiftUICore' (no such file)
This error does not happen on iOS 18+. When i run dyld_info Design.framework/Design, i see that there is indeed a dependency on SwiftUICore.framework
Design.framework/Design [arm64]:
-platform:
platform minOS sdk
iOS-simulator 16.0 18.1
-uuid:
09880F25-DC86-3D8E-BCAE-1A283508D879
-segments:
load-offset segment section sect-size seg-size max-prot init-prot
0x00000000 __TEXT 416KB r.x
0x00000000 __TEXT 416KB r.x
0x0000543C __text 355508
0x0005C0F0 __stubs 3168
0x0005CD50 __objc_methlist 32
0x0005CD70 __const 8296
0x0005EDD8 __swift5_typeref 15820
0x00062BB0 __cstring 6885
0x00064698 __constg_swiftt 2804
0x0006518C __swift5_builtin 40
0x000651C0 __swift5_reflstr 2952
0x00065D48 __swift5_assocty 816
0x00066078 __objc_methname 299
0x000661A4 __swift5_proto 368
0x00066314 __swift5_types 280
0x0006642C __swift5_fieldmd 3688
0x00067294 __swift5_protos 8
0x0006729C __swift5_capture 244
0x00067390 __unwind_info 2296
0x00067C88 __eh_frame 888
0x00068000 __DATA_CONST 16KB rw.
0x00068000 __DATA_CONST 16KB rw.
0x00068000 __got 3704
0x00068E78 __const 6864
0x0006A948 __objc_classlist 40
0x0006A970 __objc_imageinfo 8
0x0006C000 __DATA 32KB rw.
0x0006C000 __DATA 32KB rw.
0x0006C000 __objc_const 792
0x0006C318 __objc_selrefs 96
0x0006C378 __objc_classrefs 48
0x0006C3A8 __objc_data 208
0x0006C478 __data 4136
0x0006D4A0 __bss 12784
0x00070690 __common 4592
-linked_dylibs:
attributes load path
@rpath/CommonTools.framework/CommonTools
/System/Library/Frameworks/Foundation.framework/Foundation
/usr/lib/libobjc.A.dylib
/usr/lib/libSystem.B.dylib
/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics
/System/Library/Frameworks/CoreText.framework/CoreText
weak-link /System/Library/Frameworks/DeveloperToolsSupport.framework/DeveloperToolsSupport
/System/Library/Frameworks/SwiftUI.framework/SwiftUI
/System/Library/Frameworks/SwiftUICore.framework/SwiftUICore
/System/Library/Frameworks/UIKit.framework/UIKit
/usr/lib/swift/libswiftCore.dylib
weak-link /usr/lib/swift/libswiftCoreAudio.dylib
/usr/lib/swift/libswiftCoreFoundation.dylib
weak-link /usr/lib/swift/libswiftCoreImage.dylib
weak-link /usr/lib/swift/libswiftCoreMedia.dylib
weak-link /usr/lib/swift/libswiftDarwin.dylib
weak-link /usr/lib/swift/libswiftDataDetection.dylib
weak-link /usr/lib/swift/libswiftDispatch.dylib
weak-link /usr/lib/swift/libswiftFileProvider.dylib
weak-link /usr/lib/swift/libswiftMetal.dylib
weak-link /usr/lib/swift/libswiftOSLog.dylib
/usr/lib/swift/libswiftObjectiveC.dylib
weak-link /usr/lib/swift/libswiftQuartzCore.dylib
weak-link /usr/lib/swift/libswiftSpatial.dylib
weak-link /usr/lib/swift/libswiftUniformTypeIdentifiers.dylib
weak-link /usr/lib/swift/libswiftXPC.dylib
/usr/lib/swift/libswift_Concurrency.dylib
weak-link /usr/lib/swift/libswiftos.dylib
weak-link /usr/lib/swift/libswiftsimd.dylib
weak-link /usr/lib/swift/libswiftUIKit.dylib
I can add a -weak_framework SwiftUICore to "Other Linker Flags" in my Design.framework Build Settings, and that will solve my problem, but I'd like to know what prompts my Design.framework to depend on SwiftUICore despite having a minimum set to iOS 16? And how am I supposed to handle devices prior to iOS 18 which do not have this library? is adding the linker flag the right way forward?
Topic:
UI Frameworks
SubTopic:
SwiftUI
Hi everyone,
I'm encountering a persistent build error in a SwiftUI iOS app and I'm running out of ideas.
Setup:
My ContentView uses two @EnvironmentObjects (GameViewModel, SettingsStore). The GameViewModel has an AppState enum (.welcome, .setup, .game). The ContentView body uses a switch viewModel.currentAppState (wrapped in a Group) to display one of three different views (WelcomeView, SetupView, GameView). Navigation between states is triggered by changing viewModel.currentAppState within withAnimation blocks in the respective subviews.
Problem:
I consistently get the build error 'buildExpression' is unavailable: this expression does not conform to 'View' pointing to the lines inside the .setup and .game cases of the switch statement in ContentView.
Code (ContentView.swift - Simplified Test Version that STILL fails):
// Zweck: Steuert die Hauptnavigation basierend auf AppState
// KORRIGIERTE VERSION OHNE .animation(...) am Ende
import SwiftUI
struct ContentView: View {
// Zugriff auf das ViewModel, um den AppState zu lesen
@EnvironmentObject var viewModel: GameViewModel
// SettingsStore wird von untergeordneten Views benötigt
@EnvironmentObject var settingsStore: SettingsStore
var body: some View {
// Optional: Group um das switch-Statement, kann manchmal helfen (kannst du auch weglassen)
Group {
// Wechsle die Ansicht basierend auf viewModel.currentAppState
switch viewModel.currentAppState {
case .welcome:
WelcomeView()
// EnvironmentObjects an WelcomeView übergeben
.environmentObject(viewModel)
.environmentObject(settingsStore)
// Übergangsanimation
.transition(.opacity)
case .setup:
SetupView()
// EnvironmentObjects an SetupView übergeben
.environmentObject(viewModel)
.environmentObject(settingsStore)
// Übergangsanimation
.transition(.asymmetric(insertion: .move(edge: .trailing), removal: .move(edge: .leading)))
case .game:
GameView()
// EnvironmentObjects an GameView übergeben
.environmentObject(viewModel)
.environmentObject(settingsStore)
// Übergangsanimation
.transition(.asymmetric(insertion: .move(edge: .trailing), removal: .move(edge: .leading)))
}
} // Ende der optionalen Group
// !!! WICHTIG: KEIN .animation(...) Modifier hier !!!
}
}
// Vorschau
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
// Erstelle Instanzen für die Vorschau
let vmWelcome = GameViewModel()
vmWelcome.currentAppState = .welcome
let vmSetup = GameViewModel()
vmSetup.currentAppState = .setup
let vmGame = GameViewModel()
vmGame.currentAppState = .game
vmGame.currentCard = Card.defaultCards.first
let settings = SettingsStore()
// Zeige verschiedene Zustände in der Vorschau an
Group {
ContentView()
.environmentObject(vmWelcome)
.environmentObject(settings)
.previewDisplayName("Welcome State")
ContentView()
.environmentObject(vmSetup)
.environmentObject(settings)
.previewDisplayName("Setup State")
ContentView()
.environmentObject(vmGame)
.environmentObject(settings)
.previewDisplayName("Game State")
}
}
}
Troubleshooting Steps Taken (No Success):
Ensured correct placement of .environmentObject modifiers on subviews within the switch.
Removed a previous .animation() modifier applied directly to the switch.
Ensured state changes triggering transitions are wrapped in withAnimation.
Wrapped the switch in a Group.
Multiple "Clean Build Folder".
Deleted entire Derived Data folder (with Xcode closed).
Restarted Xcode and the Mac multiple times.
Deleted and recreated ContentView.swift with the code above.
Crucially: The errors persist even when replacing WelcomeView(), - - - --- SetupView(), and GameView() with simple Text("...") views inside the switch cases (as shown in the code snippet above).
Environment:
Xcode Version: newest
macOS Version: newest
Question:
Does anyone have any idea why the compiler would still fail to type-check this switch structure, even when the views inside are simplified to basic Text? What else could I try to diagnose or fix this? Could it be related to the subviews (SetupView/GameView) potentially having their own NavigationView or complexity, even when replaced by Text in the failing ContentView?
Thanks for any suggestions!
Topic:
UI Frameworks
SubTopic:
SwiftUI
I want record screen in my app,the method startCaptureWithHandler:completionHandler:,the sampleBuffer, It is supposed to exist but it has become nil.Not only that,but there‘s another problem,when I want to stop recording and save the video,I will check [RPScreenRecorder sharedRecorder].recording first, it will be false sometime,that problems are unusual in iOS 18.3.2 iPhoneXs Max,and unexpected,here is my code
-(void)startCaptureScreen {
NSLog(@"AKA++ startCaptureScreen");
if ([[RPScreenRecorder sharedRecorder] isRecording]) {
return;
}
//屏幕录制
[[RPScreenRecorder sharedRecorder]setMicrophoneEnabled:YES];
NSLog(@"AKA++ MicrophoneEnabled AAAA startCaptureScreen");
[[RPScreenRecorder sharedRecorder]setCameraEnabled:YES];
[[RPScreenRecorder sharedRecorder] startCaptureWithHandler:^(CMSampleBufferRef _Nonnull sampleBuffer, RPSampleBufferType bufferType, NSError * _Nullable error) {
if(self.assetWriter == nil){
if (self.AVAssetWriterStatus == 0) {
[self setupAssetWriterAndStartWith:sampleBuffer];
}
}
if (self.AVAssetWriterStatus != 2) {
return;
}
if (error) {
// deal with error
return;
}
if (self.assetWriter.status != AVAssetWriterStatusWriting) {
[self assetWriterAppendSampleBufferFailWith:bufferType];
return;
}
if (bufferType == RPSampleBufferTypeVideo) {
if(self.assetWriter.status == 0 ||self.assetWriter.status > 2){
} else if(self.videoAssetWriterInput.readyForMoreMediaData == YES){
BOOL success = [self.videoAssetWriterInput appendSampleBuffer:sampleBuffer];
}
}
if (bufferType == RPSampleBufferTypeAudioMic) {
if(self.assetWriter.status == 0 ||self.assetWriter.status > 2){
} else if(self.audioAssetWriterInput.readyForMoreMediaData == YES){
BOOL success = [self.audioAssetWriterInput appendSampleBuffer:sampleBuffer];
}
}
} completionHandler:^(NSError * _Nullable error) {
//deal with error
}];
}
and than ,when want to save it :
-(void)stopRecording {
if([[RPScreenRecorder sharedRecorder] isRecording]){
// The problem is sporadic,recording action failed,it makes me confused
}
[[RPScreenRecorder sharedRecorder] stopCaptureWithHandler:^(NSError * _Nullable error) {
if(!error) {
//post message
}
}];
}
I am using the standard SwiftUI component for subscription management, and on one device it is showing the user as unsubscribed when their sub is still in service.
The subscribe button is active but inert, doesn't do anything.
Ideas?
In order to make referencing keys for localized strings a little more reliable, our application references generated constants for localized string keys:
This eliminates the potential for developers to misspell a key when referencing a localized strings. And because these constants are automatically generated by the exact same process that provides localized strings for the application, each and every constant is guaranteed to have a localized string associated with it.
I’m currently attempting to implement something similar for the localized strings referenced by our new App Intents. Our initial release of App Intent functionality is simply using string literals to reference localized strings:
However, I am running into several issues when trying to reference the string keys as a constant. The closest I managed to get was defining the constant as either a LocalizationValue or as a StaticString and referencing the constant while initializing the LocalizedStringResource. With this approach, I see no errors from Xcode until I try and compile. What’s more is that the wording of the error being thrown is quite peculiar:
As you can see with the sample code above, I am clearly calling LocalizedStringResource’s initializer directly as Indicated by the error.
Is what I’m trying to do even possible with App Intents? From my research, it does look like iOS app localization is moving more towards using string literals for localized strings. Like with String Catalog’s ability to automatically generate entries from strings referenced in UI without the need for a key. However, we’d prefer to use constants if possible for the reasons listed above.
I’m building a macOS app using SwiftUI with a WindowGroup(id: "rootWindow") for the main UI. The app shows a countdown timer, and the timer continues to run even after the user closes the main window (clicks the red "X"). When the timer reaches 0, I want to automatically reopen that window and bring the app to the front.
I’m currently using the following code to bring the app to the foreground and show the window when the app is still open (but not focused/resign active state):
NSApp.activate(ignoringOtherApps: true)
NSApp.windows.forEach { window in
if window.identifier?.rawValue.starts(with: "rootWindow") {
window.makeKeyAndOrderFront(nil)
}
}
However, this doesn’t work when the window has been closed. At that point, NSApp.windows no longer contains my SwiftUI window, and I have no reference to recreate or reopen it. I also cannot use openWindow environment value as it requires a view.
How can I programmatically reopen a SwiftUI WindowGroup window after it’s been closed, without requiring any user interaction (like clicking the Dock icon)?
I have a simple Picker where the options available change by the view state. I would like to have the transition animated but the default animation is not good so I tried setting a .transition() and or an .animation() inside an item on the picker but it is ignored. The same happens if the transition is set on the picker itself since it's always present.
Am I doing it right and is just not posible or is there something else to do?
Code to reproduce the issue:
struct ContentView: View {
@State var list: [String] = [
"Item 4",
"Item 5",
"Item 6",
"Item 7",
"Item 8",
]
@State var selected: String?
@State var toggle: Bool = false
var body: some View {
VStack {
Picker("List", selection: $selected) {
ForEach(list, id: \.self) {
Text($0).tag($0)
// .transition(.opacity)
}
}
.pickerStyle(.segmented)
// .transition(.opacity)
HStack {
Button(action: swapOptions) {
Text("Swap")
}
}
}
.padding()
}
}
extension ContentView {
func swapOptions() {
withAnimation {
toggle.toggle()
switch toggle {
case true:
list = [
"Item 1",
"Item 2",
"Item 3",
"Item 4",
"Item 5",
]
case false:
list = [
"Item 4",
"Item 5",
"Item 6",
"Item 7",
"Item 8",
]
}
}
}
}
``
Topic:
UI Frameworks
SubTopic:
SwiftUI
We recently migrated our app to use NavigationSplitView on iPad with a sidebar and detail setup, and we got reports that the navigation buttons on the sidebar disappear when returning to our app after using a different app. I reproduced the issue from a new empty project with the following code (issue tested on iOS 17.4 and iOS 18.3, was not able to reproduce on iOS 16.4):
import SwiftUI
@main
struct TestApp: App {
var body: some Scene {
WindowGroup {
NavigationSplitView {
Text("sidebar")
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button(action: {}) {
Image(systemName: "square.and.arrow.down")
}
}
ToolbarItem(placement: .topBarTrailing) {
Button(action: {}) {
Image(systemName: "square.and.arrow.up")
}
}
}
} detail: {
Text("detail")
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button(action: {}) {
Image(systemName: "eraser")
}
}
ToolbarItem(placement: .topBarTrailing) {
Button(action: {}) {
Image(systemName: "pencil")
}
}
}
}
}
}
}
Please check the following GIF for the simple steps, notice how the navbar buttons in the detail view do not disappear:
Here's the console output, it shows that the constraints break internally:
Hi, I'm working on RealityView and I have two entities in RCP. In order to set views for both entities, I have to create two separate attachments for each entity. What I want to achieve is that when I hover (by eye) on one entity's attachment, it would trigger the hover effect of the other entity's attachment. I try to use the hoverEffectGroup, but it would only activate the hover effect in a subview, instead a complete separate view. I refer to the following WWDC instruction for the hover effect.
https://developer.apple.com/videos/play/wwdc2024/10152/
One of our users reported a very strange bug where our app freezes and eventually crashes on some screen transitions.
From different crash logs we could determine that the app freezes up when we call view.layoutIfNeeded() for animating constraint changes. It then gets killed by the watchdog 10 seconds later:
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: FRONTBOARD 2343432205
<RBSTerminateContext| domain:10 code:0x8BADF00D explanation:scene-update watchdog transgression: app<bundleID(2A01F261-3554-44C0-B5A9-EBEB446484AD)>:6921 exhausted real (wall clock) time allowance of 10.00 seconds
ProcessVisibility: Background
ProcessState: Running
WatchdogEvent: scene-update
WatchdogVisibility: Background
WatchdogCPUStatistics: (
"Elapsed total CPU time (seconds): 24.320 (user 18.860, system 5.460), 29% CPU",
"Elapsed application CPU time (seconds): 10.630, 12% CPU"
) reportType:CrashLog maxTerminationResistance:Interactive>
The crash stack trace looks slightly different, depending on the UI transition that is happening. Here are the two we observed so far. Both are triggered by the layoutIfNeeded() call.
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 CoreAutoLayout 0x1b09f90e4 -[NSISEngine valueForEngineVar:] + 8
1 UIKitCore 0x18f919478 -[_UIViewLayoutEngineRelativeAlignmentRectOriginCache origin] + 372
2 UIKitCore 0x18f918f18 -[UIView _nsis_center:bounds:inEngine:forLayoutGuide:] + 1372
3 UIKitCore 0x18f908e9c -[UIView(Geometry) _applyISEngineLayoutValuesToBoundsOnly:] + 248
4 UIKitCore 0x18f9089e0 -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 148
5 CoreFoundation 0x18d0cd6a4 __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ + 24
6 CoreFoundation 0x18d0cd584 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 432
7 UIKitCore 0x18f8e62b0 -[UIView(Geometry) resizeSubviewsWithOldSize:] + 128
8 UIKitCore 0x18f977194 -[UIView(AdditionalLayoutSupport) _is_layout] + 124
9 UIKitCore 0x18f976c2c -[UIView _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 800
10 UIKitCore 0x18f903944 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2728
11 QuartzCore 0x18ec15498 CA::Layer::layout_if_needed(CA::Transaction*) + 496
12 UIKitCore 0x18f940c10 -[UIView(Hierarchy) layoutBelowIfNeeded] + 312
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 QuartzCore 0x18ec2cfe0 -[CALayer animationForKey:] + 176
1 UIKitCore 0x18fa5b258 UniqueAnimationKeyForLayer + 192
2 UIKitCore 0x18fa5ab7c __67-[_UIViewAdditiveAnimationAction runActionForKey:object:arguments:]_block_invoke_2 + 468
3 UIKitCore 0x18fa5ba5c -[_UIViewAdditiveAnimationAction runActionForKey:object:arguments:] + 1968
4 QuartzCore 0x18eb9e938 CA::Layer::set_bounds(CA::Rect const&, bool) + 428
5 QuartzCore 0x18eb9e760 -[CALayer setBounds:] + 132
6 UIKitCore 0x18f941770 -[UIView _backing_setBounds:] + 64
7 UIKitCore 0x18f940404 -[UIView(Geometry) setBounds:] + 340
8 UIKitCore 0x18f908f84 -[UIView(Geometry) _applyISEngineLayoutValuesToBoundsOnly:] + 480
9 UIKitCore 0x18f9089e0 -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 148
10 CoreFoundation 0x18d0cd6a4 __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ + 24
11 CoreFoundation 0x18d132488 -[__NSSingleObjectArrayI enumerateObjectsWithOptions:usingBlock:] + 92
12 UIKitCore 0x18f8e62b0 -[UIView(Geometry) resizeSubviewsWithOldSize:] + 128
13 UIKitCore 0x18f977194 -[UIView(AdditionalLayoutSupport) _is_layout] + 124
14 UIKitCore 0x18f976c2c -[UIView _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 800
15 UIKitCore 0x18f916258 -[UIView(Hierarchy) layoutSubviews] + 204
16 UIKitCore 0x18f903814 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2424
17 QuartzCore 0x18ec15498 CA::Layer::layout_if_needed(CA::Transaction*) + 496
18 UIKitCore 0x18f940c10 -[UIView(Hierarchy) layoutBelowIfNeeded] + 312
So far, we only know of one iPad Air M1 where this is happening. But we don't know how many users experience this issue without reporting it.
Does anyone know what could cause Auto Layout or Core Animation to block in those calls? We have no clue so far...
Hi everyone! I am having a bit of trouble with why my Map() is overwriting my customized tabBar settings. Specifically my tab bar background. (White -> Black)
Map(position: $cameraPosition) {
UserAnnotation()
}
.toolbarBackground(.hidden, for: .tabBar)
This above ^ is a view which acts as a tab view for my tab bar. I have customized my tab bar as follows just so it was obvious to see me changes.
let tabAppearance = UITabBarAppearance()
tabAppearance.configureWithOpaqueBackground()
tabAppearance.backgroundColor = .white
UITabBar.appearance().standardAppearance = tabAppearance
UITabBar.appearance().scrollEdgeAppearance = tabAppearance
I have tried implementing solutions which is seen with my .toolbar attempt but nothing has help. I would like the tab bar to be consistent with all of my views and from my understanding the Map is overwriting those settings.
Hello,
In my SwiftUI App i'm trying to create a custom UI trait and a matching bridged SwiftUI environment key. I want to override the environment key in a swift view and then have that reflect in the current UITraitCollection.
I'm following the pattern in the linked video but am not seeing the changes reflect in the current trait collection when I update the swift env value.
I can't find anything online that is helping.
Does anyone know what I am missing?
https://developer.apple.com/videos/play/wwdc2023/10057/
// Setup
enum CustomTheme: String, Codable {
case theme1 = “theme1”,
theme2 = “theme2”
}
struct customThemeTrait: UITraitDefinition {
static let defaultValue = brand.theme1
static let affectsColorAppearance = true
static let identifier = "com.appName.customTheme"
}
extension UITraitCollection {
var customTheme: CustomTheme { self[customThemeTrait.self] }
}
extension UIMutableTraits {
var customTheme: CustomTheme {
get { self[customThemeTrait.self] }
set { self[customThemeTrait.self] = newValue }
}
}
private struct customThemeKey: EnvironmentKey {
static let defaultValue: CustomTheme = .theme1
}
extension customThemeKey: UITraitBridgedEnvironmentKey {
static func read(from traitCollection: UITraitCollection) -> CustomTheme {
traitCollection.customTheme
}
static func write(to mutableTraits: inout UIMutableTraits, value: CustomTheme) {
mutableTraits.customTheme = value
}
}
extension EnvironmentValues {
var customTheme: CustomTheme {
get { self[customThemeKey.self] }
set { self[customThemeKey.self] = newValue }
}
}
// Attempted Usage
extension Color {
static func primaryBackground() -> Color {
UITraitCollection.current.customTheme == .theme1 ? Color.red : Color.blue
}
}
struct ContentView: View {
@State private var theme = .theme1
var body: some View {
if (dataHasLoaded && themeIsSet) {
HomeView()
.environment(\.customTheme, theme)
} else {
SelectThemeView( theme: self.theme, setContentThemeHandler)
}
}
func setContentThemeHandler(theme: customTheme) {
self.theme = theme
}
}
struct HomeView() {
@Environment(\.customTheme) private var currentTheme: customTheme
var body: some View {
VStack {
Text("currentTheme: \(currentTheme.rawValue)")
.background(Color.primaryBackground())
Text("currentUITrait: \(UITraitCollection.current.customTheme.rawValue)")
.background(Color.primaryBackground())
}
}
}
OUTCOME:
After selecting theme2 in the theme selector view and navigating to the homeView, the background is still red and the env and trait values print the following:
currentTheme: theme2
currentUITrait: theme1
Can anyone help me identify what I am missing?
Hi Apple team and community,
We’re encountering a strange issue with Live Activity that seems related to memory management or background lifecycle.
❓ Issue:
Our app updates a Live Activity regularly (every 3 minutes) using .update(...). However, after the app remains in the background for around 8 hours, the Live Activity reverts to the initial state that was passed into .request(...).
Even though the app continues sending updates in the background, the UI on the Lock Screen and Dynamic Island resets to the original state.