Delve into the world of built-in app and system services available to developers. Discuss leveraging these services to enhance your app's functionality and user experience.

Post

Replies

Boosts

Views

Activity

Deployment Target for iOS app running on a Mac with Apple Silicon
Currently, I am working on an iOS app with a Deployment Target set to iOS 15.0, and macOS 12.0. The app is allowed to run on Macs with Apple Silicon. A customer with a Mac running macOS Monterey (12) is complaining that in the TestFlight app, they cannot install the app since it shows "Requires OS Update", even though the deployment target is smaller than the installed version of macOS 12. Are there any specifications available on which macOS version is required in order to use iOS apps on Silicon Macs?
2
0
250
Jan ’25
How to get the real app language code + variation?
Hello, I have the app localised to many languages and its variants, like English from Australia or Dutch from Belgium. My phone language is en_UK and the region is configured to ES. I cannot find a way to get the regional language code (ex: en_au, nl_be), it always gets simplified to the language (ex: en, nl), or adds my device region (ex: en-ES, nl-ES). Here I attach some examples while I have the app on en_au Locale.preferredLanguages ▿ 3 elements - 0 : "en-ES" - 1 : "ca-ES" - 2 : "es-ES" Bundle.main.preferredLocalizations ▿ 1 element - 0 : "en" NSLocale.current.languageCode ▿ Optional<String> - some : "en" Locale.current ▿ en_001@rg=eszzzz (fixed en_001@rg=eszzzz) - identifier : "en_001@rg=eszzzz" - locale : "fixed en_001@rg=eszzzz" Locale.autoupdatingCurrent.languageCode ▿ Optional<String> - some : "en" Locale.current.languageCode ▿ Optional<String> - some : "en" Locale.preferredLanguages[0] "en-ES"
2
0
353
Jan ’25
URLComponents bug in 18.x
Prior to 18.x, this has worked for years. However, if a port is included, the behavior in 18.x is to return "///some/path". In all previous versions it correctly returns "/some/path". Is this a bug, or documented change we missed? func relativeURLString(for urlString: String) -> String? { guard var components = URLComponents(string: urlString) else { return nil } components.host = nil components.scheme = nil // WE FOUND IF YOU NIL THE PORT BEFORE HOST AND SCHEME, IT WORKS components.port = nil return components.string }
4
0
238
Jan ’25
PDFKit - beginFindString
I am creating an iOS app that needs to parse the text from a PDF document. I can read the entire PDF document's text using the string property, but if it's a large PDF document, this could cause delays for users. From the documentation, I came across the beginFindString function, which seems to asynchronously, with no return? https://developer.apple.com/documentation/pdfkit/pdfdocument/beginfindstring(_:withoptions:)) Unfortunately I cannot find examples on how to use this function or its intended purpose/functionality, so any guidance would be appreciated. My goal is to read the PDF document one line at a time, searching for newlines ('\n'), then parsing that line as needed. I'm hoping the beginFindString function will be useful.
0
0
160
Jan ’25
Spotlight results | AppShortcut with AppEntity parameter vs CSSearchableItem.associateAppEntity
I've been exploring the Trails Sample App from this session at WWDC24. The app has a TrailEntity of type AppEntity which is leveraged in multiple places throughout the app, including: The GetTrailInfo App Intent with a trail parameter of type TrailEntity. A parameterized App Shortcut which calls the GetTrailInfo intent. The TrailDataManager's init calls updateSpotlightIndex(), which creates a CSSearchableItem for each Trail in the app, along with an associateAppEntity call linking the corresponding TrailEntity to each item that gets added to the CSSearchableIndex. If you build the app and search "trails" in Spotlight, the Trails Sample App section includes instances of TrailEntity as search results. But if you comment out the App Shortcut that takes a TrailEntity as a parameter and rebuild, there are no instances of TrailEntity in the search results. In both cases, the console prints [Spotlight] Trails indexed by Spotlight. Is this expected behavior? Why are the TrailEntity instances only appearing in Spotlight via the App Shortcut? Shouldn't the CSSearchableItem instances show up in Spotlight on their own regardless? If not, then what is the purpose of adopting Core Spotlight with App Entities? Does this add the app entities to the semantic index for "new Siri", even though they're not user facing in the Spotlight UI?
0
0
251
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
180
Jan ’25
How to manage child device's apps through an app on parent's phone using Screen Time Controls?
When we request auth from the AuthorizationCenter, it seems that we're only really able to allow users to control the apps on the parent's phone. Is there a way to allow us to let parents manage apps on the kid's device directly through our parent app? For context, we have 2 different apps, one for the parent and one for the child. The child is able to purchase screen time and the parent can redeem them (activate those minutes) from their end.
0
0
162
Jan ’25
Xcode 16.2 App Crashes Due to Missing NSMotionUsageDescription Key in Info.plist
There is a crash while running the project in Xcode 16.2. The project has been using CMPedometer and CoreMotion since 2020. I wonder: I did not have the NSMotionUsageDescription key added, why is it mandatory to add this key now? “This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSMotionUsageDescription key with a string value explaining to the user how the app uses this data.”
0
0
189
Jan ’25
macOS 15.1 MFMailComposeViewController.canSendMail() returns false always
In my Catalyst app I use func setupMailComposer() { // Check if the device can send email guard MFMailComposeViewController.canSendMail() else { print("Mail services are not available") showMailErrorAlert() return } // Create and configure the mail composer let mailComposeVC = MFMailComposeViewController() mailComposeVC.mailComposeDelegate = self // Set the email details mailComposeVC.setToRecipients(["example@example.com"]) mailComposeVC.setSubject("Subject for your email") mailComposeVC.setMessageBody("This is the body of the email.", isHTML: false) // Attach a file (optional) if let filePath = Bundle.main.path(forResource: "example", ofType: "pdf"), let fileData = try? Data(contentsOf: URL(fileURLWithPath: filePath)) { mailComposeVC.addAttachmentData(fileData, mimeType: "application/pdf", fileName: "example.pdf") } // Present the mail composer self.present(mailComposeVC, animated: true, completion: nil) } Since I have updated to macOS 15.1 the canSendMail() function returns false although I have configured Apple Mail (like before in 15.0 where it worked flawlessly).
1
1
253
Dec ’24
Deep link
Hi, I have a work task that I need to do that I struggle with... We would like to sent an email to our clients where in that email there will be a link that will redirect to App Store to our app to be downloaded. After the app is downloaded when the user opens the app he will automatically have a promocode pasted in our registration flow promocode text field. Has anyone had similar task ? Is it even possible ? I did some research on this but I didn't find anyone in situation that I have now... I now that deeplinks are widely used to parse data like this, but I'm not sure if this works even when the app is not downloaded yet. Maybe that the solution will be having a two links, but that would not be very user friendly... Do you have any advice how to do something like this or some alternatives please ? Thank you soo much for you time and respond.
1
0
193
Jan ’25
App Clip works in TestFlight but not elsewhere
My app is available in TestFlight but has been rejected in App Review with the review feedback that the app clip "just shows a blank screen". However, in the TestFlight app, the App Clip works as expected and brings up the clip. It also works correctly from Xcode testing. Any ideas on what the problem could be? It is using the default App Clip link (appclip.apple.com)
0
0
151
Jan ’25
iOS Message Filter Extension - deferQueryRequestToNetwork(completion:) error
iOS Message Filter Extension - deferQueryRequestToNetwork(completion:) error I made a test app using the iOS App template and added a target using the Message Filter Extension template which invokes deferQueryRequestToNetwork(completion:) when receiving an SMS. The app and the extension have same "Associated Domains Capabilities" with "messagefilter" pointing to a server which receives query requests and returns proper responses. The extension has the "ILMessageFilterExtensionNetworkURL" key in Info.plist file which specifies the server URL. deferQueryRequestToNetwork(completion:) throws a com.apple.calls.messagefilter error which reads "Extension's containing app (appID ) unauthorized to defer requests to host "
2
0
400
Nov ’24
AppIntent with long-running perform()
I'm using the AppIntents framework introduced in iOS 16. My goal is to create an AppIntent that performs a long-running task but does open my app when run. When I run the Intent from the Shortcuts app, I see an error message that says the shortcut "was interrupted because it didn't finish executing in time." Is there a way to signal progress to the user of a long-running AppIntent or get more time from the system prior to the AppIntent being cancelled?
3
1
2.0k
Sep ’22
Set Default Value for Date Picker in App Intent
Hi everyone, I have a simple question regarding App Intents. I have an intent that defines a few parameters, one of which is a Date. When the user is prompted for input, I’d like the date picker to start at a specific value (e.g., tomorrow) instead of the default current date. Is there a way to set an initial/default value for the date parameter in an App Intent? Thanks in advance for any guidance!
0
1
153
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. <service>:<fully qualified domain>?mode=<alternate mode> 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
201
Jan ’25
Should WCSession.isPaired be true before checking WCSession.isWatchAppInstalled ?
I have a depended watch app bundled with my iOS app. // ... <key>WKRunsIndependentlyOfCompanionApp</key> <false/> // ... My code: guard WCSession.isSupported() else { return } let session = WCSession.default session.delegate = self session.activate() public func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) { // ... if (session.activationState == .activated) { let log = Log(isPaired: session.isPaired, isWatchAppInstalled: session.isWatchAppInstalled) uploadLogToServer(log) } // ... } and also: guard WCSession.isSupported() else { return } let session = WCSession.default guard session.activationState == .activated, session.isWatchAppInstalled else { return } do { try session.updateApplicationContext(...) } catch { uploadErrorToServer(error) } What I've observed is that when I query the logs in the server's database, I get entities with isPaired = false and isWatchAppInstalled = true. Also, when I query the errors I see deviceNotPaired errors. So my question is, does Should WCSession.isPaired property be true before accessing WCSession.isWatchAppInstalled property ?
1
0
334
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
1.2k
Jul ’24