I was looking out for the error handling for rendering the Widgets(like UIButton, UIVIew etc) on the screen in iOS. I am painting the screen programmatically using swift.
Considering a simple Widget(like for say UIButton) when we try to create using its initializer and set some properties like 'setTitle' . These functions neither return any value upon success/failure nor in documentation they have mentioned about any exceptions which would be raised upon failure.
https://developer.apple.com/documentation/uikit/uibutton/settitle(_:for:)
So, how to do error handling here in this scenarios, in case the apis fail to due some reason, like memory issue? There must be some scenarios for these api failure.
UIKit
RSS for tagConstruct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.
Posts under UIKit tag
200 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi,
There are total three errors from the app running on the device.
First one is right after the app starts running on the device:
Could not create a sandbox extension for '/var/containers/Bundle/Application/D4CBF093-EFB1-43C5-996D-7D5CB04BF643/appadmob.app'
Below second issue comes when I dismiss the Interstitial Ad
First responder issue detected: non-key window attempting reload - allowing due to manual keyboard (first responder window is <UIWindow: 0x10d11c700; frame = (0 0; 414 896); hidden = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x301749300>; backgroundColor = <UIDynamicSystemColor: 0x3002b3080; name = _windowBackgroundColor>; layer = <UIWindowLayer: 0x3019b7960>>, key window is <QUIWindow: 0x10880db00; baseClass = UIWindow; frame = (0 0; 414 896); gestureRecognizers = <NSArray: 0x3017276e0>; layer = <UIWindowLayer: 0x3019852f0>>)
And the third issue below follows right after the second one:
Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "((target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.rendering AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.networking AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.webcontent))" UserInfo={NSLocalizedFailureReason=((target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.rendering AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.networking AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.webcontent))}>
0x118024480 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'WebProcess NearSuspended Assertion' for process with PID=19180, error: (null)
Failed to terminate process: Error Domain=com.apple.extensionKit.errorDomain Code=18 "(null)" UserInfo={NSUnderlyingError=0x3019254a0 {Error Domain=RBSRequestErrorDomain Code=3 "No such process found" UserInfo={NSLocalizedFailureReason=No such process found}}}
Also when I dismissed the interstitial ad, the screen looks greyed out, but when I touch the screen, the screen comes to normal.
Could you please suggest any solution for the problems.
Thanks,
Topic:
App & System Services
SubTopic:
General
Tags:
Xcode
UI Frameworks
UIKit
Xcode Sanitizers and Runtime Issues
Hi! I was trying to add an animation to my SwiftUI view with UIKit, but after the animation runs there's a delay before the view will accept touch interactions. I thought it was because of the frame size of the view controller, but even after fixing that I still get the delay. Could anyone point me to where I might be going wrong, or if maybe using a UIKit modifier for the animation just doesn't work?
Any help would be greatly appreciated!
UIView:
class BounceView: UIView {
required init() {
super.init(frame: .zero)
}
func bounceAnimation() {
guard let piece = self.subviews.first else { return }
UIView.animate(withDuration: 0.7, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0) {
piece.frame.origin.x += 10
}
}
func bounceBack() {
guard let piece = self.subviews.first else { return }
UIView.animate(withDuration: 0.7, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0) {
piece.frame.origin.x -= 10
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
UIView controller:
class BounceViewController: UIViewController {
init(controller: UIViewController) {
super.init(nibName: nil, bundle: nil)
view = BounceView()
addChild(controller)
controller.view.translatesAutoresizingMaskIntoConstraints = false
controller.view.backgroundColor = .clear
view.addSubview(controller.view)
controller.didMove(toParent: self)
}
// adjusts view to match bounds of child
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let subviewFrame = self.view.subviews.first?.bounds ?? .zero
view.frame = subviewFrame
print(subviewFrame)
self.updateViewConstraints()
}
func update(animated: Bool) {
let bounceView = view as? BounceView
if animated {
bounceView?.bounceAnimation()
} else {
bounceView?.bounceBack()
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
SwiftUI wrapper:
struct BounceUIViewController: UIViewControllerRepresentable {
private var controller: UIViewController
@Binding var animated: Bool
init(controller: UIViewController, animated: Binding<Bool>) {
self.controller = controller
self._animated = animated
}
func makeUIViewController(context: Context) -> BounceViewController {
BounceViewController(controller: controller)
}
func updateUIViewController(_ uiViewController: BounceViewController, context: Context) {
uiViewController.update(animated: animated)
}
}
View extension:
extension View {
func bounce(animated: Binding<Bool>) -> some View {
modifier(Bounce(animated: animated))
}
}
struct Bounce: ViewModifier {
@Binding var animated: Bool
init(animated: Binding<Bool>) {
self._animated = animated
}
func body(content: Content) -> some View {
BounceUIViewController(controller: content.uiViewController, animated: $animated)
}
}
It looks like Xcode 16 has changed this behavior so I'm not sure if this is a bug or not.
When a SwiftUI Button wraps a UIButton, the button doesn't work on iOS 18.0+
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Button(action: {
print("Not called on iOS 18")
}) {
WrapperButton()
.frame(width: 200, height: 50)
}
}
}
}
struct WrapperButton: UIViewRepresentable {
func makeUIView(context: Context) -> some UIView {
let button = UIButton(type: .system)
button.setTitle("OK", for: .normal)
return button
}
func updateUIView(_ uiView: UIViewType, context: Context) {}
}
This occurs with the app build with Xcode 16 and running on iOS 18
but it was worked with Xcode 15 builds and running on iOS 18
On the iOS 18 system, we have found that some pages will definitely experience this kind of crash phenomenon when displayed. It's puzzling that I can modify different codes and this kind of crash won't occur on the 18 system. This has had a great impact on my code development, and I don't know if I can still use this API in the future. Can you help me solve this dilemma. thank
Is there any way to change lens correction on iPad programatically using AVCapture?
Hi All
I faced up with strange issue in my app.
Everything works in iOS 18.0 and lower.
But after install iOS 18.1 same app from App Store crashes every time with error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard (<UIStoryboard: 0x11f6287a0>) doesn't contain a view controller with identifier 'MKCPinEntryViewControllerIdentifier''
Interesting that this view controller exist in the Storyboard.
First call in app:
dispatch_async(dispatch_get_main_queue(), ^{
//No authentication, needs login view controller popped.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
PinEntryViewController *pinViewController = [storyboard instantiateViewControllerWithIdentifier:@"PinEntryViewControllerIdentifier"];
pinViewController.delegate = self;
pinViewController.entryType = PinEntryTypeEnter;
[self.presentationContext presentViewController:pinViewController animated:YES completion:nil];
});
works good.
But second call in other place after 5 seconds:
dispatch_async(dispatch_get_main_queue(), ^{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
PinEntryViewController *pinViewController = [storyboard instantiateViewControllerWithIdentifier:@"PinEntryViewControllerIdentifier"];
pinViewController.delegate = self;
[self.presentationContext presentViewController:pinViewController animated:YES completion:nil];
});
crash the app with
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard (<UIStoryboard: 0x11f6287a0>) doesn't contain a view controller with identifier 'MKCPinEntryViewControllerIdentifier''
*** First throw call stack:
(0x1841b47cc 0x1814872e4 0x186d9c140 0x1063d692c 0x10301ec08 0x104370a30 0x10437271c 0x104382de8 0x1043829a4 0x184188204 0x184185440 0x184184830 0x1d01641c4 0x186ceaeb0 0x186d995b4 0x10667fe3c 0x1a9b72ec8)
libc++abi: terminating due to uncaught exception of type NSException
And issue not only with this view controller.
issue with all in that storyboard.
At start up instantiateViewControllerWithIdentifier works good with all view controllers identifiers. But on second call in other places in the app - all crash with same error
Reproduce in real device with iOS18.1 only. Simulators and devices with iOS 18.0 works well.
Could someone help me, what's wrong with the app?
if I set UIApplicationPreferredDefaultSceneSessionRole to UISceneSessionRoleImmersiveSpaceApplication then my Immersive Space for image is working fine but when I try with UIWindowSceneSessionRoleApplication this option and try to open Immersive space on particular sub screen then its not showing image in immersive space(Immersive space not open).
Any one have idea what the issue.
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationPreferredDefaultSceneSessionRole</key>
<string>UIWindowSceneSessionRoleApplication</string>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>UISceneSessionRoleImmersiveSpaceApplication</key>
<array>
<dict>
<key>UISceneInitialImmersionStyle</key>
<string>UIImmersionStyleFull</string>
</dict>
</array>
</dict>
</dict>
My info.plist value as above
Dear Experts,
I created a SwiftUI View (in a UIKit based project) whose objective is to display a short animation in the front of the user screen. I developed it 8 month ago in XCode 15 for iOS 17, no problems.
But since iOS 18, I can observe huge lags on my animation only in Release app. The problem is not present in Debug app.
I don't understand why this problem occurs, the animation is quite simple, it's just an offset deplacement.
I tried many thing like:
Show the animation with a UINavigationController
Show the animation with a UIWindow
Move the view with .position
Remove the GeometryReader
All other animation
withAnimation and .animation
Task and DispatchQueue
Etc...
I found that the laggy animation occurs when I set the Optimization Level for the Swift Compiler - Code Generation to Optimize for Speed [-O]. That's very strange because we had this option on Release for iOS 17 and we had no lags...
I can share to you a Sample Repository with the configuration we have. https://github.com/Thibma/sample-animation-swiftui
Today the only option I used is to develop this feature in UIKit but it's too bad to skip the SwiftUI opportunity. :/
If you have any ideas to resolve this, I take !
Thank you !
Hello!
I have a collectionView and assigned a layout to it:
collectionView.collectionViewLayout = createLayout(hasHeader: true)
func createLayout(hasHeader: Bool) -> UICollectionViewCompositionalLayout {
let layout = UICollectionViewCompositionalLayout { [weak self] (section,environment) -> NSCollectionLayoutSection? in
// configure cells
}
// adding a header:
if hasHeader {
let header = //...
layout.boundarySupplementaryItems.append(header)
}
return layout
}
Now, I just want to hide the header (animated).
Removing the header can simply be done this way, but this is not animated:
collectionView.collectionViewLayout = createLayout(hasHeader: false)
Is there any other possibility to hide it animated?
I have added an custom attribute for a paragraph using the below method
textStorage.addAttribute(.customCase, value: "checkList", range: paragraphRange)
When I insert some text in between the text which contains the custom attribute, that text is not inheriting/propagating the custom attribute of existing paragraph text
Old Text : - This is a test
New Text : - This is "some new" a test
The inserted part is not getting the custom attribute of the old text, Can I know why it's happening, Is it some textKit2's behaviour.
I have been implementing a UISearchController, I add it to the navigationItem of the view. When the view loads, it is hidden until I scroll down to show it. I want it to be shown initially. I have changed the navigationItem.hidesSearchBarWhenScrolling to false, it solved the initial problem but I also want it to be hidden when the user is scrolling through the collectionView of the view. I am currently using Swift 6 and iOS 18+.
I will add the current configuration function.
private func configureSearchController() {
let searchController = UISearchController()
searchController.searchResultsUpdater = self
searchController.searchBar.delegate = self
searchController.searchBar.placeholder = "Search for a username"
searchController.obscuresBackgroundDuringPresentation = false
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = false
}
I have encountered a tricky problem and hope to receive help.
My APP process does not exist, and then I click on the notification message of the APP to open it. At this time, my APP will first configure uitabbarccontroller, and then push the first (index=0) viewcontroller (A) from the tab to the notification message list viewcontroller (B). However, I found that on iOS18, the lifecycle of A (viewDidLoad) did not execute at the end of this process.
I am sure this problem will occur stably on iOS18.1.1.
Versions lower than iOS18 will not.
Can someone tell me why this is?
Hi, need some help with an iOS application we are trying to make future safe. Basically, we know that our app would require SwiftUI so the app is made in that framework, however we require some important elements that are available only in UIKit, so we've made a bridge that allows us to pass UIKit views to SwiftUI to display them. So most of the app actually has UI made in UIKit, however, we now need to use the Charts framework present in SwiftUI, we've used SwiftUI buttons in our UIKit before by passing them through a HostingController (Passing SwiftUI buttons to UIKit to use). And we are currently considering to the same for SwiftUI Charts. Just to recap, it's a SwiftUI iOS app, that is mostly made in UIKit (through a bridge) but also has other SwiftUI elements injected into it. What we want to know that, is this the best way to do this? Or is there a better way to have UIKit and SwiftUI work more comfortably with eachother. The reason for such looping around is also because we interoping our C++ code to Swift for making this application, since we are making it for many other platforms and the business logic is in C++. Let me know if there are better ways to go about this!
Hello,
I have an iOS app that is using SwiftUI but the gesture code is written using UIGestureRecognizer. When I run this app on visionOS using the "Designed for iPad" destination and try to use any of my gestures I see this warning in the console:
Trying to convert coordinates between views that are in different UIWindows, which isn't supported. Use convertPoint:fromCoordinateSpace: instead.
But I don't see any visible problems with the gestures.
I see this warning printed out after the gesture takes place but before any of our gesture methods get kicked off. So now I am wondering if this is something we need to deal with or some internal work that needs to happen in UIKit.
Does anyone have any thoughts on this?
To store the data, I used the following api:
(nullable UIPasteboard *)pasteboardWithName:(UIPasteboardName)pasteboardName create:(BOOL)create
The official document says that starting from iOS10, clipboard data does not support persistence, but from the test practice, I use this clipboard to save the data always exists, no matter uninstall and reinstall the APP, restart the phone, or even update the system, then what scenarios may lead to the clipboard data is deleted, using this scheme to store data is reliable?
We found some Firebase crashes in QLPreviewController on iOS18.1 +.
It shows cash info in QLPreviewController that we haven't changed for some years.
Please help with this.
Thanks in advance.
// stack info from Firebase
Fatal Exception: NSInvalidArgumentException
*** -[NSURL URLByAppendingPathComponent:]: component, components, or pathExtension cannot be nil.
0
CoreFoundation
__exceptionPreprocess
1
libobjc.A.dylib
objc_exception_throw
2
Foundation
-[NSURL(NSURLPathUtilities) URLByAppendingPathComponent:]
3
QuickLookUICore
+[NSURL(_QL_Utilities) _QLTemporaryFileURLWithType:filename:]
4
QuickLookUICore
+[NSURL(_QL_Utilities) _QLTemporaryFileURLWithType:uuid:]
5
QuickLook
-[QLPreviewController(ScreenshotsSupport) screenshotService:generatePDFRepresentationWithCompletion:]
6
ScreenshotServices
__82+[SSScreenshotMetadataHarvester _grabPDFRepresentationForIdentifier:withCallback:]_block_invoke_3
7
libdispatch.dylib
_dispatch_call_block_and_release
8
libdispatch.dylib
_dispatch_client_callout
9
libdispatch.dylib
_dispatch_main_queue_drain
10
libdispatch.dylib
_dispatch_main_queue_callback_4CF
11
CoreFoundation
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
12
CoreFoundation
__CFRunLoopRun
13
CoreFoundation
CFRunLoopRunSpecific
14
GraphicsServices
GSEventRunModal
15
UIKitCore
-[UIApplication _run]
16
UIKitCore
UIApplicationMain
17
Glip
main.swift - Line 13
main + 13
I have NsTextList and it has [NsTextListElement], I want to replace an NsTextListElement with other element like NsTextParagraph or NstextListElement or an AttributedString. For some reason the below method is not working at all. And I couldn't find any alternate way of replacing the elements
textLayoutManager.replaceContents(in: element.elementRange, with: NSAttributedString(string: "happy"))
I have a view controller that is hosing a WKWebView. My view controller overrides buildMenu(with builder: UIMenuBuilder), and prior to the beta, this was called reliably. However under 18.2 beta 4, it is not called at all, despite no code changes on my part.
Things I've tried:
Ensured that my responder chain is set up correctly.
Walked through the debugger via a symbolic breakpoint on [UIResponder buildMenuWithBuilder:] to understand that the web view is the last object to get a buildMenuWithBuilder message.
Any feedback or commiseration would be appreciated.
I have a crash on 19 [UITextField inputAssistantItem] + 68
It is running on a Simulator, is this related?
Details:
========= code in app ================================
numberTextField = CursorInCenterTextField()
numberTextField.listener = self
numberTextField.delegate = self
numberTextField.textAlignment = .left
numberTextField.adjustsFontSizeToFitWidth = true
numberTextField.isUserInteractionEnabled = true
numberTextField.inputView = UIView()
numberTextField.inputAssistantItem.leadingBarButtonGroups = []
numberTextField.inputAssistantItem.trailingBarButtonGroups = []
numberTextField.font = UIFont.systemFont(ofSize: 24.0, weight: .medium)
numberTextField.autocorrectionType = .no
numberTextField.returnKeyType = .search
========= crash stack from ips file ========================
Incident Identifier: 50AF117D-546E-409E-8915-6E4607C83BC0
CrashReporter Key: 4AB5D894-3E17-F998-4B64-F931D05DC65D
Hardware Model: Macmini9,1
Process: Glip [47003]
Path: /Users/USER/Library/Developer/CoreSimulator/Devices/83049BCF-16F7-481C-BE83-58727242A065/data/Containers/Bundle/Application/82E219BC-96B5-4A0F-AB20-D068A88C792F/Glip.app/Glip
Identifier: com.glip.mobile.rc
Version: 25.1.10 (132)
Code Type: X86-64 (Native(?))
Role: Foreground
Parent Process: launchd_sim [38628]
Coalition: com.apple.CoreSimulator.SimDevice.83049BCF-16F7-481C-BE83-58727242A065 [1342]
Date/Time: 2024-12-04 22:47:10.4249 +0800
Launch Time: 2024-12-04 22:47:02.4577 +0800
OS Version: macOS 14.5 (23F79)
Release Type: User
Baseband Version: None
Report Version: 104(?)
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000001b3531d10
Exception Codes: 0x0000000000000001, 0x00000001b3531d10
Exception Note: EXC_CORPSE_NOTIFY(?)
VM Region Info: 0x1b3531d10 is not in any region. Bytes after previous region: 3427601 Bytes before following region: 176880
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
Rosetta Generic 1b31ec000-1b31ed000 [ 4K] rw-/rwx SM=PRV
---> GAP OF 0x370000 BYTES
Rosetta Generic 1b355d000-1b355e000 [ 4K] rw-/rwx SM=PRV
Termination Reason: SIGNAL;[11] Segmentation fault: 11
Terminating Process: exc handler [47003]
Triggered by Thread: 0
Kernel Triage:
None
Thread 0 name: com.apple.main-thread
Thread 0 Crashed:
0 None 0x11e1e0144 0x0 + 4800250180
1 CoreUI 0x14fa08817 -[CUIStructuredThemeStore renditionWithKey:usingKeySignature:] + 406
2 CoreUI 0x14fa3e8ac -[CUICatalog _storageRefForRendition:representsODRContent:] + 94
3 CoreUI 0x14fa3b244 -[CUICatalog namedVectorGlyphWithName:scaleFactor:deviceIdiom:layoutDirection:glyphContinuousSize:glyphContinuousWeight:glyphPointSize:appearanceName:locale:] + 1909
4 CoreUI 0x14fa3b3a5 -[CUICatalog namedVectorGlyphWithName:scaleFactor:deviceIdiom:layoutDirection:glyphSize:glyphWeight:glyphPointSize:appearanceName:locale:] + 74
5 UIKitCore 0x167c4f99c __78-[_UIAssetManager imageNamed:configuration:cachingOptions:attachCatalogImage:]_block_invoke_2 + 201
6 UIKitCore 0x167c51fce __88-[_UIAssetManager _performLookUpObjectForTraitCollection:outNamedLookup:objectAccessor:]_block_invoke + 79
7 UIKitCore 0x16713340e -[UITraitCollection _enumerateThemeAppearanceNamesForLookup:] + 215
8 UIKitCore 0x167c51f3d -[_UIAssetManager _performLookUpObjectForTraitCollection:outNamedLookup:objectAccessor:] + 172
9 UIKitCore 0x167c520c0 -[_UIAssetManager _lookUpObjectForTraitCollection:objectAccessor:] + 40
10 UIKitCore 0x167c4f709 __78-[_UIAssetManager imageNamed:configuration:cachingOptions:attachCatalogImage:]_block_invoke + 849
11 UIKitCore 0x167c4f137 -[_UIAssetManager imageNamed:configuration:cachingOptions:attachCatalogImage:] + 291
12 UIKitCore 0x167c5001d -[_UIAssetManager imageNamed:configuration:] + 224
13 UIKitCore 0x1670c1b87 +[UIImage _systemImageNamed:withConfiguration:allowPrivate:] + 297
14 UIKitCore 0x167ae8cc0 +[UIAssistantBarButtonItemProvider configuredSymbolImageWithName:size:keyboardLanguageCode:] + 585
15 UIKitCore 0x167ae747e +[UIAssistantBarButtonItemProvider barButtonItemForAssistantItemStyle:target:forcePlainButton:] + 2850
16 UIKitCore 0x167ae90f1 +[UIAssistantBarButtonItemProvider defaultSystemLeadingBarButtonGroupsForItem:] + 206
17 UIKitCore 0x167ae9935 +[UIAssistantBarButtonItemProvider systemDefaultAssistantItem] + 55
18 UIKitCore 0x167719194 -[UIResponder(UIResponderInputViewAdditions) inputAssistantItem] + 67
19 UIKitCore 0x167b67898 -[UITextField inputAssistantItem] + 68
20 Glip 0x105915dbc BaseDialPadViewController.setupTopContainerViewConstraintAndSubViews() + 780
21 Glip 0x105917869 BaseDialPadViewController.setupContentViewForM1X() + 2681
22 Glip 0x105915781 BaseDialPadViewController.setupUI() + 193
........