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

Post

Replies

Boosts

Views

Activity

API to fetch dhcpv6 information
I am trying to fetch DHCP server identifiers of the current network. For IPv4 I am able to get this information using SCDynamicStoreCopyDHCPInfo and then using DHCPInfoGetOptionData fetching option 54. I am trying to do the same thing for IPv6, in my scutil I do see DHCPv6 present. Is there any API present which fetches this information for v6 DHCP servers, or do I have to get this direct from scutil?
5
0
291
Sep ’24
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
360
Sep ’24
Bluetooth State Restoration: Relaunch app after update?
Hi. Background: We have an app acting as central, keeping a persistent connection to a peripheral body worn sensor, in order to ensure that the sensor behaves as expected. We've managed make a robust system, that stays connected while the peripheral is in range. When the peripheral gets out of range we're fine with the app being suspended, as long as it's revived when the sensor gets back in range. This works fine using the Restoration Identifier This revival works also works fine after a phone restart. Now for the question: It doesn't work when upgrading the app. (tested in testflight) As the App Upgrade case isn't specified in: https://developer.apple.com/library/archive/qa/qa1962/_index.html we'd like to know if this case is supported. If it is supported, we'd be happy if you could provide some additional insights. Best Regards Rasmus Tønnesen UNEEG medical
2
0
190
Sep ’24
How to allow my app to receive BLE data from sensor while running in background?
I have a sensor that communicates via BLE periodically. The intention is for it to be a set it and forget it kind of thing. The user will check the app periodically but won't be doing so frequently. I need the app to be able to still receive the BLE data from the sensor even if it's running in the background so that when the user does check the app, they can see everything that's been happening. I've read a lot from 2020 - 2021 where it seems many developers are struggling with the same issue. Is there a supported way to do this now? How to have my app run in the background and still be able to receive BLE data?
1
0
219
Sep ’24
Message filter extension doesn't run on iOS 18
If I run an app with a message filter extension on < iOS 18 everything is as expected, if I run the same app, without any changes on iOS 18 then it doesn't work. I've discovered that problems occur if the extension has the following code: extension MessageFilterExtension: ILMessageFilterQueryHandling, ILMessageFilterCapabilitiesQueryHandling { func handle(_ capabilitiesQueryRequest: ILMessageFilterCapabilitiesQueryRequest, context: ILMessageFilterExtensionContext, completion: @escaping (ILMessageFilterCapabilitiesQueryResponse) -> Void) { let response = ILMessageFilterCapabilitiesQueryResponse() response.transactionalSubActions = [.transactionalCarrier, .transactionalHealth, .transactionalPublicServices, .transactionalFinance, .transactionalWeather, .transactionalRewards, .transactionalOrders, .transactionalOthers, .transactionalReminders] response.transactionalSubActions = [.transactionalFinance, .transactionalOrders, .transactionalHealth] completion(response) } This code doesn't run on iOS 18, however the following code does run on iOS 18: let response = ILMessageFilterCapabilitiesQueryResponse() completion(response) I downloaded several apps from the app store which provide message filtering, within the Message app they all had one thing in common, on < iOS 18 they all show 12 filtering categories, but within iOS 18 they only show 2. So it seems the issue is endemic and effects other apps, not just mine.
3
1
329
Sep ’24
iOS 18 crash
Bootstrapping failed for <FBApplicationProcess: 0x52ed3f180; app:> with error: <NSError: 0x3020c42a0; domain: RBSRequestErrorDomain; code: 5; "Launch failed."> { NSUnderlyingError = <NSError: 0x3020c4630; domain: NSPOSIXErrorDomain; code: 85> { NSLocalizedDescription = Launchd job spawn failed; }; }
1
0
231
Sep ’24
Issue with IOServiceOpen
I have an app that is used to control features of a device with a driverkit driver. I am having trouble creating a connection a certain device. The Sample code from "Communicating between a DriverKit extension and a client app. The sample code shows: ret = IOServiceGetMatchingServices(kIOMainPortDefault, IOServiceNameMatching(kDextIdentifier), &iterator); I cannot use kDextIdentifier but need to find a service with a certain BSD Name. So in this case I try: ret = IOServiceGetMatchingServices(kIOMainPortDefault, IOBSDNameMatching(kIOMasterPortDefault, NULL, interface), &iterator); In each case the call completes correctly, and we get an iterator. I can also use IOServiceGetMatchingService with IOBSDNameMatching, and that completes correctly as well. However when I attempt IOServiceOpen with the first case, the connection is created correctly. However, I have four of these in the machine, and I need to select the service and subsequently connection for a certain BSD name. When I attempt the IOServiceOpen with the second/third calls, the IOServiceOpen call fails with error 0x2c7 which is unsupported. Is there an entitlement I need to make this work?
1
0
219
Sep ’24
Need Help! ANCS Client
Hi I am looking for examples where a BLE Device (ESP32 or Arduino) can be a BLE Client and subscribe to iPhone ANCS Services. Unfortunately my code is UNABLE TO FIND my iPhone device even after scanning for nearby BLE Devices. ANCS Documentation (Not helpful): https://developer.apple.com/library/archive/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Specification/Specification.html I am able to create a BLE Device as a server but I am looking to subscribe to incoming call notifications. PLEASE HELP if you have done this before. Thanks
2
0
214
Sep ’24
Matter pairing without Matter client developer profile
To be able to paire a matter device on ios I need to installed on my iPhone the matter client developper profile as indicate on the apple documentation Adding Matter support to your ecosystem | Apple Developer Documentation (To test your app on the iOS or macOS device that initiates the pairing, download the developer profile now, then install it.) When I do that it works perfectly. Otherwise the documentation says that the profile is only needed for development but when I want to use my app from the apple store (validate by Apple) and when I remove the profile it doesn't work anymore. What do I have to do to paire Matter device on iphone without the Matter client developer profile.
12
1
1.9k
Jul ’23
FileProvider Extension's Version is not matching in Mac
Hello, I would like to know why my FileProvider. apex application cannot run on a Mac OS 12.0 computer after I compiled it on Mac OS 4.5. I have changed the macOS Deployment Target and Minimum Deployment in the XCode configuration file to 11.0, but it still cannot run The error is as follows:  2024-09-23 10:10:24.264067+0800 0xab312 Error 0x0 83438 0 O+Connect: (libFileProviders Manager. dylib) [com. oplus. DeviceSpace: FileProviders Manager] Unable to add domain, error: Error Domain=NSFileProviders Error Domain Code=-2001 "The application is currently unavailable. UserInfo={NSLocalizedDescription=The application is currently unavailable.} I want to know what this error means and how to solve it
2
0
233
Sep ’24
App using audio background mode gets suspended
Hi. I am developing an alarm app. My app plays white noise to help users get into sleep properly. To keep white noise playing in the background, my app uses audio background mode. The problem is that my app sometimes gets suspended few hours after getting into background. I cannot find the exact reason for it. Doesn't audio background guarantee that app is not suspended by system? Then how can I handle this issue so that my app can keep white noise playing feature?
3
0
216
Sep ’24
scenePhase change on display cadence change
My Watch app is a workout app that has to be careful to minimize CPU load when backgrounded to get below the 15% avg/60 s in order to avoid being terminated by the system. Accordingly I have logic to detect a transition to the background using a .onChange(of: scenePhase) { phase in… } handler which works well for cases where the app is backgrounded - it is able to reduce its CPU load to just 6-9% while backgrounded. But a special case of the change to scenePhase presents a challenge - when an overlay such as the Control Center or a long-look notification presents, there is no transition to .background, only to .inactive. This is a problem because the system nevertheless imposes the background CPU limit on the app while it’s being covered by the overlay, even though the app didn’t get the .background transition on the scenePhase handler. To further complicate matters, it now seems with watchOS 11 that whenever a transition is made in the screen cadence from .live to .seconds, the scenePhase handler is called with a transition to .inactive. Which is a problem because this transition has to be distinguished from the case of the overlay presentation - the cadence change has no CPU usage implications as long as the app remains foregrounded, but the overlay presentation does, and the system will terminate the app if it exceeds 15% avg/60s. My question: how can I distinguish between the two causes of the transition to .inactive for the two cases: 1) when the overlay presents, and 2) when the display shifts to the slow cadence?
0
0
194
Sep ’24
Problems with SensorKit data calls
The Deligate 'didFetchResult' method of fetching data past 24 hours from SensorKit is not being called. It is confirmed that you have already granted full access to the SensorKit and that data on the Ambient value in the device's personal information -> research sensor & usage data are recorded. It is possible to export to an lz4 file. I want to have the data after 24 hours called to the app, but other Deligate methods are called, but only Deligate that gets the illumination value is not called. Is it understood that only data past 24 hours can be imported after startRecoding() is called? If so, in order to receive data past 24 hours, do I have to continue to receive the illumination data value in the background for more than 24 hours to receive the Ambient value afterwards? import Foundation import SensorKit import UIKit final class SensorKitManager: NSObject, ObservableObject, SRSensorReaderDelegate { static let shared = SensorKitManager() private let ambientReader = SRSensorReader(sensor: .ambientLightSensor) var availableDevices: [SRDevice] = [] @Published var ambientLightData: [AmbientLightDataPoint] = [] var isFetching = false var isRecordingAmbientLight = false private override init() { super.init() setupReaders() checkAndRequestAuthorization() } private func setupReaders() { ambientReader.delegate = self } // MARK: - Permission Request func requestAuthorization() { SRSensorReader.requestAuthorization(sensors: [.ambientLightSensor]) { [weak self] error in DispatchQueue.main.async { guard let self = self else { print("Permission request aborted") return } if let error = error { print("Permission request failed: \(error.localizedDescription)") } else { print("Permission request succeeded") self.startRecordingAmbientLightData() } } } } func checkAndRequestAuthorization() { let status = ambientReader.authorizationStatus switch status { case .authorized: print("Ambient light sensor access granted") startRecordingAmbientLightData() case .notDetermined: print("Ambient light sensor access undetermined, requesting permission") requestAuthorization() case .denied: print("Ambient light sensor access denied or restricted") @unknown default: print("Unknown authorization status") } } // MARK: - Ambient Light Data Logic func startRecordingAmbientLightData() { guard !isRecordingAmbientLight else { print("Already recording ambient light data.") return } print("Starting ambient light data recording") isRecordingAmbientLight = true ambientReader.startRecording() fetchAmbientLightData() fetchAmbientDeviceData() } func fetchAmbientLightData() { print("Fetching ambient light data") let request = SRFetchRequest() let now = Date() let fromTime = now.addingTimeInterval(-72 * 60 * 60) let toTime = now.addingTimeInterval(-25 * 60 * 60) request.from = SRAbsoluteTime(fromTime.timeIntervalSinceReferenceDate) request.to = SRAbsoluteTime(toTime.timeIntervalSinceReferenceDate) print("Fetch request: \(fromTime) ~ \(toTime)") ambientReader.fetch(request) } private func displayAmbientLightData(sample: SRAmbientLightSample) { print("Ambient light: \(sample.lux.value) lux") print("Current ambientLightData content:") for data in ambientLightData { print("Timestamp: \(data.timestamp), Lux: \(data.lux)") } } // MARK: - Device Data Logic private func fetchAmbientDeviceData() { print("Fetching device information") let request = SRFetchRequest() let now = Date() let fromDate = now.addingTimeInterval(-72 * 60 * 60) let toDate = now.addingTimeInterval(-24 * 60 * 60) request.from = SRAbsoluteTime(fromDate.timeIntervalSinceReferenceDate) request.to = SRAbsoluteTime(toDate.timeIntervalSinceReferenceDate) if availableDevices.isEmpty { print("No devices available") ambientReader.fetchDevices() } else { for device in availableDevices { print("Starting data fetch (Device: \(device))") request.device = device ambientReader.fetch(request) print("Fetch request sent (Device: \(device))") } } } // MARK: - SRSensorReaderDelegate Methods func sensorReader(_ reader: SRSensorReader, didFetch devices: [SRDevice]) { availableDevices = devices for device in devices { print("Fetched device: \(device)") } if !devices.isEmpty { fetchAmbientDeviceData() } } func sensorReader(_ reader: SRSensorReader, fetching fetchRequest: SRFetchRequest, didFetchResult result: SRFetchResult<AnyObject>) -> Bool { print("sensorReader(_:fetching:didFetchResult:) method called") if let ambientSample = result.sample as? SRAmbientLightSample { let luxValue = ambientSample.lux.value let timestamp = Date(timeIntervalSinceReferenceDate: result.timestamp.rawValue) // Check for duplicate data and add it if !ambientLightData.contains(where: { $0.timestamp == timestamp }) { let dataPoint = AmbientLightDataPoint(timestamp: timestamp, lux: Float(luxValue)) ambientLightData.append(dataPoint) print("Added ambient light data: \(luxValue) lux, Timestamp: \(timestamp)") } else { print("Duplicate data, not adding: Timestamp: \(timestamp)") } // Output data self.displayAmbientLightData(sample: ambientSample) } return true } func sensorReader(_ reader: SRSensorReader, didCompleteFetch fetchRequest: SRFetchRequest) { print("Data fetch complete") if ambientLightData.isEmpty { print("No ambient light data within 24 hours.") } else { print("ambientLightData updated") for dataPoint in ambientLightData { print("Added ambient light data: \(dataPoint.lux) lux, Timestamp: \(dataPoint.timestamp)") } } } }
0
0
210
Sep ’24
Migrating from pkg installer to Service Management
Hello, we are currently working on a plan to migrate our app suite from Developer ID binaries inside a simple pkg installer to macOS app store distribution. The reason we are using an installer is that there are multiple binaries inside that communicate via XPC and we need to install the respective launchd plist in /Library/LaunchDaemons and /Library/LaunchAgents: 1 root daemon 1 agent that has minimal UI and lives in the system menu bar 1 embedded command line utility in user agent 1 embedded FileProvider extension in user agent 1 embedded Action Extension in user agent 1 agent that only does OAuth stuff Looking through Updating helper executables from earlier versions of macOS I can install the root daemon with SMAppService.daemon(plistName:) and the OAuth helper with SMAppService.agent(plistName:). For the main application I only found SMAppService.mainApp which does not accept a property list configuration. Therefore, I have no place to put my MachServices array and so the File Provider extension, the Action Extension, and the embedded command line utility have no way to talk to the user agent. Currently, XPC is used in between these processes: user agent -> root daemon command line utility -> user agent action extension -> user agent file provider extension -> user agent user agent -> file provider extension: that already works through NSFileProviderServicing I know app-to-app communication only works through launchd for security reasons, but these applications are all part of the same app group (except the root daemon obviously). My question is what is the proper way of starting the user agent so XPC from other binaries just work ™️? Any input is much appreciated!
6
0
900
Feb ’24
Help with eSIM Entitlement Request for Core Telephony API
Hi everyone, I'm currently developing an app that installs eSIM profiles directly within the app and checks if the device supports eSIM. For this functionality, I understand that I need the eSIM entitlement for the Core Telephony API. I submitted a request for the eSIM entitlement to Apple about three weeks ago, but I haven't received a response yet. Has anyone experienced a similar situation? What would be the best course of action to follow up on this? Any guidance or suggestions would be greatly appreciated. Thank you!
3
0
309
Sep ’24
Detecting a backgrounded iOS-Peripheral
We are developing an app where we want iPhone to iPhone communication via bluetooth. We are using the core bluetooth API. One iPhone acts as the peripheral and the other as the central. When both apps are on screen they successfully find each other and can connect. However when the peripheral is in background the central can't find it. To be clear the central is still in foreground. I have consulted this page: https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html and other resources. From my understanding the service UUID should be moved to the manufacturer data. This makes it difficult for non-iOS devices to detect the service but the documentation says that my central should be able to find the peripheral. I have added the required keys to the pList and am explicitly searching for the mentioned service UUID. When using a third party BLE Tool I'm able to find and communicate with the peripheral even when it is in background mode. I know that some option-keys will be ignored but from my understanding they should still find each other at least once. This was tested with two iOS 18 iPhones. Here is the code im using: import UIKit import CoreBluetooth class ViewController: UIViewController { private var centralManager: CBCentralManager! private var peripheralManager: CBPeripheralManager! override func viewDidLoad() { super.viewDidLoad() } @IBAction func btnPeripheral(_ sender: Any) { peripheralManager = CBPeripheralManager(delegate: self, queue: nil, options: nil) } @IBAction func btnCentral(_ sender: Any) { print("central go") centralManager = CBCentralManager(delegate: self, queue: nil) } } extension ViewController: CBCentralManagerDelegate { func centralManagerDidUpdateState(_ central: CBCentralManager) { print("central state: \(central.state)") switch central.state { case .poweredOn: print("central powered on") centralManager.scanForPeripherals(withServices: [CBUUID(string:"db9acb1e-1ac4-4f70-b58c-3b3dcea84703")], options: [CBCentralManagerScanOptionAllowDuplicatesKey: true]) default: print("central not powered on") } } func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { print("Dicovered \(peripheral)") } } extension ViewController: CBPeripheralManagerDelegate { func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) { print("peripheral state: \(peripheral.state)") if peripheral.state == .poweredOn { print("powered on") let uuid = CBUUID(string: "db9acb1e-1ac4-4f70-b58c-3b3dcea84703") let service = CBMutableService(type: uuid, primary: true) peripheralManager.add(service) peripheralManager.startAdvertising([CBAdvertisementDataServiceUUIDsKey: [uuid], CBAdvertisementDataLocalNameKey: "MyService"]) } } }
2
2
385
Sep ’24