Explore the core architecture of the operating system, including the kernel, memory management, and process scheduling.

Post

Replies

Boosts

Views

Activity

Host Card Emulation / Card Session for payment URL
We have a financial application where we want to use NFC to broadcast a Payment URL to another iPhone or Android device when initiating a payment transaction. This will then open the banking application installed on the recipient’s device, allowing the transaction to be completed. We have already made the necessary requests to Apple and configured the entitlements file as follows: <key>aps-environment</key> <string>development</string> <key>com.apple.developer.nfc.hce</key> <true/> <key>com.apple.developer.nfc.hce.iso7816.select-identifier-prefixes</key> <array> <string>D2760000850101</string> </array> <key>com.apple.developer.nfc.readersession.formats</key> <array> <string>TAG</string> <string>NDEF</string> </array> </dict> I've tried to use CardSession with the sample code provided by Apple on their site: Card Session The connection between the devices (two iPhones, OS is above iOS 17.4) is established, the event stream's case .received(let cardAPDU): works, however, when I send the response, nothing really happens Initial APDU response: CLA | 0x00 INS | 0xA4 P1 | 0x04 P2 | 0x00 DATA | 0x7D2760000850101 (guess this is the AID) Le | 00 Sending the apdu response in the event stream via: do { guard let request = APDUUtil.createAPDURequest(from: paymentUrl) else { return } try await cardAPDU.respond(response: request) await cardSession.stopEmulation(status: .success) } static func createAPDURequest(from paymentUrl: URL?) -> Data? { guard let paymentUrl else { return nil } let ndefMessage = APDUUtil.createNDEFMessage(from: paymentUrl) APDUUtil.updateNdefRecordFile(ndefMessage: ndefMessage) let data = Data(mNdefRecordFile) let apdu = NFCISO7816APDU(instructionClass: 0x00, instructionCode: 0xA4, p1Parameter: 0x04, p2Parameter: 0x00, data: data, expectedResponseLength: -1) // Tried with different values return apdu.data } static func createNDEFMessage(from url: URL?) -> NFCNDEFMessage? { guard let url, let payload = NFCNDEFPayload.wellKnownTypeURIPayload(url: url) else { return nil } return NFCNDEFMessage(records: [payload]) } static func updateNdefRecordFile(ndefMessage: NFCNDEFMessage?) { guard let ndefMessage else { return } // Convert the NFCNDEFMessage to Data let ndefMessageData = ndefMessage.records.reduce(Data()) { result, record -> Data in var result = result result.append(record.payload) return result } let nlen = ndefMessageData.count mNdefRecordFile = [UInt8](repeating: 0, count: nlen + 2) // Store the length in the first two bytes (big-endian format) mNdefRecordFile[0] = UInt8((nlen & 0xFF00) >> 8) mNdefRecordFile[1] = UInt8(nlen & 0xFF) // Copy the NDEF message data into the data starting at index 2 mNdefRecordFile.replaceSubrange(2..<mNdefRecordFile.count, with: ndefMessageData) } Could someone please help? I also tried to send the payment url as Data made from url. We have a working Android application, which uses HCE too (they use NDEF message and byte arrays in communication). As I've seen, the NFCNDEFReaderSessionDelegate and NFCTagReaderSessionDelegate is not suitable for communication between two iOS devices...
1
0
366
Sep ’24
Install non-sandboxed Helper app from sandboxed Main app
Hi, I developed a utility app that allows monitoring system activity and usage. It is a sandboxed app distributed via the Mac App Store. Because in the sandbox I cannot fetch enough data about system activity (like processor temperature, fans, etc.), I developed a little Helper app (non-sandboxed), which currently is distributed via my website, and to enable extra features it provides, the user is asked to download and install it manually (it installs itself as a daemon). I'm looking for ways to improve the user experience. Ideally, it would be a button inside the main app, which would download and install the helper app, without asking the user to do more than pressing a button. As far as I understand, in the previous versions of macOS, it would be possible with privileged helpers and SMJobBless, but those are deprecated APIs now. Another way I tried, is simply downloading the installer app from the website, but opening it programmatically from the main app is tricky since it cannot remove it from the quarantine, in other words, it fails with "operation not permitted". Any advice is appreciated!
4
0
362
Sep ’24
Has iOS 18 changed the threshold for decoding base64 into ASCII code?
This code fails to decode when running on iOS 18.0 or 18.1 beta device. But succeeds below iOS 18, such as iOS 17.5. Xcode Version 16.0 (16A242d) let base64String = "1ZwoNohdE8Nteis/IXl1rg==" if let decodedData = Data(base64Encoded: base64String, options: .ignoreUnknownCharacters) { if let decodedString = String(data: decodedData, encoding: .ascii) { print("Decoded string: \(decodedString)") } else { print("Failed to decode string using ascii encoding") } } else { print("Failed to decode Base64 string") }
7
0
641
Sep ’24
vnop_lookup returning ENOENT aborts rm(1)
When recursively removing a directory with a large number of entries that resides on my custom filesystem, rm(1) aborts with ENOENT. % rm -Rv /Volumes/myfs/linux-kernel/linux-6.10.6 [...] /Volumes/myfs/linux-kernel/linux-6.10.6/include/drm/bridge/aux-bridge.h /Volumes/myfs/linux-kernel/linux-6.10.6/include/drm/bridge/dw_hdmi.h rm: fts_read: No such file or directory I'm observing the following sequence of calls being made. 2024-09-17 17:58:25 vnops.c:281 myfs_vnop_lookup: rm-936 -> dw_hdmi.h ;initial lookup call 2024-09-17 17:58:25 vnops.c:315 myfs_vnop_lookup: -> cache_lookup(dw_hdmi.h) 2024-09-17 17:58:25 vnops.c:317 myfs_vnop_lookup: <- cache_lookup(dw_hdmi.h) -> 0 ;cache miss 2024-09-17 17:58:25 rpc.c:431 myfsLookup: rm-936 -> dw_hdmi.h ;do remote lookup 2024-09-17 17:58:25 rpc.c:500 myfsLookup: -> myfs_lookup_rpc(dw_hdmi.h) 2024-09-17 17:58:25 rpc.c:502 myfsLookup: <- myfs_lookup_rpc(dw_hdmi.h) -> 0 ;file found and added to vfs cache 2024-09-17 17:58:25 vnops.c:281 myfs_vnop_lookup: rm-936 -> dw_hdmi.h ;subsequent lookup call 2024-09-17 17:58:25 vnops.c:315 myfs_vnop_lookup: -> cache_lookup(dw_hdmi.h) 2024-09-17 17:58:25 vnops.c:317 myfs_vnop_lookup: <- cache_lookup(dw_hdmi.h) -> -1 ;cache hit 2024-09-17 17:58:25 vnops.c:1478 myfs_vnop_remove: -> myfs_unlink(dw_hdmi.h) ;unlink sequence 2024-09-17 17:58:25 rpc.c:1992 myfs_unlink: -> myfs_unlink_rpc(dw_hdmi.h) 2024-09-17 17:58:25 rpc.c:1994 myfs_unlink: <- myfs_unlink_rpc(dw_hdmi.h) -> 0 ;remote unlink succeeded 2024-09-17 17:58:25 vnops.c:1480 myfs_vnop_remove: <- myfs_unlink(dw_hdmi.h) -> 0 2024-09-17 17:58:25 vnops.c:1487 myfs_vnop_remove: -> cache_purge(dw_hdmi.h) 2024-09-17 17:58:25 vnops.c:1489 myfs_vnop_remove: <- cache_purge(dw_hdmi.h) 2024-09-17 17:58:25 vnops.c:1499 myfs_vnop_remove: -> vnode_recycle(dw_hdmi.h) 2024-09-17 17:58:25 vnops.c:1501 myfs_vnop_remove: <- vnode_recycle(dw_hdmi.h) 2024-09-17 17:58:27 vnops.c:281 myfs_vnop_lookup: fseventsd-101 -> dw_hdmi.h ;another lookup; why? 2024-09-17 17:58:27 vnops.c:315 myfs_vnop_lookup: -> cache_lookup(dw_hdmi.h) 2024-09-17 17:58:27 vnops.c:317 myfs_vnop_lookup: <- cache_lookup(dw_hdmi.h) -> 0 2024-09-17 17:58:27 rpc.c:431 myfsLookup: fseventsd-101 -> dw_hdmi.h 2024-09-17 17:58:27 rpc.c:500 myfsLookup: -> myfs_lookup_rpc(dw_hdmi.h) 2024-09-17 17:58:27 rpc.c:502 myfsLookup: <- myfs_lookup_rpc(dw_hdmi.h) -> ENOENT(2) 2024-09-17 17:58:27 vnops.c:371 myfs_vnop_lookup: SET(NNEGNCENTRIES): dw_hdmi.h 2024-09-17 17:58:27 vnops.c:373 myfs_vnop_lookup: ENOENT(2) <- shouldAddToNegativeNameCache(dw_hdmi.h) I checked the value of vnode's v_iocount when vnop_remove and vnop_reclaim are being called. Each vnop_remove and followed by vnop_reclaim with v_iocount set to 1 in both calls, as expected. What I don't understand is why after removing the file is there another lookup call being made, which returns ENOENT to rm(1), which causes it to abort. Any pointers on what could be amiss there would be much appreciated.
3
0
353
Sep ’24
SwiftUI @main Accessing UserDefaults Too Early Before applicationDidFinishLaunching
I'm working on a macOS and iOS app using SwiftUI. And received bug from very few user that they are being logged out, even tho they didn't. So i'm assuming issue is relevant to this forum post, and that the keychain data and user defaults aren't available very early on in an app's lifecycle (presumably from cold start). There is fix available for iOS but didn't find anything relevant to isProtectedDataAvailable for macOS. I'm accessing UserDefaults in my @main view's sub view. It seems that UserDefaults is accessed too early, before applicationDidFinishLaunching. And therefore, not getting user data on launch sometimes. This issue is very rare, i'm not able to reproduce this, but assuming this can be cause based on some form post, also because view's onAppear calls before applicationDidFinishLaunching.
3
0
261
Sep ’24
[iOS18] Crash in `static NSDecimal./ infix(_:_:)`
Crashed: com.apple.main-thread 0 Foundation 0x2bd25c specialized static NSDecimal._integerDivide(dividend:divisor:maxResultLength:) + 1996 1 Foundation 0x2c1c0c specialized NSDecimal._divide(by:roundingMode:) + 2432 2 Foundation 0x372710 static NSDecimal./ infix(_:_:) + 64 Crashed: com.um.positions.fiber.queue 0 Foundation 0x2bdc94 <redacted> + 1996 1 Foundation 0x2c2644 <redacted> + 2432 2 Foundation 0x372804 $sSo9NSDecimala10FoundationE1doiyA2B_ABtFZ + 64 After iOS18, some new crashes appeared, but they never appeared before iOS18. How to avoid such crashes? I checked the API documentation and there is no relevant modification, https://developer.apple.com/documentation/foundation/1409398-nsdecimaldivide However, I parsed iOS_22A5326g/../Foundation.framework/Foundation, and found that this EXC_BREAKPOINT is newly added You can reproduce it with the following code: let a: Decimal = .greatestFiniteMagnitude let b: Decimal = .greatestFiniteMagnitude let c = a / b // if < iOS18, c = 1. if = iOS18, will crashed ;< print(c)
3
1
554
Sep ’24
Bluetooth connection unexpectedly timing out with macOS Sequoia
After the macOS Sequoia update, my app seems to have an issue with Bluetooth communication between macOS and iOS that uses CoreBluetooth for Central-Peripheral communication. Setup: The iPhone (in my case: iPhone 14 Pro with iOS 18.0 (22A3354)) acts as the Central, and the Mac (in my case: 14" MacBook Pro 2023 with macOS 15.0 (24A335)) as the Peripheral. I’ve implemented a mechanism where the Central (iPhone) sends a message to the Peripheral (Mac) every 15 seconds to keep the connection alive (Because it needs to wait for notify characteristic updates). I never noticed this kind of issue before, but with macOS Sequoia I get it permanently. Issue: The connection drops unexpectedly after a period of time (sometimes 20 seconds, sometimes a few minutes) with CBErrorDomain - code 6: The connection has timed out unexpectedly. Sample Code: Peripheral (Mac): ContentView (Peripheral).txt ContentViewModel (Peripheral).txt Central (iPhone): ContentView (Central).txt ContentViewModel (Central).txt Reproduce: I attached sample code including the Central-Sample (for iPhone) and Peripheral-Sample (for Mac). Just run the Peripheral-Sample (after granting Bluetooth permissions). Then run the Central-Sample and select the Mac device in the list After selecting it should connect, discover the service & characteristic and should start writing messages to it. After some time the func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: (any Error)?) {should get called with timed out unexpectedly error. Could anyone please look into this issue and advise on whether there’s a known bug or any workaround? Any guidance would be greatly appreciated, as this impacts the stability of Bluetooth communication between the devices. Thanks in advance. Logs: I also ran the console.app during this issue which got these errors (if this is helpful): console_logs.txt
5
4
1.2k
Sep ’24
system crash on ios and freeze
Feedback ID: FB15148112 Hello, I have submitted a feedback on feedback assistant. I am using iphone 14 pro ios 17.5.1. Since yesterday, I can not enter settings app. and on some screens my phone crashes. While deleting an app, also system crashes. Can you look at the logs at sysdiagnose_2024.09.16_23-52-06+0300_iPhone-OS_iPhone_21F90.tar.gz ? Thank you I want to share my ticket here due to current issue is very crucial for me. Ticket: Which of the following did you encounter on-screen when the system crash occurred? Gray Loading Spinner appeared over black screen What were you doing on the device just before the crash occurred? whatever i do Please describe the issue and what steps we can take to reproduce it: when i open settings, it is not opening and also when i switch between screens it freezes and shutdown with spinner. i am very sad :( i can not use my phone. it began today morning i am software engineer, i try to find log details via xcode but i could not catch it. only localization text missings error exist on logs. but i could not find the solution. please help me thank you
1
0
229
Sep ’24
CallKit: Blocked Calls Appearing as Unanswered in iOS 18
Hello Apple Developer Community, I'm developing a call-blocking app for iOS and have encountered an issue with iOS 18. Despite calls being successfully blocked by our app's Call Directory extension, they are still appearing as unanswered calls in the native Phone app. Details: iOS version: 18 App uses CallKit and Call Directory extension Calls are blocked successfully (not ringing on device) Blocked calls show up as "Unanswered" in Phone app's recent calls list Expected behavior: Blocked calls should not appear in the Phone app's recent calls list. Actual behavior: Blocked calls appear as "Unanswered" in the recent calls list.
11
1
776
Sep ’24
Can't enroll in 15.1 beta in VM after signing into iCloud
I have created an Apple silicon macOS Sequoia VM using UTM on my Mac also running macOS Sequoia. As noted in the documentation, I can now sign-in to iCloud in the VM. I want to update the VM to macOS Sequoia 15.1 beta. (I understand that Apple Intelligence won't be available in the VM. I need to test my software.) However, when I go to Software Update in the System Settings, I am not offered the opportunity to enroll in the beta. (The "Beta Updates" section never appears.) Is this intentional?
0
1
309
Sep ’24
How to make my daemon run only in pre login mode.
Hi, I'd like to be able to run my daemon process only in pre-logon mode that can be reach by either reboot the machine prior to provide user credentials, or by log out from current user. So far I couldn't find any useful configuration in the plist file under /Library/LaunchDaemon. Perhaps there's a way to get notification programmatically for when the system enter/exit pre-login mode ? Thanks
1
0
261
Sep ’24
obtaining file creation & modified time & size failing 5-10% of time within .onOpenURL when file shared with app
When users share a file with my app I am having trouble 5-10% of the time obtaining the file meta data, specifically creation and modified time and size. Using SwiftUI with the code below.. .onOpenURL { url in var fileSize: Int64 = 0 var creationTime: Date = Date(timeIntervalSince1970: 0) var modificationTime: Date = Date(timeIntervalSince1970: 0) do { let fileAttributes = try FileManager.default.attributesOfItem(atPath: url.path) fileSize = fileAttributes[FileAttributeKey.size] as? Int64 ?? 0 creationTime = fileAttributes[FileAttributeKey.creationDate] as? Date ?? Date(timeIntervalSince1970: 0) modificationTime = fileAttributes[FileAttributeKey.modificationDate] as? Date ?? Date(timeIntervalSince1970: 0) <SNIPPED CODE no other tries though and not involving above variables> } catch { // quite confident I am ending up here because variables after the above code aren’t being set and there are no other try blocks, // so FileManager.default.attributesOfItem(atPath: url.path) must be throwing…. } <SNIPPED CODE> To attempt to resolve this, I added in a 0.5 second wait cycle if creationTime == 0 and modificationTime == 0 , so if obtaining both metadata fails, wait 0.5 seconds and try again, try this a max of 3 times and then give up. I don’t know how often I am entering this code (didn’t instrument the app for it), but am still getting times when metadata comes back blank which means this code wasn’t successful after 3 tries. I assume the file would only become visible and sharable with my app after it has completed being written by the original app/process. Perhaps it hasn’t finalized yet? Is there a way to detect this so I can tell the user in my share screen to wait and try again? I am assuming that the file has finished writing though since when I read the data from the file contents, it’s good data and complete even when metadata failed. I will be instrumenting the above code in my next app version, just hoping to fix it right now since users are emailing saying my app is broken. Thanks!
3
0
392
Sep ’24
com.apple.root.default-qos EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000020
Crashed: com.apple.root.default-qos 0 libobjc.A.dylib 0x275c objc_release + 16 1 libobjc.A.dylib 0x275c objc_release_x0 + 16 2 libobjc.A.dylib 0x5acc object_cxxDestructFromClass(objc_object*, objc_class*) + 116 3 libobjc.A.dylib 0x4f00 objc_destructInstance + 80 4 libobjc.A.dylib 0x4ea4 _objc_rootDealloc + 80 5 CoreServices 0x47f0 std::__1::__hash_table<std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::__unordered_map_hasher<objc_selector*, std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::hash<objc_selector*>, std::__1::equal_to<objc_selector*>, true>, std::__1::__unordered_map_equal<objc_selector*, std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::equal_to<objc_selector*>, std::__1::hash<objc_selector*>, true>, std::__1::allocator<std::__1::__hash_value_type<objc_selector*, objc_object* __strong> > >::__deallocate_node(std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, void*>>) + 36 6 CoreServices 0x47ac std::__1::__hash_table<std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::__unordered_map_hasher<objc_selector*, std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::hash<objc_selector*>, std::__1::equal_to<objc_selector*>, true>, std::__1::__unordered_map_equal<objc_selector*, std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::equal_to<objc_selector*>, std::__1::hash<objc_selector*>, true>, std::__1::allocator<std::__1::__hash_value_type<objc_selector*, objc_object* __strong> > >::~__hash_table() + 28 7 CoreServices 0x4760 -[LSRecord dealloc] + 36 8 CoreServices 0x472c -[LSBundleRecord dealloc] + 72 9 CoreServices 0x1bb7c -[LSApplicationProxy .cxx_destruct] + 60 10 libobjc.A.dylib 0x5acc object_cxxDestructFromClass(objc_object*, objc_class*) + 116 11 libobjc.A.dylib 0x4f00 objc_destructInstance + 80 12 libobjc.A.dylib 0x4ea4 _objc_rootDealloc + 80 13 CoreServices 0xb42d4 +[LSBundleProxy clearBundleProxyForCurrentProcess] + 48 14 CoreServices 0xb436c __45+[LSBundleProxy bundleProxyForCurrentProcess]_block_invoke.21 + 36 15 libdispatch.dylib 0x3dd4 _dispatch_client_callout + 20 16 libdispatch.dylib 0x72d8 _dispatch_continuation_pop + 600 17 libdispatch.dylib 0x1b1c8 _dispatch_source_latch_and_call + 420 18 libdispatch.dylib 0x19d8c _dispatch_source_invoke + 832 19 libdispatch.dylib 0x6dc4 _dispatch_queue_override_invoke + 504 20 libdispatch.dylib 0x15894 _dispatch_root_queue_drain + 392 21 libdispatch.dylib 0x1609c _dispatch_worker_thread2 + 156 22 libsystem_pthread.dylib 0x48f8 _pthread_wqthread + 228 23 libsystem_pthread.dylib 0x10cc start_wqthread + 8
1
0
160
Sep ’24
Callkit blocking behaviour is overridden in iOS 18
In iOS 18 if a number is registered with CallKit to be blocked, then if that number is also in contacts, then the number isn't blocked. If a user has added a number to their contacts, then in all probability they might not want the number blocked, so this might seem reasonable behaviour. However the point is, this is new behaviour for CallKit in iOS 18, and its never been like this before going back several years to the very first release. Why suddenly change it now, after all these years, without notice nor documentation, and take away that option from the user, should for some reason, they want to block a number which is also in their contacts. This is quite a disruptive change for apps using CallKit.
8
0
715
Sep ’24
handling files offloaded to iCloud?
My app saves its document files by default into ~/Documents. It does some important domain-specific stuff when a document is deleted. I monitor for deletion using https://github.com/eonist/FileWatcher Unfortunately several users have noticed my app doing this cleanup work even when they have not deleted the corresponding document. We've traced it through and realised it's the iCloud "Optimise Mac Storage" feature, or "Store in iCloud &gt; Desktop and Documents". I'm not sure which because I don't use these features of macOS at all, and also they seem to have been renamed or changed in Sonoma. Either way, I'm wondering: a) how I can tell in Swift whether a file has actually been deleted, or whether it's been "offloaded" to iCloud by macOS. b) how can I test this? My research is pointing at urlubiquitousitemdownloadingstatus but it's hard to play with it without knowing how to test it.
2
0
369
Sep ’24