iOS is the operating system for iPhone.

Posts under iOS tag

200 Posts

Post

Replies

Boosts

Views

Activity

Understanding Keychain Errors in Mobile Banking App
Hi, We use the iOS Keychain in our mobile app to securely store and retrieve data, which is tightly coupled with the initialization of some app features within the application. This issue is encountered during app launch We retrieve during Splash Screen UI controller at viewDidApper() The logic we use to access the Keychain is as follows: NSDate *NSDate_CD; NSString *account = [NSString stringWithUTF8String:@"SOME_KEY_ACCOUNT"]; NSString *attrgen = [NSString stringWithUTF8String:@"SOME_KEY"]; NSMutableDictionary *query = [[NSMutableDictionary alloc] init]; [query setObject:(__bridge id)(kSecClassGenericPassword) forKey:(__bridge id<NSCopying>)(kSecClass)]; [query setObject:attrgen forKey:(__bridge id<NSCopying>)(kSecAttrGeneric)]; [query setObject:(__bridge id)(kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly) forKey:(__bridge id<NSCopying>)(kSecAttrAccessible)]; [query setObject: [NSBundle mainBundle].bundleIdentifier forKey:(__bridge id<NSCopying>)(kSecAttrService)]; [query setObject:account forKey:(__bridge id<NSCopying>)(kSecAttrAccount)]; [query setObject:@YES forKey:(__bridge id<NSCopying>)(kSecReturnAttributes)]; [query setObject:@YES forKey:(__bridge id<NSCopying>)(kSecReturnData)]; CFDictionaryRef valueAttributes = NULL; OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, (CFTypeRef *)&valueAttributes); NSDictionary *attributes = (__bridge_transfer NSDictionary *)valueAttributes; if(status==errSecSuccess) { NSDate_CD = [attributes objectForKey:(__bridge id)kSecAttrCreationDate]; } else { NSLog(@"Key chain query failed"); } However, some users have reported intermittent failures during app launch. Upon investigation, we discovered that these failures are caused by exceptions thrown by the iOS Keychain, which the app is currently not handling. Unfortunately, we do not log the exception or the Keychain error code in the app logs at the moment, but we plan to implement this logging feature in the near future. For now, we are trying to better understand the nature of these errors. Could you help clarify the following Keychain errors, which might be encountered from the code above? errSecServiceNotAvailable (-25307) errSecAllocate (-108) errSecNotAvailable (-25291) If these errors are encountered, are they typically persistent or are they temporary states that could resolve on their own? Your insights would be greatly appreciated. Thank you.
1
0
483
Jan ’25
Launch screen more vibrant in iOS18?
Hi! I've detected that in iOS18 launch screen colors differs from the defined ones, that is, if I create a launch screen with a color like #ff0000 (red) and the initial view controller is a view controller with the same color as background, I can see the transition between launch screen and the initial view controller because the launch screen color is different from the other one (dark in this case). I've tested it with several colors: left side is the launch screen and right side is the initial view controller. Both views created with IB using the same colors (it also happens with background images using colors) Is this an intentionall behavior? If so, theres a way to disable it? I need the transition between the launch screen and my initial view controller to be non perceptible... Thanks!
Topic: Design SubTopic: General Tags:
4
1
629
Jan ’25
OS Logging says developer mode is disabled but its enabled
I'm trying to diagnose an issue with a Message Filtering Extension not working. The associated domain for the server is not currently publicly hosted, so the associated domains specified for the app are postpended with ?mode=developer On application installation I filtered OS logging by the swcd process and saw this logged: debug 08:40:01.125071-0800 swcd Skipping domain vz….qa….cl….ce….com?mode=developer because developer mode is disabled But developer mode IS enabled on the phone (Settings/Privacy & Security/Developer Mode is set to On). Therefore why is swcd saying developer mode is disabled? Is the developer mode mentioned in the documentation not actually the Developer Mode in the iPhone's setting but something else? That wouldn't appear to be the case because the documentation explicitly states "Specifies that only devices in developer mode can access the domain." Full Documentation: https://developer.apple.com/documentation/BundleResources/Entitlements/com.apple.developer.associated-domains If you use a private web server, which is unreachable from the public internet, while developing your app, enable the alternate mode feature to bypass the CDN and connect directly to your server. To do this, add a query string to your associated domains entitlement, as shown in the following example: :?mode= developer Specifies that only devices in developer mode can access the domain. So I've: turned developer mode on for the device have added ?mode=developer to the domain am building/running using a developer certificate. But why does swcd log that developer mode is disabled?
2
0
456
Jan ’25
Programmatically setting accessibility focus broken?
Hello! I'm trying to improve the accessibility of a UIKit login form in our iOS app. If an error occurs, an error message is shown in a label that is hidden by default. For our VoiceOver users, I want to move the focus to the error message label so that VoiceOver reads out the error message. I'm trying to achieve this using UIAccessibility.post, but try as I might, it does not work. To better understand the problem, I created a very simple App which shows a button and a label (always visible), and on pressing the button, I post an accessibility notification: UIAccessibility.post(notification: .layoutChanged, argument: label) What I expect to happen is for the focus to move from the button to the label. What happens instead is the focus stays with the button and VoiceOver reads out the button's label again. So it seems to process the notification, but ignore the argument. Am I misunderstanding how accessibility notifications work or is this simply broken at the moment? I am testing this withy my iPhone with the current iOS version 18.2.1 By the way, using the more modern variant leads to the same result: AccessibilityNotification.LayoutChanged(label).post()
3
0
489
Jan ’25
System fonts file access: allowed for sandboxed apps?
Hello! I am developing an ebook reader iOS app that uses c/c++ codec as a page renderer. The codec uses TrueType as a font rendering engine that requires access to .ttf (or .ttc) files. Currently, I supply TrueType with fonts embedded in the app package, so they lay within the app sandbox. The codec supports the whole unicode plane and many languages that ebooks may use, but the fonts I supply don't have some of the important glyphs (i.e. katakana or hangul). I see that iOS has its own font storage, located in /System/Library/Fonts/ directory. The codec is able to parse this directory and read .ttf files located inside, using these fonts as a fallback in the case when the supplied fonts can't draw certain glyphs. I use opendir and fopen(in "rb" mode) as a way to read the data, and it works well. Does this type of access to the system directory violate the sandbox rule for an app distribution, and, if yes, is there a way to get access to stored .ttf files not violating the mentioned rule?
1
0
834
Jan ’25
Is it possible to create a .ipa without a distribution certificate?
I have a developer certificate but not a distribution certificate (its not my Apple account). Its possible to create an .xcarchive with a developer certificate, but what about a .ipa? After creating an archive, non of the distribution options within XCode will work without a dist cert. Is there another way to make an .ipa with just a dev cert? And if so is that going to be a dev build rather than a prod build (i.e. the .ipa would only install onto provisioned devices and would be no good for uploading to testflight for example)
3
0
549
Jan ’25
What are causes of networkURLUnauthorized in a message filter extension
I'm getting ILMessageFilterError.networkURLUnauthorized returned in a message filter extension when calling deferQueryRequestToServer(). Googling for people who have had the same error, they didn't include the associated domain in the containing app. However I have added that. The server is set up at https://something.com:443, it has an apple association file located at https://something.com:443/.well-known/apple-app-site-association I have added associated domains to the app and the app extension of: messagefilter:something.com?mode=developer webcredentials:something.com?mode=developer Side question 1: are both needed or just the messagefilter? Side question 2: should the domain include the port :443? The server isn't publicly hosted hence I've appended ?mode=developer on the end as per the documentation. The extension's info.plist has ILMessageFilterExtensionNetworkURL added as something.com Question 3: Does this need the port adding too? With everything set up according to the documentation, apart from the questions above, what might be the cause of getting networkURLUnauthorized returned?
3
0
288
Jan ’25
Universal Links not working on an iOS 14 device with the associated website behind a VPN
Prior to iOS 14 our Dev server was routing universal links to our test devices just fine from both Xcode and TestFlight builds. But now that we've started testing on iOS 14 devices the links aren't being handled any more. After doing some research we noticed the new configuration regarding Associated Domains for web servers that aren't reachable from the public internet. https://developer.apple.com/documentation/safariservices/supporting_associated_domains Starting with macOS 11 and iOS 14, apps no longer send requests for apple-app-site-association files directly to your web server. Instead, they send these requests to an Apple-managed content delivery network (CDN) dedicated to associated domains. While you’re developing your app, if your web server is unreachable from the public internet, you can use the alternate mode feature to bypass the CDN and connect directly to your private domain.You enable an alternate mode by adding a query string to your associated domain’s entitlement as follows: <service>:<fully qualified domain>?mode=<alternate mode> Given our Dev server is only reachable via a VPN we changed our project config to use the alternate mode: <key>com.apple.developer.associated-domains</key> <array> <string>webcredentials:ourDevServerURL?mode=developer</string> <string>applinks:ourDevServerURL?mode=developer</string> </array> But unfortunately that still doesn't work and in the console we can see the following swcd logs being generated after a fresh app install. debug com.apple.swc 11:45:19.016561-0600 swcd entry Skipping domain si….va….com?mode=developer because developer mode is disabled So what else do we need to get developer mode working for these app links?
14
1
26k
Jan ’25
Message Filter Extension and domain alternate mode
The documentation (https://developer.apple.com/documentation/BundleResources/Entitlements/com.apple.developer.associated-domains) for a message filter extension says: If you use a private web server, which is unreachable from the public internet, while developing your app, enable the alternate mode feature to bypass the CDN and connect directly to your server. &lt;service&gt;:&lt;fully qualified domain&gt;?mode=&lt;alternate mode&gt; Where alternate mode is one of the following: developer Specifies that only devices in developer mode can access the domain. In this mode, you can use any valid SSL certificate on your web server, including a certificate that the system doesn’t trust. What does it mean "you can use any valid SSL certificate on your web server"? Does the app have to do anything with regards to this?
2
0
340
Jan ’25
Ability to retrieve keychain item appears to be lost after restoring an IOS Device
On some production devices our application fails to find the keychain item associated with our application where we store our JWT tokens. We have been unable to reproduce this in house for many months. Today I restored a phone from a backup using the device to device transfer of data as I replaced my personal phone. On that device now when opened each time I am prompted to login again and it appears my token is never saved to the keychain. Upon every successive reopen of the application I see this error in the console. Error fetching keychain item - Error Domain=NSOSStatusErrorDomain Code=-25300 "no matching items found" UserInfo={numberOfErrorsDeep=0, NSDescription=no matching items found} I currently do not see any errors in the console related to the saving of said token. We access this token with the after first unlock security and we do not allow iCloud backup for these tokens. Any help here would be appreciated. I'm not sure what would cause an issue like this. Other applications on my device do not seem to have this issue, so Its likely something we're doing code wise that may be different. Any hints as to what to look for here may be of help. The previous device or any device i have not created from a backup works as intended, including about 95% of our production users.
4
2
436
Jan ’25
How to determine the default duration of a long-press
Using gesture recognizers it is easy to implement a long-press gesture to open a menu, show a preview or something else on the iOS platform. And you can provide the duration the user must hold down the finger until the gesture recognizer fires. But I could not yet find out how to determine the default duration for a long-press gesture that is configured in the system settings within the "accessibility" settings under "Haptic Touch" (the available options are fast, standard and slow here). Is it possible to read out this setting, so my App can adapt to this system setting as well?
1
0
319
Jan ’25
State Restoration not restoring root view controller
I'm trying to implement UI state restoration in an old Objective-C UIKit app that does not use scenes and also does not have a storyboard. I have implemented the correct AppDelegate methods -- application:shouldSaveSecureApplicationState: and application:shouldRestoreSecureApplicationState: -- and I can see that they are being called when expected. I have also implemented the state restoration and UIViewControllerRestoration viewControllerWithRestorationIdentifierPath:coder: methods for the view controllers I want to persist and restore; along with correctly setting their restorationIdentifier and restorationClass properties. I can also see that those are being called when expected. I've also installed the restorationArchiveTool and have verified that the persisted archive contains the expected view controllers and state. However, once state restoration is complete, the window's rootViewController property is still nil and has not been assigned to the view controller that has the restorationIdentifier of the rootViewController at the time the state is persisted. I found this sample app that does what I want to do -- persist and restore the state of the view controllers without the use of storyboards. Running that I verified that it does in fact work as expected. https://github.com/darrarski/iOS-State-Restoration The difference between what that app does and what mine does, is that it always creates the top level view controllers in application:willFinishLaunchingWithOptions:. func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { let viewControllerA = DemoViewController() viewControllerA.title = "A" let navigationControllerA = UINavigationController(rootViewController: viewControllerA) navigationControllerA.restorationIdentifier = "Navigation" let viewControllerB = DemoViewController() viewControllerB.title = "B" let navigationControllerB = UINavigationController(rootViewController: viewControllerB) navigationControllerB.restorationIdentifier = "Navigation" let tabBarController = UITabBarController() tabBarController.restorationIdentifier = "MainTabBar" tabBarController.viewControllers = [navigationControllerA, navigationControllerB] window = UIWindow(frame: UIScreen.main.bounds) window?.restorationIdentifier = "MainWindow" window?.rootViewController = tabBarController return true } Unfortunately, my app is more dynamic and the rootViewController is determined after launch. When I updated the app to be structured more like mine, I see that it fails the same as mine and no longer restores the rootViewController. class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? var didRestoreState = false func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { window = UIWindow(frame: UIScreen.main.bounds) window?.restorationIdentifier = "MainWindow" return true } func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { if !didRestoreState { let viewControllerA = DemoViewController() viewControllerA.title = "A" let navigationControllerA = UINavigationController(rootViewController: viewControllerA) navigationControllerA.restorationIdentifier = "Navigation" let viewControllerB = DemoViewController() viewControllerB.title = "B" let navigationControllerB = UINavigationController(rootViewController: viewControllerB) navigationControllerB.restorationIdentifier = "Navigation" let tabBarController = UITabBarController() tabBarController.restorationIdentifier = "MainTabBar" tabBarController.viewControllers = [navigationControllerA, navigationControllerB] window?.rootViewController = tabBarController } window?.makeKeyAndVisible() return true } func application(_ application: UIApplication, shouldSaveSecureApplicationState coder: NSCoder) -> Bool { let libraryDirectory = FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first let appStateUrl = libraryDirectory?.appendingPathComponent("Saved Application State") NSLog("Restoration files: \(appStateUrl?.path ?? "none")") return true } func application(_ application: UIApplication, shouldRestoreSecureApplicationState coder: NSCoder) -> Bool { return true } func application(_ application: UIApplication, didDecodeRestorableStateWith coder: NSCoder) { didRestoreState = true } } I don't really understand why this doesn't work since the archive file looks identical in both cases, and the methods used to create and restore state of the view controllers are being called in both cases. Is there something else I need to do to correctly restore the view controllers without having to create them all before state restoration begins?
2
1
338
Jan ’25
Skipping Notifications permission alert on sequoia
Hello, it seems like starting from iOS 18.0, it is possible to entirely skip the notifications permission request alert by swiping up from the bottom of the screen. It doesn't work this way with any other kinds of system alerts, nor in iOS 17.4 (tested it in the Simulator though). So, is it a bug? Or is it intended? Either way, I haven't found any information regarding that. The problem with that is when you skip the alert, notifications are missing from the app preferences.
1
0
324
Jan ’25
What is the current proper way to load an image from local filesystem?
I'm just trying to display an image that is stored in the local filesystem, but the more I dig into this the more confused I get. So previously I used this code (it's simplified): func findImage(name: String) -&gt; UIImage? { do { let url = try FileManager.default.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: false) .appendingPathComponent("MyFolder") .appendingPathComponent("\(name).png") guard let image = UIImage(contentsOfFile: url.path) else { return nil } return image } catch { print(error.localizedDescription) } return nil } Notice I create the URL with just .appendingPathComponent() and turning URL to path via url.path. It works! So what's the question? In Improving performance and stability when accessing the file system I've read that you better use the new appendingPathComponent(_:isDirectory:), that's good, will do. Also url.path is deprecated in iOS18. Should I use url.path(percentEncoded:) instead? What should be the value of percentEncoded when accessing the local filesystem? In this adjacent thread I've read: Don't use UIImage(contentsOfFile:) either, because it's a path-based API. There's no URL-based equivalent, which is an Apple clue that should be doing something else. Is this true? Then how should I store and load my images? Just FYI, I create images like this: private func generateThumbnail(name: String) { guard let drawingWidth = canvasGeo?.size.width, let drawingHeight = canvasGeo?.size.height else { return } let thumbnailRect = CGRect(x: 0, y: 0, width: drawingWidth, height: drawingHeight) Task { UITraitCollection(userInterfaceStyle: .light).performAsCurrent { let image = self.canvasView.drawing.image(from: thumbnailRect, scale: UIScreen.main.scale) guard let data = image.pngData() else { return } // -- HERE do { try FileManager.default.createDirectory(at: try FileManager.default.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true) .appendingPathComponent("MyFolder"), withIntermediateDirectories: true, attributes: nil) let filename = "\(name).png" let url = try FileManager.default.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true) .appendingPathComponent("MyFolder") .appendingPathComponent(filename) try data.write(to: url, options: .atomic) // -- and HERE } catch { print(error.localizedDescription) } } } } My usecase — just save the user's PencilKit Canvas as an image and display it back to him on a different View. I'm on SwiftUI and iOS 16+. Would be happy to learn the correct way, thanks!
4
0
2.4k
Jan ’25
Live Caller ID doesn't perform caching
I experimented a lot with Live Caller ID when it first appeared with iOS 18 Beta. Now I'm starting to pick it up again and have immediately noticed some detrimental differences between the behavior observed when it was in beta status to how it currently behaves with iOS 18.3. The main difference is caching - if a call is made and data from a live call id lookup displayed on the call screen, then if the call is made again immediately then that data is re-fetched from the server. And it takes a long time too, about 5 or 6 seconds before the data is displayed in the call screen (with the beta it took about 3 seconds). In the data set cache_expiry_minutes is set to 50, yet it's not being honored, there's no caching occurring at all. Yet this did used to occur several months ago when the feature was in beta. What's happened to caching, why is it no longer working when it used to? Another change is there used to be a notification displayed when a call was blocked, this no longer is displayed. Is this an intentional change or a bug?
0
2
342
Jan ’25
Need Help with LZMA2 Compression Using SWCompression in Swift
I'm looking for assistance with compressing data using the LZMA2 algorithm from the SWCompression library in an iOS project. I've encountered issues and need guidance on how to correctly implement LZMA2 compression. Any help or code examples would be greatly appreciated! Please help me providing information regarding this NOTE: If I use third party library means I am getting error from testflight The app references non-public symbols in Payload/Hogs.app/Hogs: _lzma_easy_encoder, _lzma_end (ID: 305f671a-b2ee-4e14-8764-00ed9b86bfb0) Help me solve this issue Thanks
5
0
446
Jan ’25
CallKit - CallDirectory extension - Added data by addIdentificationEntry
The app I'm making uses the CallDirectory extension to identify callers. Where is the contact data added by "func addIdentificationEntry" in "CallDirectory Extension" stored? The app calls "CXCallDirectoryManager.sharedInstance.reloadExtension" and adds contact data by processing "CXCallDirectoryExtensionContext.addIdentificationEntry" written in "func beginRequest" of "CallDirectory Extension". I thought that if I uninstalled the app, I would lose the contact data that added by App. However, when I uninstalled the app and reinstalled it, it seemed to retain contact data that added by App before I uninstalled the app, even though the app hasn't added any contact data yet. Will the contact data added to the "CallDirectory Extension" be retained on iPhone even after uninstalling the app? ---Note--- I found a similar post on the forum about contact data added by addIdentificationEntry. ・CallKit - addIdentificationEntry is it secure? [https://developer.apple.com/forums/thread/662182] Answer of this post that "the added data is cached in a SQLite database", but I couldn't find any official Apple documentation on this, so I'm not sure if this is correct. If contact data is cached in SQLite, will that data remain on the iPhone when uninstalled and not deleted? ●Development environment Mac OS Sonoma 14.7.1 Xcode 16.0 Swift ●Test Device iPhoneSE3 iOS:17.6.1
2
0
986
Jan ’25