Xcode 16.1
iOS 18.1
iPad Air 13-inch (M2)
I have created a completely new Xcode project with Swift and Storyboard.
In Storyboard, I only have a tabBarController with two attached UIViewControllers.
The code from the base project hasn't been changed at all.
I created a UITest with a very simple premise.
let app = XCUIApplication()
override func setupWithError() throws {
continueAfterFailure = false
app.launch()
}
func testTabBarExistence() {
let tabBar = app.tabBars.element(boundBy: 0)
XCTAssertTrue(tabBar.waitForExistence(timeout: 5), "Tab bar should exist")
}
But this test always fails for iPad on iOS 18+, but it will succeed for anything lower (e.g. 17.5)
UIKit
RSS for tagConstruct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.
Post
Replies
Boosts
Views
Activity
I am trying to convert some of my older drawings to a PKCanvas. In my older drawings, I had an eraser stroke which erases anything that the stroke intersected with. I am able to convert all the strokes except an eraser stroke which doesn't seem to exist in PKCanvas. The user tool exists, but PKInkTypePen etc... doesn't contain an eraser type.
Is there any way to create an "eraser type stroke" so I can convert my drawing strokes to use the PKCanvas?
Thanks
In my app, User can select word in the UITextView, then I want to insert a content under the selected words(the comment words shouldn't be selected).like:
I found TextKit2 only support edit NSTextParagraph position, or I missed some features in NSTextLayoutManager?
I try to override the NSTextLayoutFragment and update the draw(at point: CGPoint, in context: CGContext) but I found, user still can select the origin content at the origin position, even if the layer of linefragment layer on the corrent position not the origin position.
Hello everyone,
I’m encountering a problem on the latest iOS 18 related to location permissions. When the user denies location access, my app triggers the standard system prompt asking them to enable location from Settings. On iOS 17 and below, tapping the “Settings” button in this system alert would successfully navigate the user to my app’s Settings page. However, on iOS 18, nothing happens. Instead, I see the following warning in the Xcode console:
Warning :
BUG IN CLIENT OF UIKIT: The caller of UIApplication.openURL(:) needs to migrate
to the non-deprecated UIApplication.open(:options:completionHandler:).
Force returning false (NO).
Important details and context:
In my own code, I have already replaced all calls to openURL(:) with open(:options:completionHandler:).
I searched the entire codebase for usage of openURL: and didn’t find any.
The alert that appears is the system location alert (iOS-generated), not a custom UIAlertController. Thus, I have no direct control over the underlying call.
On iOS 17 (and below), tapping “Settings” in the same system dialog works perfectly and takes the user to the app’s permission page.
The console message implies that somewhere—likely inside the system’s own flow—the deprecated API is being called and blocked on iOS 18.
What I’ve tried:
Verified I am not calling openURL: anywhere in my code.
Confirmed that UIApplication.openSettingsURLString works when I programmatically open it in a custom alert.
Tested multiple times on iOS 17 and iOS 18 to confirm the behavior difference.
Steps to reproduce:
Install the app on a device running iOS 18 Beta.
Deny location permission when prompted.
Trigger a piece of code that relies on location (e.g., loading a map screen) so that the OS automatically shows its standard “Location is disabled” alert, which includes a “Settings” button.
Tap “Settings.” On iOS 17, this navigates to the app’s Settings. On iOS 18 Beta, it does nothing, and the console logs the BUG IN CLIENT OF UIKIT warning.
Questions:
Is this a known iOS 18 bug where the system’s own alert is still using the deprecated openURL: call?
If so, are there any workarounds besides presenting a custom alert that manually calls open(_:options:completionHandler:)?
Thank you in advance. Any guidance or confirmation would be appreciated!
Im creating a chat using uiTableView. The response is send as streaming so I need to reload last cell até every response update. However when I do reload row and scroll to bottom, the content of the last cell seems to be drag to the bottom instead of looking as a regular scroll.
Hello,
we are presenting a UIDocumentInteractionController within our app, so the user can share some documents. Sharing basically works but we are facing the problem that the two delegate methods
documentInteractionController(UIDocumentInteractionController, willBeginSendingToApplication: String?)
and
documentInteractionController(UIDocumentInteractionController, didEndSendingToApplication: String?)
are never being called. Other delegate methods such as
documentInteractionControllerWillBeginPreview(UIDocumentInteractionController)
are called just fine. Everything worked as expected when we last checked a year ago or so, but doesn't anymore now, even after updating to the latest iOS 18.3.
Does anybody know of a solution for this?
For reference, this is the simplified code we are using the reproduce the issue:
import UIKit
import OSLog
class ViewController: UIViewController, UIDocumentInteractionControllerDelegate {
let log = Logger(subsystem: "com.me.pdfshare", category: "app")
var documentInteractionController: UIDocumentInteractionController!
override func viewDidLoad() {
super.viewDidLoad()
guard let pdfURL = Bundle.main.url(forResource: "test", withExtension: "pdf") else {
return
}
documentInteractionController = UIDocumentInteractionController(url: pdfURL)
documentInteractionController.delegate = self
documentInteractionController.presentPreview(animated: true)
}
// MARK: - UIDocumentInteractionControllerDelegate
func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
log.notice("documentInteractionControllerViewControllerForPreview")
return self
} // This will be called.
func documentInteractionController(_ controller: UIDocumentInteractionController, willBeginSendingToApplication application: String?) {
log.notice("willBeginSendingToApplication")
} // This will NOT be called.
func documentInteractionController(_ controller: UIDocumentInteractionController, didEndSendingToApplication application: String?) {
log.notice("didEndSendingToApplication")
} // This will NOT be called.
}
I use
for (NSNumber *controlState in AllControlStates()) {
[uiButton setAttributedTitle:attributedStrings[controlState] forState:controlState.unsignedIntegerValue];
}
to set different title colors based on different controlState now.
How to use UIButtonConfiguration to set attributedTitle based on control state?
I am deprecating contentEdgeInsets for my button now, I have to set all the other properties on configuration to maintain the current look of my button.
I'm using UIDocumentBrowserViewController. This view controller automatically creates a TabView with navigation titles and up to two trailing navigation bar items.
To visualize this, open the Files app by Apple on an iPhone.
I want to do the following:
Add a third button and place it farthest on the trailing side.
Keep all three buttons blue (the default color), but adjust the color of the navigation title to use the primary text color (it is also currently blue, by default)
Button Order
If my button is represented by C, then the order from left-to-right or leading-to-trailing should be A B C.
I tried to add it by using additionaltrailingnavigationbarbuttonitems:
class DocumentBrowserViewController: UIDocumentBrowserViewController, UIDocumentBrowserViewControllerDelegate
{
override func viewDidLoad()
{
super.viewDidLoad()
let button = UIBarButtonItem(...)
additionalTrailingNavigationBarButtonItems.append(button)
}
}
This always adds it as the leftmost trailing item. The order when the view loads is C A B, where C represents my button.
Here are some things I've tried:
Add it in viewWillAppear - same results.
Add it in viewDidAppear - same results.
Add it using rightBarButtonItems - does not show up at all.
insert it at: 0 instead of appending it - same results.
Add it with a delay using DispatchQueue.main.async - same results.
After some experimentation, I realized that the arrays referenced by additionalTrailingNavigationBarButtons and rightBarButtonItems seem to be empty, other than my own button. This is the case even if the DispatchQueue delay is so long that the view has already rendered and the two default buttons are clearly visible. So I'm not sure how to place my button relative to these, since I can't figure out where they actually are in the view controller's properties.
How do I put my button farther to the trailing/right side of these two default buttons?
Title Color
The navigation titles created by UIDocumentBrowserViewController are blue when not in their inline format. I want them to use the primary text color instead.
In viewDidLoad, I could do something like this:
UINavigationBar.appearance().tintColor = UIColor.label
This will change the title color to white or black, but it will also change the color of the buttons. I've tried various approaches like titleTextAttributes, and none of them seem to work with this view controller.
How do I change just the color of the navigation title, and not the color of the navigation bar items?
We are developing an MacOS app from our iOS app using MacCatalyst.
If I press long on the app icon on the Dock, a list of recent files appears.
If I tap one one of these files nothing happens. I would expect the scene delegate function:
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>)
would be called but it is not. Can somebody maybe explain what I am missing here?
The list of recent files also appears in the Menu under File > Open recent files. There I can tap on a file and it it is opened correctly using the scene delegate method mentioned above.
The files can also be opened with the app using the Finder, so the associated file types with the app are correct.
If I show a textfield in my app and set nothing else on it but the following, The keyboard will show an autofill suggestion from a password manager for a one time code.
textField.keyboardType = .numberPad
In this case, the text field is for typing in a count, so iOS suggesting to autofill a one time code is incorrect.
Setting textField.textContentType to nil has no affect on the behaviour.
Prerequisites to reproduce
an app with an associated domain
an entry in a password manager with a one time code for the domain
a textfield with keyboardType set to numberPad
How to share 'back facing' iOS camera app at same time Eye Tracking app needs 'front facing' camera?
While using my xmas present of a new iPhone and iOS 18.2, I figured I'd try the Eye Tracker app. I've been working with clients successfully using Tobii and other existing eye trackers. In my limited tests, Apple has room for improvement.
My main issue is with the camera app which cannot be used at the same time while using the Eye Tracker app. I get an error popup from Apple:
Camera is use by another app
The image below is from my app showing the popup message "Camera in use by another app", but the same error occurs on the installed camera app. This error is from Apple, not my app.
For terminology: 'front' camera is the one pointing at the user (the selfi camera) while 'back' camera is the main one with multiple lenses. Eye tracking needs the 'front' camera.
It seems when an app uses the camera, it takes over both the front and back facing cameras (since you might swap them). Thus another app, especially Eye Tracking, cannot use just the front facing camera at the same time.
That limits use of Eye Tracking, in particular one cannot take pictures or click any buttons on an app that uses the camera.
Anyone know of a way for an app to not take over both front and back cameras at the same time? If I can separate them, the Eye Tracker could use the front camera while the camera uses the back camera.
I'm upgrading my app from minVersion iOS 11 to iOS 12. My compiler says that UIDocumentMenuViewController with UIDocumentPickerViewController is deprecated, they recommend to use directly the last one. So I change the code.
fileprivate func openDocumentPicker() {
let documentPicker = UIDocumentPickerViewController(
documentTypes: [
"com.adobe.pdf",
"org.openxmlformats.wordprocessingml.document", // DOCX
"com.microsoft.word.doc" // DOC
],
in: .import
)
documentPicker.delegate = self
view.window?.rootViewController?.present(documentPicker, animated: true, completion: nil)
}
When I open the picker in iOS 17.2 simulator and under it is well shown, like a page sheet. But in iOS 18.0 and up at first it opens like a page sheet with no content but then it is displayed as a transparent window with no content. Is there any issue with this component and iOS 18? If I open the picker through UIDocumentMenuViewControllerDelegate in an iphone with iOS 18.2 it is well shown.
Image in iOS 18.2 with the snippet
The same snippet in iOS 17.2 (and expected in older ones)
I'm encountering an issue displaying a large HTML string (over 11470 characters) in a UILabel. Specifically, the Arabic text within the string is rendering left-to-right instead of the correct right-to-left direction. I've provided a truncated version of the HTML string and the relevant code snippet below. I've tried setting the UILabel's text alignment to right, but this didn't resolve the issue. Could you please advise on how to resolve this bidirectional text rendering problem?
The results of the correct and incorrect approaches are shown in the image below.
Here's the relevant Swift code:
let labelView: UILabel = {
let label = UILabel()
label.textAlignment = .right
label.translatesAutoresizingMaskIntoConstraints = false
label.numberOfLines = 0
label.semanticContentAttribute = .forceRightToLeft
label.backgroundColor = .white
label.lineBreakMode = .byWordWrapping
return label
}()
//Important!!
//It must exceed 11470 characters.
let htmlString = """
<p style=\"text-align: center;\"><strong>İSTİÂZE</strong></p> <p>Nahl sûresindeki:</p>
<p dir="rtl" lang="ar"> فَاِذَا قَرَاْتَ الْقُرْاٰنَ فَاسْتَعِذْ بِاللّٰهِ مِنَ الشَّيْطَانِ الرَّج۪يمِ </p>
<p><strong>“</strong><strong>Kur’an okuyacağın zaman kovulmuş şeytandan hemen Allah’a sığın!</strong><strong>”</strong> (Nahl 16/98) emri gereğince Kur’ân-ı Kerîm okumaya başlarken:</p> <p dir="rtl" lang="ar">اَعُوذُ بِاللّٰهِ مِنَ الشَّيْطَانِ الرَّج۪يمِ</p> <p><em>“Kovulmuş şeytandan Allah’a sığınırım” </em>deriz. Bu sözü söylemeye “istiâze<em>” denilir. “Eûzü”</em>, sığınırım, emân dilerim, yardım taleb ederim, gibi anlamlara gelir. It must exceed 11470 characters.</p>
“””
if let data = htmlString.data(using: .utf8) {
let options: [NSAttributedString.DocumentReadingOptionKey: Any] = [
.documentType: NSAttributedString.DocumentType.html,
.characterEncoding: String.Encoding.utf8.rawValue
]
do {
let attributedString = try NSAttributedString(data: data, options: options, documentAttributes: nil)
labelView.attributedText = attributedString
} catch {
print("HTML string işlenirken hata oluştu: \(error)")
}
}
I'm using iOS 18.2 and Swift 6. Any suggestions on how to correct the bidirectional text rendering?
I have a project that has many dialogue boxes that pop up. The method I've chosen (and worked well for years) is to put a UIView on a ViewController with a slightly opaque background. Dialogue info is in the UIView. With the upgrade to Xcode 16 and iOS 18 all of my UIViews in my project have been re-sized to 540x600 and I can't figure out how to change them back to their original size. Many of them are now unusable as the information they previously contained was much larger than that.
Any idea who to blame (Xcode 16 or iOS 18?) or how to fix it?
I'm desperate enough I'm willing to use code level support but it requires a small test project and the issue is with a large existing project. Can't reproduce it on a new project.
I tried to update my ios from 17.2 to 18.1 on my iphone 14 pro. I use this device for testing my apps. when i go to my sdk, i got double back button and when i clicked the back button it will go to blank screen
here is the ss
double back button
got blank screen
its never happened on ios 17 and below
i use coordinator and UINavigationController
anyone have solutions?
In iPadOS18 UITabBarController not releasing viewControllers after deinit with sidebar enabled.
On checking the memory Graph Debugger we could see that the viewControllers are hold by UITab which in turn hold by UITabSidebarItem. We don't have control over the UITabSidebarItem and unable to remove the reference.
The issue not happens when tabbarController mode is set to 'tabBar' instead of 'sidebar'.
We have event tried to set empty tabs before dismiss the view but still the original tabs are not removing in memory and holding the viewcontollers as well.
Anyone assist on this issue. Sharing the sample code here
My App always encounter with CoreAutoLayout invade
My SnapKit layout constraint as follow:
popBgView.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.leading.equalTo(assistantTeacherView.snp.trailing).offset(.isiPad ? -50 : -40)
if TTLGlobalConstants.isCompactScreen320 {
make.width.lessThanOrEqualTo(300)
} else {
let widthRatio = .isiPad ? 494.0 / 1024.0 : 434.0 / 812.0
make.width.lessThanOrEqualTo(TTLGlobalConstants.screenWidth * widthRatio)
}
bubbleViewRightConstraint = make.trailing.equalToSuperview().constraint
}
.....
popBgView.addSubview(functionView)
msgLabel.snp.remakeConstraints { make in
make.leading.equalToSuperview().inset(Metric.msgLabelHorizantalInset)
make.centerY.equalToSuperview()
make.trailing.lessThanOrEqualToSuperview().inset(Metric.msgLabelHorizantalInset)
make.top.equalTo(Metric.msgLabelVerticalInset)
}
functionView.snp.makeConstraints { make in
make.leading.equalTo(msgLabel.snp.trailing).offset(Metric.msgLabelFunctionSpacing)
make.centerY.equalToSuperview()
make.trailing.equalToSuperview().offset(-Metric.msgLabelHorizantalInset)
}
msgLabel and functionView superview is popBgView
However, when I try remove from superview for functionView, There is low probability crash:
OS Version: iOS 16.1.1 (20B101)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: SEGV_NOOP
Crashed Thread: 0
Application Specific Information:
Exception 1, Code 1, Subcode 14967683541490370463 >
KERN_INVALID_ADDRESS at 0xcfb7e4e0f8fe879f.
Thread 0 Crashed:
0 CoreAutoLayout 0x382555f44 -[NSISEngine positiveErrorVarForBrokenConstraintWithMarker:errorVar:]
1 CoreAutoLayout 0x382555e9c -[NSISEngine positiveErrorVarForBrokenConstraintWithMarker:errorVar:]
2 CoreAutoLayout 0x3825557e4 -[NSISEngine removeConstraintWithMarker:]
3 CoreAutoLayout 0x382555198 -[NSLayoutConstraint _removeFromEngine:]
4 UIKitCore 0x34d87961c __57-[UIView _switchToLayoutEngine:]_block_invoke
5 CoreAutoLayout 0x382556e8c -[NSISEngine withBehaviors:performModifications:]
6 UIKitCore 0x34d8a1c38 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]
7 UIKitCore 0x34d7f01b0 __57-[UIView _switchToLayoutEngine:]_block_invoke_2
8 UIKitCore 0x34d879770 __57-[UIView _switchToLayoutEngine:]_block_invoke
9 CoreAutoLayout 0x382556e8c -[NSISEngine withBehaviors:performModifications:]
10 UIKitCore 0x34d8a1c38 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]
11 UIKitCore 0x34d8a1848 __45-[UIView _postMovedFromSuperview:]_block_invoke
12 UIKitCore 0x34e7ff8d0 -[UIView _postMovedFromSuperview:]
13 UIKitCore 0x34d85e3c8 __UIViewWasRemovedFromSuperview
14 UIKitCore 0x34d85b1a4 -[UIView(Hierarchy) removeFromSuperview]
15 Collie-iPad 0x203001550 [inlined] InClassAssistantView.functionView.didset (InClassAssistantView.swift:105)
In iOS 18, we encountered a crash:
Thread 4 name: com.apple.root.user-interactive-qos
Thread 4 Crashed:
0 CoreFoundation 0x18c4f9b10 __CFCheckCFInfoPACSignature + 4
1 CoreFoundation 0x18c53ed64 CFBundleGetInfoDictionary + 24
2 CoreFoundation 0x18c53ed1c CFBundleGetIdentifier + 16
3 Foundation 0x18b153740 -[NSUserDefaults(NSUserDefaults) _initWithSuiteName:container:] + 84
4 UIKitCore 0x18ef26ef0 ___UIKitUserDefaults_block_invoke + 40
5 libdispatch.dylib 0x1941ee0d0 _dispatch_client_callout + 20
6 libdispatch.dylib 0x1941ef918 _dispatch_once_callout + 32
7 UIKitCore 0x18ef9de28 _UIKitUserDefaults + 80
8 UIKitCore 0x18f058a7c ___UIKitPreferencesOnce_block_invoke + 20
9 libdispatch.dylib 0x1941ee0d0 _dispatch_client_callout + 20
10 libdispatch.dylib 0x1941ef918 _dispatch_once_callout + 32
11 UIKitCore 0x18f056c8c _UIKitPreferencesOnce + 80
12 UIKitCore 0x18f0563b8 ___UIApplicationMainPreparations_block_invoke + 20
13 libdispatch.dylib 0x1941ec370 _dispatch_call_block_and_release + 32
14 libdispatch.dylib 0x1941ee0d0 _dispatch_client_callout + 20
15 libdispatch.dylib 0x1941fff60 _dispatch_root_queue_drain + 860
16 libdispatch.dylib 0x194200590 _dispatch_worker_thread2 + 156
17 libsystem_pthread.dylib 0x2136ffc40 _pthread_wqthread + 228
18 libsystem_pthread.dylib 0x2136fc488 start_wqthread + 8
Below image show more details:
And after set a symbol breakpoint:
[NSUserDefaults _initWithSuiteName:container:]
We found that at the beginning of app launch, the system will call it:
It not always crash, but sometimes especially when app upgrade, what the root cause maybe?
When using:
[[NSUserDefaults alloc] initWithSuiteName:@"TestSuiteName"];
It sometimes cause crash, the crash detail is:
Thread 4 name: com.apple.root.user-interactive-qos
Thread 4 Crashed:
0 CoreFoundation 0x1963f9b10 __CFCheckCFInfoPACSignature + 4
1 CoreFoundation 0x19643ed64 CFBundleGetInfoDictionary + 24
2 CoreFoundation 0x19643ed1c CFBundleGetIdentifier + 16
3 Foundation 0x195053740 -[NSUserDefaults(NSUserDefaults) _initWithSuiteName:container:] + 84
4 UIKitCore 0x198e26ef0 ___UIKitUserDefaults_block_invoke + 40
5 libdispatch.dylib 0x19e0ee0d0 _dispatch_client_callout + 20
6 libdispatch.dylib 0x19e0ef918 _dispatch_once_callout + 32
7 UIKitCore 0x198e9de28 _UIKitUserDefaults + 80
8 UIKitCore 0x198f58a7c ___UIKitPreferencesOnce_block_invoke + 20
9 libdispatch.dylib 0x19e0ee0d0 _dispatch_client_callout + 20
10 libdispatch.dylib 0x19e0ef918 _dispatch_once_callout + 32
11 UIKitCore 0x198f56c8c _UIKitPreferencesOnce + 80
12 UIKitCore 0x198f563b8 ___UIApplicationMainPreparations_block_invoke + 20
13 libdispatch.dylib 0x19e0ec370 _dispatch_call_block_and_release + 32
14 libdispatch.dylib 0x19e0ee0d0 _dispatch_client_callout + 20
15 libdispatch.dylib 0x19e0fff60 _dispatch_root_queue_drain + 860
16 libdispatch.dylib 0x19e100590 _dispatch_worker_thread2 + 156
17 libsystem_pthread.dylib 0x21d7dfc40 _pthread_wqthread + 228
18 libsystem_pthread.dylib 0x21d7dc488 start_wqthread + 8
and for more detail crash info can see the attachment image
.
And Refer to the API's description:
/// -initWithSuiteName: initializes an instance of NSUserDefaults that searches the shared preferences search list for the domain 'suitename'. For example, using the identifier of an application group will cause the receiver to search the preferences for that group. Passing the current application's bundle identifier, NSGlobalDomain, or the corresponding CFPreferences constants is an error. Passing nil will search the default search list.
- (nullable instancetype)initWithSuiteName:(nullable NSString *)suitename API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0)) NS_DESIGNATED_INITIALIZER;
It seems using a constants string is a wrong way.
Does any one know what to root cause?
Demo project link
https://cdn.pokekara.com/int/other/1737343007_fbcdee810da429552b12ffa2644d928c.zip