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

Posts under Core OS subtopic

Post

Replies

Boosts

Views

Activity

Why is using clonefile for a folder strongly discouraged?
As a part of the video editing app I’m working on, I want to efficiently copy a folder of resources on the same (local) filesystem. Because iOS is on APFS, cloning (CoW) is an option. I read the documentation for clonefile(2) which states that cloning a folder works but is strongly discouraged. I did a small sample project which demonstrates that using clonefile on a folder works correctly and is 10× faster than using FileManager’s copyItem method. My questions: The main one I’m interested in: Why is using clonefile for a folder strongly discouraged? Is FileManager using cloning behind the scenes? Or more exactly how guaranteed are we it will use it? (I know it does, I tried manually cping the resources and it was thousands of times slower.)
2
0
90
May ’25
public API which allows to get information about APFS
Hello, I am working on a daemon which collects information about disk space usage on macOS. APFS has quite complex structure and there is a challenge to get detailed info. My application must provide disk usage by APFS containers. Are there any recommended way to get space usage by particular APFS volume? Are there any recommended way to get free space on particular APFS container? Are there any recommended way to enumerate APFS containers and volumes? I am using Disk Arbitration to get APFS info. However, I get restricted info about space usage because I get get disk usage for mounted volumes only. Are there any public API (daemon-safe) which allows to easily get disk space usage on macOS? Thank you in advance, Pavel
6
0
94
May ’25
How to tell if FileProvider Extension is enabled, programatically?
I tried using Pluginkit via terminal to determine if a File Provider Extension is enabled on Mac OS. Although I see the extension listed in the output of pluginkit -m, The status of + or - doesn't seem to change in this output when I disable or enable the FileProvider extension in System Settings. Is there a more reliable way to determine if the extension is enabled ?
1
0
76
May ’25
NFC HCE CardSession.isSupported crash
I am getting report of a crash occurring, while doing a NFC HCE CardSession. The swift code is mostly the same as the example from the CardSession docs: @objc func deviceSupportsNFC (_ call: CAPPluginCall) { call.keepAlive = true let supportsNFCCallbackId = call.callbackId! Task() { guard NFCReaderSession.readingAvailable, CardSession.isSupported, // <-- line 86 await CardSession.isEligible else { print(TAG + " HCE not allowed/available") var support = JSObject() support["supported"] = false; let callback = bridge?.savedCall(withID: supportsNFCCallbackId) call.resolve(); callback?.resolve(support); return; } print(TAG + " HCE allowed") var support = JSObject() support["supported"] = true; let callback = bridge?.savedCall(withID: supportsNFCCallbackId) call.resolve(); callback?.resolve(support); } } Calling it from my plugin, to verify if (HCE) NFC is supported: if(await deviceInfoService.isIos()) { if(iosSupportEnabled === false) { console.log("NfcHceService:iOS but disabled"); return; } this.requiresManualTrigger = true; DfsNfcHce.deviceSupportsNFC((supportObj) => { const support = supportObj?.supported ?? false; this.hceSupported = support; }); } else { this.hceSupported = true; } The crash report i get via Crashlytics is below. It's specifying the error occurs at line 86 (marked it in my code above) The error seems to be in the CoreNFC (NFCHardwareManager areFeaturesSupported). # Crashlytics - Stack trace # Application: com.wodanbrothers.dyflexis # Platform: apple # Version: 2025.04.101356 (1744977392) # Issue: c3a293fbfa73c64f59f92c4b4cdfeb83 # Session: 5c64465c452c41e3abb1ba9f970b54c0_DNE_0_v2 # Date: Wed May 07 2025 07:56:11 GMT+0200 (Central European Summer Time) Fatal Exception: NSInvalidArgumentException 0 CoreFoundation 0x11a2ec __exceptionPreprocess 1 libobjc.A.dylib 0x31a7c objc_exception_throw 2 CoreFoundation 0x18467c +[NSObject(NSObject) _copyDescription] 3 CoreFoundation 0x31b84 ___forwarding___ 4 CoreFoundation 0x314f0 _CF_forwarding_prep_0 5 CoreNFC 0x2ac40 -[NFCHardwareManager areFeaturesSupported:outError:] 6 CoreNFC 0x2b184 -[NFCHardwareManager areFeaturesSupported:expiry:completion:] 7 CoreNFC 0x2f9d8 block_destroy_helper.5 8 Dyflexis 0x5c08 closure #1 in DfsNfcHcePlugin.deviceSupportsNFC(_:) + 86 (DfsNfcHcePlugin.swift:86) 9 Dyflexis 0x7f8d <deduplicated_symbol> 10 Dyflexis 0x7725 specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) (<compiler-generated>) 11 Dyflexis 0x77fd <deduplicated_symbol> 12 libswift_Concurrency.dylib 0x65241 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError ... Crashed: com.google.firebase.crashlytics.ios.exception 0 FirebaseCrashlytics 0x1b658 FIRCLSProcessRecordAllThreads + 172 1 FirebaseCrashlytics 0x1ba64 FIRCLSProcessRecordAllThreads + 1208 2 FirebaseCrashlytics 0x13adc FIRCLSHandler + 48 3 FirebaseCrashlytics 0xe9d4 __FIRCLSExceptionRecord_block_invoke + 92 4 libdispatch.dylib 0x1b584 _dispatch_client_callout + 16 5 libdispatch.dylib 0x11728 _dispatch_lane_barrier_sync_invoke_and_complete + 56 6 FirebaseCrashlytics 0xe260 FIRCLSExceptionRecord + 204 7 FirebaseCrashlytics 0xe4f8 FIRCLSExceptionRecordNSException + 452 8 FirebaseCrashlytics 0xdeb8 FIRCLSTerminateHandler() + 396 9 libc++abi.dylib 0x158b4 std::__terminate(void (*)()) + 16 10 libc++abi.dylib 0x18e1c __cxa_get_exception_ptr + 86 11 libc++abi.dylib 0x18dc4 __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 90 12 libobjc.A.dylib 0x31be4 objc_exception_throw + 448 13 CoreFoundation 0x18467c +[NSObject(NSObject) _copyDescription] + 362 14 CoreFoundation 0x31b84 ___forwarding___ + 1492 15 CoreFoundation 0x314f0 _CF_forwarding_prep_0 + 96 16 CoreNFC 0x2ac40 -[NFCHardwareManager areFeaturesSupported:outError:] + 364 17 CoreNFC 0x2b184 -[NFCHardwareManager areFeaturesSupported:expiry:completion:] + 96 18 CoreNFC 0x2f9d8 block_destroy_helper.5 + 8028 19 Dyflexis 0x5c08 closure #1 in DfsNfcHcePlugin.deviceSupportsNFC(_:) + 86 (DfsNfcHcePlugin.swift:86) 20 libswift_Concurrency.dylib 0x5c134 swift::runJobInEstablishedExecutorContext(swift::Job*) + 292 21 libswift_Concurrency.dylib 0x5d5c8 swift_job_runImpl(swift::Job*, swift::SerialExecutorRef) + 156 22 libdispatch.dylib 0x13db0 _dispatch_root_queue_drain + 364 23 libdispatch.dylib 0x1454c _dispatch_worker_thread2 + 156 24 libsystem_pthread.dylib 0x4624 _pthread_wqthread + 232 25 libsystem_pthread.dylib 0x19f8 start_wqthread + 8 ...
1
0
45
May ’25
Mac App Store TestFlight not available when using non-Xcode developer tools
@Quinn, The application which is not made with Xcode, has a provision profile, but App Store Connect says "Not Available for Testing". My Googlefu appears weak as I can't seem to figure out why this is, except that it mentions you need to be using Xcode 13 or newer. Am guessing Xcode is adding some meta data to the Info.plist file which TestFlight requires. Is it possible to know which keys and values are required to satisfy TestFlight? If it's not plist keys, is there something else that's needed, that can be shared? We can do this privately if desired.
2
0
1.3k
May ’25
Terminal Command to get the same file count as Get Info in finder
Hi All, I am looking for a terminal command to get the exact same output as the file count you recieve when using Get Info in finder. The closest i can get is using the find command with flags: find 'path/to/folder' -not -path '*/\.*' -and -not -path '*\.key/*' -and -not -path '*\.numbers/*' -and -not -path '*\.pages/*' -and -not -path '*__MACOSX/*' -and -not -path '*\.pdf/*' -and -not -path '*\.app/*' -and -not -path '*\.rtfd/*' | wc -l I will be searching on an external volume that sometimes produces keynote save files that finder sometimes sees as a package and sometimes sees as a folder. If a folder finder counts the items contained if a package it doesn't, I need the command or script to mimic this behaviour. In the example of the screenshot get info on the top folder produces a count of 14 and the find command produces a count of 23. There are also other behaviours that differ the file count between them but i'm not sure what causes them. Any help on a solution it being a command or script would be much apreciated. Thanks, James
1
0
75
May ’25
Matter request extension no long working for Thread devices
My app has been working fine until just recently, now it can not add Matter devices over Thread (Wifi commissioning still works). I didn't change anything on my side, so not sure if an update maybe changed things? In any case, reading through my logs (and i have the matter/thread debug profiles installed). it seems like the device is added to the thread network fine, and it looks to me like the phone is successfully commissioning the device to the Apple setup fabric, but then it seems to choke on this line and i don't think the device is actually added to the keychain/matter db, so it fails later on . error 12:18:03.369036-0700 homed [2610726604/1195614123(679130348)] failed to find metric hmmtrAccessoryMetricNameCommissioningAccessory to complete I can confirm the device does join my thread border router as its pingable, and it does not seem to be in setup mode anymore (light stops flashing), so i assume it thinks its commissioned. The device i'm pairing is a Onvis (matter certified) outlet to an espressif build of a OTBR. My phone is running 18.4.1 if that matters (no pun intended) . I have also cleared out existing Matter pairings from the phone, as well ensured the device was factory reset before every try. Here is a snippet of the log towards the end where is looks like pairing works, but then errors out. I would post more but my post has a 7k character limit. default 12:18:02.836555-0700 homed Success status report received. Session was established default 12:18:02.836734-0700 homed SecureSession[0x9bb100f00, LSID:64711]: State change 'kEstablishing' --> 'kActive' default 12:18:02.837438-0700 homed Successfully finished commissioning step 'kFindOperationalForStayActive' default 12:18:02.837467-0700 homed Commissioning stage next step: 'kFindOperationalForStayActive' -> 'ICDSendStayActive' default 12:18:02.837500-0700 homed Performing next commissioning step 'ICDSendStayActive' default 12:18:02.837574-0700 homed Skipping kICDSendStayActive default 12:18:02.837627-0700 homed Successfully finished commissioning step 'ICDSendStayActive' default 12:18:02.837650-0700 homed Commissioning stage next step: 'ICDSendStayActive' -> 'kFindOperationalForCommissioningComplete' default 12:18:02.837670-0700 homed Performing next commissioning step 'kFindOperationalForCommissioningComplete' default 12:18:02.838036-0700 homed Found an existing secure session to [2:000000009B9C86CC]! default 12:18:02.838149-0700 homed Successfully finished commissioning step 'kFindOperationalForCommissioningComplete' default 12:18:02.838697-0700 homed Commissioning stage next step: 'kFindOperationalForCommissioningComplete' -> 'SendComplete' default 12:18:02.838893-0700 homed Performing next commissioning step 'SendComplete' default 12:18:02.839092-0700 homed <<< [E:35494i S:64711 M:193726318] (S) Msg TX from 0000000086BCA241 to 2:000000009B9C86CC [47A0] [UDP:[fd01:11b8:de1c:1:968a:c465:6fe8:e12a]:5540] --- Type 0001:08 (IM:InvokeCommandRequest) (B:59) default 12:18:02.839133-0700 homed ??1 [E:35494i S:64711 M:193726318] (S) Msg Retransmission to 2:000000009B9C86CC scheduled for 2910ms from now [State:Active II:800 AI:800 AT:4000] default 12:18:02.839257-0700 homed <<< [E:35493i S:0 M:19014618 (Ack:7538941)] (U) Msg TX from 3251BD376C43B658 to 0:0000000000000000 [0000] [UDP:[fd01:11b8:de1c:1:968a:c465:6fe8:e12a]:5540] --- Type 0000:10 (SecureChannel:StandaloneAck) (B:26) default 12:18:03.356373-0700 homed >>> [E:35494i S:64711 M:174417481 (Ack:193726318)] (S) Msg RX from 2:000000009B9C86CC [47A0] to 0000000086BCA241 --- Type 0001:09 (IM:InvokeCommandResponse) (B:70) default 12:18:03.356559-0700 homed Received Command Response Data, Endpoint=0 Cluster=0x0000_0030 Command=0x0000_0005 default 12:18:03.356584-0700 homed Received CommissioningComplete response, errorCode=0 default 12:18:03.356622-0700 homed Successfully finished commissioning step 'SendComplete' default 12:18:03.356648-0700 homed Commissioning stage next step: 'SendComplete' -> 'Cleanup' default 12:18:03.356746-0700 homed Performing next commissioning step 'Cleanup' default 12:18:03.356803-0700 homed Successfully finished commissioning step 'Cleanup' default 12:18:03.356916-0700 homed Closing all BLE connections default 12:18:03.357084-0700 homed Auto-closing end point's BLE connection. default 12:18:03.358146-0700 homed SecureSession[0x9bb1003c0, LSID:64710]: State change 'kActive' --> 'kPendingEviction' default 12:18:03.358652-0700 homed Commissioning complete for node ID 0x000000009B9C86CC: success default 12:18:03.358678-0700 homed <MTRDeviceController_Concrete: 0x9b8e33100, uuid: 3F6C2281-D873-4D82-BE3E-722446EA66E7, suspended: NO> DeviceControllerDelegate Commissioning complete. NodeId 0x000000009b9c86cc Status src/controller/CHIPDeviceController.cpp:2932: Success ... default 12:18:03.367999-0700 homed <MTRDeviceController_Concrete: 0x9b8e33100, uuid: 3F6C2281-D873-4D82-BE3E-722446EA66E7, suspended: NO> 1 delegates called for -[MTRDeviceController controller:commissioningComplete:nodeID:metrics:] error 12:18:03.369036-0700 homed [2610726604/1195614123(679130348)] failed to find metric hmmtrAccessoryMetricNameCommissioningAccessory to complete error 12:18:03.426636-0700 HomeUIService Unexpected accessory setup progress CASE Session Sanity Check Passed default 12:18:03.426850-0700 homed Could not find home with valid fabric ID corresponding to fabric UUID: FB19AA02-5E34-40C5-BB9D-B1B1AF51E08B ... error 12:18:03.460841-0700 homed [188914BD-5163-425C-9E59-CAE9BFA1A288] Could not find system commissioner pairing for newly staged server with identifier f1:64:16:3f:79:b8 in all pairings: ( .. default 12:18:03.460906-0700 homed Answering incoming message HMASC.m.confirmDeviceCredential (186EE57F-330B-435F-A949-0E4C5D6954AB) from client 'HomeUIService' that expects a response with error Error Domain=HMErrorDomain Code=2 "(null)" error 12:18:03.461167-0700 HomeUIService [BD890E19] Failed to stage CHIP accessory pairing in steps: Error Domain=HMErrorDomain Code=2 "(null)" error 12:18:03.462121-0700 HomeUIService -[HSSetupStateMachineCHIPPartnerConfiguration stageCHIPAccessory]_block_invoke Failed to stage CHIP accessory: Error Domain=HMErrorDomain Code=2 "(null)" default 12:18:03.462172-0700 HomeUIService -[HSSetupStateMachineConfiguration setPairingError:] *** Setting pairingError *** = Error Domain=HMErrorDomain Code=2 "(null)"
3
0
100
May ’25
Manufacturer data is duplicated in extended adverts
While implementing the extended adverts scanning, I noticed that фfter some time from the start of scanning(CBCentralManagerScanOptionAllowDuplicatesKey is true), the manufacturer data is duplicated. The first part is the actual data, and the second part is the same bytes that the device sent about 10 seconds before. This replicates on iPhone 11 - 14 but does not work on 16 Pro. I also saw the same behavior in third party BLE scanning applications. We also tried increasing the interval between sending adverts by the device and got the same result Does anyone know what the problem could be?
1
0
85
May ’25
get space which is used on an APFS volume
Hello, I am trying to get space which is consumed by APFS volume. The call getattrlist() works fine on macOS 15 (Apple silicon). However, it returns EINVAL on macOS 11.7.10 (Intel) if ATTR_VOL_SPACEUSED is defined. struct VolAttrBuf { u_int32_t length; off_t spaceUsed; } __attribute__((aligned(4), packed)); int64_t GetVolumeSpaceUsed(const std::string& mountPath) { struct attrlist attrList; std::memset(&attrList, 0, sizeof(attrList)); attrList.bitmapcount = ATTR_BIT_MAP_COUNT; attrList.volattr = ATTR_VOL_INFO | ATTR_VOL_SPACEUSED; VolAttrBuf attrBuf; if (getattrlist(mountPath.c_str(), &attrList, &attrBuf, sizeof(attrBuf), 0) || attrBuf.length > sizeof(attrBuf)) { std::cout << "getattrlist() failed with errno (" << errno << ")" << std::endl; return -1; } return attrBuf.spaceUsed; } Is it bug or ATTR_VOL_SPACEUSED is unsupported on macOS 11? Are there any other way to get space which is used on an APFS volume? (C++) Thank you in advance, Pavel
2
0
57
May ’25
CoreHID: Enumerate all devices *once* (e.g. in a command-line tool)
I am aware the USB / HID devices can come and go, if you have a long running application that's what you want to monitor. But for a "one-shot" command-line tool for example, I would like to enumerate the devices present on a system at a certain point in time, interact with a subset of them (and this interaction can fail since the device may have been disconnected in-between enumerating and me creating the HIDDeviceClient), and then exit the application. It seems that HIDDeviceManager only allows monitoring an Async[Throwing]Stream which provides the initial devices matching the query but then continues to deliver updates, and I have no idea when this initial list is done. I could sleep for a while and then cancel the stream and see what was received up to then, but that seems like the wrong way to go about this, if I just want to know "which devices are connected", so I can maybe list them in a "usage" or help screen. Am I missing something?
7
0
113
May ’25
Xcode project that runs only once under xcode
I have an xcode project that runs fine under xcode the first time, but if I try to run it a second time it fails in trying to open a directory (as part if the observable view data in the view's environment). It throws an error saying "Interupted system call". I have no idea how to debug something like this, so any help would be welcomed. Thanks in advance, Rick
8
0
80
May ’25
installing a SMAppService based LaunchDaemon from the command line
our app has a helper to perform privileged operations. previously that helper was installed via SMJobBless() into the /Library/LaunchDaemons/ and /Library/PrivilegedHelperTools/ we also had a script that would install the helper from the command-line, which was essential for enterprise users that could not manually install the helper on all their employee's Macs. the script would copy the files to their install location and would use launchctl bootstrap system as the CLI alternative to SMJobBless(). the full script is here: https://pastebin.com/FkzuAWwV due to various issues with the old SMJobBless() approach we have ported to helper to the new SMAppService API where the helpers do not need to be installed but remain within the app bundle ( [[SMAppService daemonServiceWithPlistName:HELPER_PLIST_NAME] registerAndReturnError:&err] ) however, we are having trouble writing a (remote-capable) CLI script to bootstrap the new helper for those users that need to install the helper on many Macs at once. running the trivial sudo launchctl bootstrap system /Applications/MacUpdater.app/Contents/Library/LaunchDaemons/com.corecode.MacUpdaterPrivilegedInstallHelperTool2.plist would just result in a non-informative: Bootstrap failed: 5: Input/output error various other tries with launchctl bootstrap/kickstart/enable yielded nothing promising. so, whats the command-line way to install a SMAppService based helper daemon? obviously 'installing' means both 'registering' (which we do with registerAndReturnError in the GUI app) and 'approving' (which a GUI user needs to manually do by clicking on the notification or by going into System Settings). thanks in advance! p.s. we wanted to submit this as a DTS TSI, but those are no longer available without spending another day on a reduced sample projects. words fail me. p.p.s. bonus points for a CLI way to give FDA permissions to the app!
5
1
737
May ’25
Why is HMAC_SHA_512 unsupported on eSIM Java Card 3.0.5 in iPhone?
We are currently working on deploying a Java Card applet onto the eSIM (eUICC) inside an iPhone. According to the GSMA SGP specifications, the eUICC is expected to support Java Card 3.0.5 Classic Edition. As defined in the Java Card 3.0.5 specification, the javacardx.crypto package should support standard algorithms including MessageDigest.ALG_HMAC_SHA_512. However, during our testing on the iPhone's embedded eSIM, we found that ALG_HMAC_SHA_512 appears to be unsupported or disabled. The same applet functions correctly on external Java Card platforms that support Java Card 3.0.5, leading us to believe that this is a restriction specific to the iPhone’s eUICC implementation. Our main questions are: Why is ALG_HMAC_SHA_512, which is part of the standard Java Card 3.0.5 specification, not available on the iPhone eSIM? Has Apple imposed any internal restrictions or exclusions on certain crypto algorithms for security, performance, or compliance reasons? Is there a list or documentation of supported and unsupported Java Card APIs or algorithms on the eUICC used in iPhones? Any insights from Apple engineers or other developers with experience on this topic would be greatly appreciated. Thank you in advance!
1
0
49
May ’25
SwiftUI FileManager MacOS moving a file
Until a few days ago, I had a bit of code that could download a file from elsewhere to my home drive, "Users/eric". Today, the code downloads the file to "locat", but the following no longer works let _ = try fileManager.copyItem(atPath: locat, toPath: "/Users/eric/file.txt" ) After a careful search, I've changed the network to allow Network connections, and set User Selected and Downloads Folder to Read/Write without any luck. I am using Catalina and SwiftUI on a recent Mac (2023). As well, it was working just a few days ago. Any ideas or pointers?
1
0
57
May ’25