Overview

Post

Replies

Boosts

Views

Activity

NFCTagReaderSession.PollingOption.pace fails with "Missing required entitlement" error
Hi, I'm developing an app that reads the NFC tags. So far so good, everything worked as expected, the app reads the passports and the IDs, until we encountered the french ID issued after March 2021. My app has the following entitlements: <dict> <key>com.apple.developer.nfc.readersession.formats</key> <array> <string>TAG</string> </array> </dict> And this additional entries in the .plist: <key>NFCReaderUsageDescription</key> <string>NFC usage to scan ID chip</string> ... <key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key> <array> <string>A0000002471001</string> <string>A0000002472001</string> <string>00000000000000</string> </array> According to an article which I cannot link on this forum because the domain is not permitted, iOS started supporting this specific ID from version 16. When I look at the docs, I can see the .pace polling mode was added. I tried specifying this additional polling mode in my app like so: var pollingOptions: NFCTagReaderSession.PollingOption = [.iso14443] if #available(iOS 16, *) { pollingOptions.insert(.pace) } self.session = NFCTagReaderSession(pollingOption: pollingOptions, delegate: self, queue: nil) But when I try to start the session it gets instantly invalidated with this message: Missing required entitlement. I'm pretty confident the message is misleading and something else is missing somewhere, my bet would be on the .plist entry com.apple.developer.nfc.readersession.iso7816.select-identifiers missing one of the cryptic numbers, but I have no idea where this can be taken from. How do I implement this .pace polling mode, can someone give me some guidance?
1
0
699
Feb ’23
DriverKit driver doesn't appear in Settings when installed with iPad app
I'm working on a DriverKit driver. I have it running on macOS, including a very simple client app written in SwiftUI. Everything is working fine there. I've added iPadOS as a destination for the app as demonstrated in the WWDC video on DriverKit for iPadOS. The app builds and runs on my iPad, as expected (after a little work to conditionalize out my use of SystemExtensions.framework for installation on macOS). However, after installing and running the app on an iPad, the driver does not show up in Settings->General, nor in the app-specific settings pane triggered by the inclusion of a settings bundle in the app. I've confirmed that the dext is indeed being included in the app bundle when built for iPadOS (in MyApp.app/SystemExtensions/com.me.MyApp.MyDriver.dext). I also can see in the build log that there's a validation step for the dext, and that seems to be succeeding. I don't know why the app isn't being discovered -- or in any case surfaced to the user -- when the app is installed on the iPad. Has anyone faced this problem and solved it? Are there ways to troubleshoot installation/discovery of an embedded DriverKit extensions on iOS? Unlike on macOS, I don't really see any relevant console messages.
3
1
1.2k
Feb ’23
Swift Async/Await, how to bring asynchronously calculated results back to main thread
I'm relatively new to Swift, and very new to concurrency via Async/Await, so please be patient. 😀 I'm having a hard time comprehending how to do complex operations asynchronously in background threads, and then in turn bring the results back to the main thread. I'm getting various errors along the lines of "Mutation of captured var 'personName' in concurrently-executing". I've paired the issue down as simply as possible as follows, and you'll see where the compiler gives the error message. I'd appreciate any advice on how to evolve my mental model to make this work. Thanks! Bruce import Foundation actor Person {     var myName = "Thomas Jefferson"     var name: String {         get {             return myName         }     } } func main() {     let person = Person()     var personName: String     print("start")     let nameTask = Task {         return await person.name     }     Task {         do {             personName = try await nameTask.result.get()             // Error: Mutation of captured var 'personName' in concurrently-executing code         } catch {             print("error!!!")         }     }     print("The person's name is \(personName)") } RunLoop.main.run() main()
4
0
3.1k
Mar ’23
Get device height with centimeter precision
Is it possible to get the height (Z location) of an iOS device based on sensor data? I've continuously added the accelerometer data up to infer the location but it results in a cascading error, and the inferred location of the phone "drifts" when the phone is placed still. I want to build an app where users measure the height of something by first zeroing the phone on the floor and then raising the phone to the height of the object, like placing it on the table.
3
0
914
Mar ’23
Please Create a Sendable Version of CKRecord or Make CKRecord Sendable
CKRecord is a class which does not conform to the Sendable protocol. Its fields consist of NSStrings, NSData and others which are not Sendable. I understand that Apple is incrementally modifying objects to be sendable, but I am experiencing and I would assume others are experiencing a very large number of warnings (for now) about CKRecords and Sendable. It may be too much to make CKRecord Sendable and it may be too much to create a Sendable version of CKRecord, but it would be nice if it could at least be investigated. My particular situation is I have created a Protocol named CKMethods which some of my view controllers use to download and upload CKRecords. I suddenly have a large number of warnings about non-sendable types being sent from main actor-isolated context to non-isolated instance method. The CKRecords sent to and from the protocol do not get mutated and I have never had a problem with data races in the years that I have had this protocol. At some point, the warnings will probably become errors and I definitely do not want to get to that point. I am still coming up to speed on Swift Concurrency, so there may be a more simple solution than the one I am working on - creating a Sendable Struct for every CKRecord type that I have in my app and modifying all of the methods to pass the Struct instead of a CKRecord and convert the Struct to a CKRecord for upload and convert the CKRecord to the Struct for download.
3
1
1.1k
Apr ’23
No way to close the page for subscription Offer Code processing invoked by "SKPaymentQueue.default().presentCodeRedemptionSheet()".
Problem was observed on the published App because the IAP offer code processing is only done on the published App. I implemented the ".presentCodeRedemptionSheet()" command by tapping Offer Code button. Then the typed in offer code was processed by this page and the offer was successfully purchased from AppStore. After detecting the purchased status, executed "SKPaymentQueue.default().finishTransaction(transaction)". I thought that finishTransaction() would close the offer code processing page that is not written in document. However the page for offer code processing page was still displayed and was never closed. The only way to close the input page for offer code is to manually tapping "Cancel" button. Since there is no way to close the offer code processing page, I added ".popToRootViewController(animated: true)" in order to close all pages and views after detection of purchased status but failed to close the offer code processing page managed by Apple. I need to know how to programmatically close the offer code processing page invoked by ".presentCodeRedemptionSheet()". I got no response from FeedBackAssistant and Apple Developer Technical Support. Thank you.
4
0
391
Apr ’23
NO ANIMATIONS in NavigationStack or NavigationSplitView
I'm building a macOS app using SwiftUI and I recently updated to xcode 14.3. Since then I've been debugging why none of my animations were working, it turned out that the NavigationSplitView or NavigationStack are somehow interfering with all the animations from withAnimation to .transition() and everything in between. Is anyone else experiencing this, knows a work around or knows why this is happening?
9
8
5.3k
Apr ’23
UDP socket bind with ephemeral port on macos results in OS allocating a already bound/in-use port
We have been observing an issue where when binding a UDP socket to an ephemeral port (i.e. port 0), the OS ends up allocating a port which is already bound and in-use. We have been seeing this issue across all macos versions we have access to (10.x through recent released 13.x). Specifically, we (or some other process) create a udp4 socket bound to wildcard and ephemeral port. Then our program attempts a bind on a udp46 socket with ephemeral port. The OS binds this socket to an already in use port, for example you can see this netstat output when that happens: netstat -anv -p udp | grep 51630 udp46 0 0 *.51630 *.* 786896 9216 89318 0 00000 00000000 00000000001546eb 00000000 00000800 1 0 000001 udp4 0 0 *.51630 *.* 786896 9216 89318 0 00000 00000000 0000000000153d9d 00000000 00000800 1 0 000001 51630 is the (OS allocated) port here, which as you can see has been allocated to 2 sockets. The process id in this case is the same (because we ran an explicit reproducer to reproduce this), but it isn't always the case. We have a reproducer which consistenly shows this behaviour. Before filing a feedback assistant issue, I wanted to check if this indeed appears to be an issue or if we are missing something here, since this appears to be a very basic thing.
6
1
799
Apr ’23
Info.plist Heeeeeellllp
hello. i have 3 time started a new project now I am making a app and i get a Error code on Info.plist file. I have been trying to resolve an issue with the Info.plist file in an Xcode project. The error message is "Multiple commands produce" related to the Info.plist file. I have tried several approaches to fix the issue, including: Checking the "Copy Bundle Resources" section in the "Build Phases" tab of the project settings to ensure there is only one Info.plist file listed. Deleting the Info.plist file from the project and creating a new one, then updating the reference to the Info.plist file in the "Build Settings" tab. Can anyone help me with this??
3
0
737
May ’23
Safari Extension browser.tabs.query returns invalid results
When you have a blank Safari new tab open, the browser.tabs.query API inaccurately includes those tabs in results that include a url or title in the query options. To reproduce, open several tabs, and a blank new tab. Open the background page devtools, and execute the following command: browser.tabs.query({url: 'https://github.com/'}, console.log) In addition to any potentially valid results (if you have github.com open, for example), there will also be an entry for the blank tab, which has an empty, non-matching URL. Tab { active: true, audible: false, height: 1095, highlighted: true, id: 6, incognito: false, index: 3, isArticle: false, isInReaderMode: false, mutedInfo: {muted: false}, pendingUrl: "", pinned: false, status: "complete", title: "", url: "", width: 1792, windowId: 1 } I hope that this bug can be addressed, as it causes some unexpected behavior.
1
0
655
May ’23
Promotional Offer Errors
Able to show the promotional offer, but after going through the payment process, inputting my password, and confirming the purchase, I get an error popup that says "Unable to Purchase. Contact the developer for more information." In the logs, I get the following errors: SKErrorDomain Code=12 "(null)" ASDServerErrorDomain Code=3903 "Unable to Purchase" Here are the example parameter values I am passing to the combined string appBundleId + '\u2063' + keyIdentifier + '\u2063' + productIdentifier + '\u2063' + offerIdentifier + '\u2063' + appAccountToken + '\u2063' + nonce + '\u2063' + timestamp appBundleId: com.app.myapp keyIdentifier: copied the key ID from the App Store Connect productIdentifier: product_identifier offerIdentifier: offer_identifier appAccountToken: tried both a UUID and an empty string nonce: a UUID to lowercase timestamp: UNIX timestamp How I'm generating the signature (Java) /* promotionalOfferKey = value between "-----BEGIN PRIVATE KEY-----" and "-----END PRIVATE KEY-----" from the downloaded p8 file from App Store Connect associated with the keyIdentifier parameter above */ // stringToSign = the combined string above byte[] encoded = Base64.getDecoder().decode(promotionalOfferKey); KeyFactory keyFactory = KeyFactory.getInstance("EC"); PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded); Signature ecdsaSign = Signature.getInstance("SHA256withECDSA"); ecdsaSign.initSign(keyFactory.generatePrivate(keySpec)); ecdsaSign.update(stringToSign.getBytes(StandardCharsets.UTF_8)); byte[] signature = ecdsaSign.sign(); signatureToReturn = Base64.getEncoder().encodeToString(signature); What am I doing wrong? Thank you in advance.
2
1
542
May ’23
CloudKit Stopped Syncing after adding new Entities
Can someone please shed some light? I have an app that uses Core Data and CloudKit, up until the last version, I was able to sync data between devices but now after I added two new Entities for some reason it stopped syncing between devices. Here is how I did the change: Created a new Core Data container. Added the new Entities and their Attributes Tested the new Entities locally to be able to send the new schema to CloudKit. Went to CloudKit and made sure that the new Entities and Attributes were reflected on the Developent database. Deploy Schema Cahnges. Went to the Production database to make sure the new schema was deployed; and it was, both databases look the same. Testing: Tested in the simulator and with a real device and everything syncs, even the new Entities. If I download the app from the App Store on two different devices they do NOT sync. Based on the procedure I'm describing above, is there any important step I may have missed when doing the migration? I'm not sure if this is related to the syncing issue but after testing a few times, I no longer can turn the iCloud on, I get the following message when I try to turn iCloud Sync On. CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate resetAfterError:andKeepContainer:]: <NSCloudKitMirroringDelegate: 0x282c488c0> - resetting internal state after error: Error Domain=NSCocoaErrorDomain Code=134410 "CloudKit setup failed because there is another instance of this persistent store actively syncing with CloudKit in this process." UserInfo={NSURL=file:///var/mobile/Containers/Data/Application/73F19BC7-4538-4098-85C7-484B36192CF3/Library/Application%20Support/CoreDataContainer.sqlite, NSLocalizedFailureReason=CloudKit setup failed because there is another instance of this persistent store actively syncing with CloudKit in this process., NSUnderlyingException=Illegal attempt to register a second handler for activity identifier com.apple.coredata.cloudkit.activity.setup.8D4C04F6-8040-445A-9447-E5646484521} Any idea of what could be wrong and preventing the devices from syncing? Any idea or suggestion is welcome. Thanks
3
0
1.8k
May ’23
Color asset test not working due to color not being loaded when test conditions are evaluated
I've written a Swift package plugin to add the colours provided in the asset bundles in an extension of the SwiftUI Color type but I'm having difficulties testing this since the bundle and/or colour that is in the asset catalogs are not yet loaded when XCTest goes to evaluate the test conditions. Here is my test code: (colours are just random colours, some derive from macOS colour picker; also, the new static method is functionality that I added and is not present in the existing Color APIs) final class TestCase: XCTestCase { func testBanana() { XCTAssertEqual(Color.banana, Color.new(from: "FEFC78")!) } func testAlexsColor() { XCTAssertEqual(Color.alexsColor, Color.new(from: "0432FF")!) } func testMaximumPowerColor() { XCTAssertEqual(Color.maximumPower, Color.new(from: "FF2600")!) } func testLongNameColor() { XCTAssertEqual(Color.reallyLongNameThatJustKeepsGoingOnAndOnAndOnAndOn, Color.new(from: "AAA000")) } } Here is an example error message that I get when I run the test: testBanana(): XCTAssertEqual failed: ("NamedColor(name: "Banana", bundle: Optional(NSBundle &lt;/Users/trevorhafner/Library/Developer/Xcode/DerivedData/TransportBase-cbagdabrompfzofwkimswvlsincu/Build/Products/Debug/TransportBaseTests.xctest/Contents/Resources/TransportBase_TransportBaseTests.bundle&gt; (not yet loaded)))") is not equal to ("#FEFC78FF") Here is the autogenerated code that my Swift Package Plugin creates: #if canImport(SwiftUI) import SwiftUI import Foundation @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public extension Color { static let banana = Color("Banana", bundle: .module) static let alexsColor = Color("Alex's Color", bundle: .module) static let reallyLongNameThatJustKeepsGoingOnAndOnAndOnAndOn = Color("really long name that just keeps going on and on and on and on", bundle: .module) static let maximumPower = Color("Maximum Power", bundle: .module) } #endif Does anyone know how to somehow instruct the bundle or the Color to load such that the comparison can be made correctly between the two colours?
4
1
1.5k
May ’23
How long does Apple Watch keep HealthKit data?
I would like to create an Apple Watch only app that queries data such as blood oxygenation, heart varibility, number of steps, energy consumed, and other data of a similar nature recorded over the past month and performs calculations on them. I read from the HealthKit documentation that Apple Watch synchronizes data with iPhone and periodically deletes older data, and that I can get the date from which the data is available with earliestPermittedSampleDate(). Is there a risk that in general, by making queries to retrieve data up to a month old, the data will no longer be available? I need the app to work properly without needing an iPhone.
4
0
757
Jun ’23
NFCTagReaderSession - Missing required entitlement
Hi there, I am using Core NFC and I established the connection with the card, (it means that the info.plist is correct and the entitlement should be correct as well). The app detects the card, but after sending the command 'tag.sendCommand()' I receive this message: [CoreNFC] -[NFCTagReaderSession transceive:tagUpdate:error:]:879 Error Domain=NFCError Code=2 "Missing required entitlement" UserInfo={NSLocalizedDescription=Missing required entitlement} So, what is missing or what am I doing wrong? Here is the code: func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) { guard !tags.isEmpty else { return } let hexString = //... if case let .iso7816(tag) = tags[0] { session.connect(to: tags[0]) { error in if let error = error { print("Error: \(error.localizedDescription)") return } let apdu = hexString.convertToAPDU() tag.sendCommand(apdu: apdu) { (response: Data, sw1: UInt8, sw2: UInt8, error: Error?) in // -> here is when the error appears, in the completion print([UInt8](response)) // print -> [] } } } }
3
1
1.2k
Jun ’23
Xcode beta 15.0 beta 2 cannot connect to iPhone SE running iOS 17.0 beta
macOS Version 13.4.1 (Build 22F82) Xcode 15.0 (22181.22) (Build 15A5161b) iPhone SE running iOS 17.0 beta I have a test device (iPhone SE) with iOS 17 beta installed. I am using a cable to connect it to my MacBook. Within Xcode beta, I am using the "Devices and Simulators" dialog. Attempting to "connect" the device fails repeatedly with the following message: The developer disk image could not be mounted on this device. Domain: com.apple.dt.CoreDeviceError Code: 12040 Failure Reason: Error mounting image: 0xe8000106 (kAMDMobileImageMounterCredentialsFailed: AppleConnect authentication failed or was cancelled.) User Info: { DDIPath = "/Users/***/Library/Developer/DeveloperDiskImages/iOS_DDI.dmg"; DVTErrorCreationDateKey = "2023-06-23 17:08:18 +0000"; "com.apple.dt.DVTCoreDevice.operationName" = enablePersonalizedDDI; } -- Error mounting image: 0xe8000106 (kAMDMobileImageMounterCredentialsFailed: AppleConnect authentication failed or was cancelled.) Domain: com.apple.mobiledevice Code: -402652922 User Info: { FunctionName = AMDeviceRemoteMountPersonalizedBundle; LineNumber = 2108; } -- AMAuthInstallRequestSendSync failed: 22 (kAMAuthInstallErrorAppleConnectAuthFailed) Domain: com.apple.mobiledevice Code: -402652922 User Info: { FunctionName = "-[PersonalizedImage mountImage:]"; LineNumber = 2005; } -- I also see the following error from the phone's console: Sending response: { DetailedError = "Error Domain=com.apple.MobileStorage.ErrorDomain Code=-2 \"Failed to copy personalization manifest.\" UserInfo={NSLocalizedDescription=Failed to copy personalization manifest., NSUnderlyingError=0x7a6a07b80 {Error Domain=com.apple.MobileStorage.ErrorDomain Code=-2 \"Failed to retrieve personalization manifest: Error Domain=com.apple.MobileStorage.ErrorDomain Code=-2 \"Failed to find a cached manifest (im4m) for variant DeveloperDiskImage (personalization required).\" UserInfo={NSLocalizedDescription=Failed to find a cached manifest (im4m) for variant DeveloperDiskImage (personalization required)., NSUnderlyingError=0x90ab04240 {Error Domain=com.apple.MobileStorage.ErrorDomain Code=-2 \"/private/var/run/mobile_image_mounter/DeveloperDiskImage/B5A2B06AE07F3A280BC168DCAFE0D3BADD8CFCAA017BE5C735299D5398807133F23C61593439B0B93C4B772168E8F711.im4m does not exist.\" UserInfo={NSLocalizedDescription=/private/var/run/mobile_image_mounter/DeveloperDiskImage/B5A2B06AE07F3A280BC168DCAFE0D3 I have tried the usual things: Restarting Xcode. Restarting the iPhone. Logging in/out from iCloud on the iPhone. Logging in/out of Apple Developer within Xcode. Restarting my MacBook. Burning sage and making an incantation.
9
1
4.4k
Jun ’23
Migrating to WidgetKit, issues with editing Watch Faces on iPhone
Anyone who has successfully migrated to using WidgetKit for their Apple Watch complications, your help would be greatly appreciated! I've migrated to WidgetKit for my Watch app. On the Apple Watch Face Editor, the new Widget names and options appear correctly. However, on the iPhone Apple Watch app, it offers both WidgetKit and old ClockKit complications... this should not be. I also have found rendering issues where Watch Faces on the main My Watch tab have blank gaps for WidgetKit complications, when selecting the Watch Face they then render (see photos) I've put in a feedback FB12460375 Have tried a full clear and reinstall of my app on both devices, no change. This issue occurs on WatchOS 9.5.2 / iOS 16.5.1 and WatchOS 10 Beta 2 / iOS 17 Beta 2 Any other ideas?
5
0
997
Jun ’23