Search results for

NSCocoaErrorDomain Error Code 4

170,018 results found

Post

Replies

Boosts

Views

Activity

Sharing: How I Built an IPv4/IPv6 Dual-Stack Network Diagnostic Tool for iOS
Hi everyone 👋 As a network engineer and indie iOS developer, I couldn’t find a lightweight mobile tool that fully supports IPv4/IPv6 dual-stack diagnostics — so I built NetToolbox -All-In-One Utility for engineers, DevOps, and developers. Here are its core features that solve real mobile networking pain points: One-Click Full Diagnostics: Integrates ping, traceroute, and multi-type DNS queries (A/AAAA/CNAME) — no need to switch between apps IPv4/IPv6 Dual-Stack Support: Seamlessly works in IPv6-only networks, with the ability to test connectivity differences between dual-stack environments LAN Device Scanning: Quickly identifies all devices on the same network segment and checks port availability Offline Functionality: Diagnostic logic is stored locally, enabling LAN troubleshooting without an internet connection Lightweight Design: 5MB install size, no storage bloat, and low power consumption during operation Dark Mode Support: Tailored for developers who work late at night During development, I leveraged A
1
0
23
7h
Reply to Stumped by URLSession behaviour I don't understand...
What Kevin said plus… It’s reasonable to use different approaches for different subsystems in your app. For example: If you’re fetching an audio file to play immediately, a standard session is probably best. Critically, it results in the least latency, which is important because you’re actively playing that audio. And while this requires your app to not suspend, that’s OK because you’re playing audio. If you’re downloading a large file that the user isn’t actively playing, a background session makes sense. If you’re scanning for updates, you could use a background processing task. This typically runs overnight, which is fine because the user isn’t expecting the results immediately. Unless they bring your app to the foreground and tap the refresh button, in which case you might run the same code immediately. And you can then use a continued processing task to complete the refresh. But that’s just one way to slice this. You have lots of options and it’s kinda up to you to decide which one makes sense b
8h
Stumped by URLSession behaviour I don't understand...
I have an app that has been using the following code to down load audio files: if let url = URL(string: episode.fetchPath()) { var request = URLRequest(url: url) request.httpMethod = get let task = session.downloadTask(with: request) And then the following completionHandler code: func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) { try FileManager.default.moveItem(at: location, to: localUrl) In the spirit of modernization, I'm trying to update this code to use async await: var request = URLRequest(url: url) request.httpMethod = get let (data, response) = try await URLSession.shared.data(for: request) try data.write(to: localUrl, options: [.atomicWrite, .completeFileProtection]) Both these code paths use the same url value. Both return the same Data blobs (they return the same hash value) Unfortunately the second code path (using await) introduces a problem. When the audio is playing and the iPhone goes
6
0
223
8h
Provisioning profile missing entitlement
My iOS app uses CloudKit key-value storage. I have not updated the app in a few years but it works fine. Since it was last updated, I transferred the app from an old organization to my personal developer account. Now that I'm working on the app again I get an error: Provisioning profile iOS Team Provisioning Profile: com.company.app doesn't match the entitlements file's value for the com.apple.developer.ubiquity-kvstore-identifier entitlement. In the entitlement file, it has $(TeamIdentifierPrefix)$(CFBundleIdentifier) as the value for iCloud Key-Value Store. I've verified the variables resolve as expected. When I parse the provisioning profile there is no entitlement value for key-value storage. What am I getting wrong?
13
0
823
8h
Get identities from a smart card in an authorization plugin
Hello, I’m working on an authorization plugin which allows users to login and unlock their computer with various methods like a FIDO key. I need to add smart cards support to it. If I understand correctly, I need to construct a URLCredential object with the identity from the smart card and pass it to the completion handler of URLSessionDelegate.urlSession(_:didReceive:completionHandler:) method. I’ve read the documentation at Using Cryptographic Assets Stored on a Smart Card, TN3137: On Mac keychain APIs and implementations, and SecItem: Pitfalls and Best Practices and created a simple code that reads the identities from the keychain: CFArrayRef identities = nil; OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)@{ (id)kSecClass: (id)kSecClassIdentity, (id)kSecMatchLimit: (id)kSecMatchLimitAll, (id)kSecReturnRef: @YES, }, (CFTypeRef *)&identities); if (status == errSecSuccess && identities) { os_log(OS_LOG_DEFAULT, Found identities: %{public}ldn, CFArrayGetCount(identities))
10
0
1k
9h
evaluatedPolicyDomainState
Hi Apple Developers, I'm having a problem with evaluatedPolicyDomainState: on the same device, its value keeps changing and then switching back to the original. My current iOS version is 26.1. I upgraded my iOS from version 18.6.2 to 26.1. What could be the potential reasons for this issue? { NSError *error; BOOL success = YES; char *eds = nil; int edslen = 0; LAContext *context = [[LAContext alloc] init]; // test if we can evaluate the policy, this test will tell us if Touch ID is available and enrolled // success = [context canEvaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]; if (SystemVersion > 9.3) { // test if we can evaluate the policy, this test will tell us if Touch ID is available and enrolled success = [context canEvaluatePolicy: LAPolicyDeviceOwnerAuthentication error:&error]; } else{ // test if we can evaluate the policy, this test will tell us if Touch ID is available and enrolled success = [context canEvaluatePo
4
0
708
9h
Free trial for one-time purchase: Is the $0 IAP workaround still recommended in 2026?
I have a $4 USD, one-time-purchase app (Dash Calc) and sales have been rough. In a crowded category, an paid-upfront app feels like a tough sell without a way to try it first. I’d like to offer a simple 7-day free trial followed by a single lifetime purchase, but App Store Connect still doesn’t officially support trials for paid apps. In Jan 2023, an App Store Commerce Engineer recommended the $0 non-consumable IAP + paid non-consumable IAP workaround: https://developer.apple.com/forums/thread/722874 I haven’t implemented it yet, but the subsequent discussion suggests the approach is overly complex. Handling refunds, reinstalls, activation timing, and purchase history requires non-obvious logic, and some developers report customer confusion and drop-off when presented with a $0 trial IAP. Has anything improved since 2023? Any new StoreKit APIs or App Store Connect changes that make this simpler or less error-prone? Is the $0 non-consumable IAP still the recommended approach in 2026? Any upda
2
0
160
9h
Reply to NSKeyedArchiving issue
Hey Quinn, thanks for all the material. I realize that I have a basic issue in my code. data is not loaded. In the previous version, archiver had a connection to data let archiver = NSKeyedArchiver(forWritingWith: data) That's no more the case, so data is empty, hence the problems. let data = NSMutableData() let archiver = NSKeyedArchiver(requiringSecureCoding: true) archiver.encode(myObject, forKey: theKey) archiver.encode(myObject2, forKey: theKey2) archiver.finishEncoding() do { try data.write(to: an uRL, options: []) // data is empty of course ! } catch { } So should I replace: archiver.encode(myObject, forKey: theKey) archiver.encode(myObject2, forKey: theKey2) archiver.finishEncoding() do { try data.write(to: anURL, options: []) // So object and object2 are on file with let data = try! NSKeyedArchiver.archivedData(withRootObject: myObject, requiringSecureCoding: true) let data2 = try! NSKeyedArchiver.archivedData(withRootObject: myObject2, requiringSecureCoding: true) archiver.finishEncoding()
Topic: App & System Services SubTopic: General Tags:
8h
NSKeyedArchiving issue
I have a large code that I try to update to change deprecated APIs. In the former version, I used forWritingWith and forReadingWith let data = NSMutableData() let archiver = NSKeyedArchiver(forWritingWith: data) archiver.encode(myObject, forKey: theKey) if let data = NSMutableData(contentsOf: anURL) { let unarchiver = NSKeyedUnarchiver(forReadingWith: data as Data) let myObject = unarchiver.decodeObject(forKey: theKey) as! TheObjectType // <<-- returns the object That I changed to let data = NSMutableData() let archiver = NSKeyedArchiver(requiringSecureCoding: true) archiver.encode(myObject, forKey: theKey) if let data = NSMutableData(contentsOf: anURL) { do { let unarchiver = try NSKeyedUnarchiver(forReadingFrom: data as Data) let myObject = unarchiver.decodeObject(forKey: theKey) as? TheObjectType // <<-- This returns nil This builds correctly. But on execution, unarchiver.decodeObject now returns nil. I have searched extensively to find the cause to no avail. I may probably change the
2
0
67
8h
DNS Proxy system extension – OSSystemExtensionErrorDomain error 9 “validationFailed” on clean macOS machine
Hi, I’m implementing a macOS DNS Proxy as a system extension and running into a persistent activation error: OSSystemExtensionErrorDomain error 9 (validationFailed) with the message: extension category returned error This happens both on an MDM‑managed Mac and on a completely clean Mac (no MDM, fresh install). Setup macOS: 15.x (clean machine, no MDM) Xcode: 16.x Team ID: AAAAAAA111 (test) Host app bundle ID: com.example.agent.NetShieldProxy DNS Proxy system extension bundle ID: com.example.agent.NetShieldProxy.dnsProxy The DNS Proxy is implemented as a NetworkExtension system extension, not an app extension. Host app entitlements From codesign -d --entitlements :- /Applications/NetShieldProxy.app: xml com.apple.application-identifier AAAAAAA111.com.example.agent.NetShieldProxy com.apple.developer.system-extension.install com.apple.developer.team-identifier AAAAAAA111 com.apple.security.app-sandbox com.apple.security.application-groups group.com.example.NetShieldmac com.apple.se
5
0
162
10h
Reply to DNS Proxy system extension – OSSystemExtensionErrorDomain error 9 “validationFailed” on clean macOS machine
Thanks for the clarification about Developer ID vs Apple Development and for the links. Previously I started with Developer ID and the dns-proxy-systemextension entitlement, but per your advice I’ve now switched both the host app and the DNS Proxy system extension to Apple Development signing and the legacy dns-proxy value. Current Apple Development setup macOS: 15.7.3 (24G419) Xcode: 26.2 (17C52) Host: com.example.agent.MyMacProxy DNS Proxy system extension: com.example.agent.MyMacProxy.dnsProxy System extension entitlement: xml com.apple.developer.networking.networkextension dns-proxy System extension Info.plist (built .systemextension inside the host app): xml NSExtension NSExtensionPointIdentifier com.apple.system_extension.network_extension NSExtensionPrincipalClass MyMacProxy.DNSProxyProvider There is no NetworkExtension key in this plist (confirmed with plutil -p on the built .systemextension in both DerivedData and /Applications). The system extension is embedded at: MyMacProxy.app/Contents/Library/Sy
10h
Reply to Reduce dyld overhead
OK. I don’t think you can optimise beyond that. Rather, I think you should use that as a baseline for performance work as you evolve your program. Speaking of that, An Apple Library Primer has links to various WWDC talks where the linker team discusses various topics. Most notably, the 2022 talk discusses launch times. It’s well worth a watch. Finally, just for context, the libSystem initialiser does a bunch of really critical stuff. For example, it has the code that sets up the App Sandbox, if the executable enables it. If you want to see this initialiser in action, open your true clone project, set a symbolic breakpoint on libSystem_initializer, and run it from Xcode. When you stop at the breakpoint, Xcode will show a page of disassembled code, but that’s not too hard to understand. And most of the symbols are present, so you can look up the source code in Darwin. IMPORTANT The Darwin open source isn’t guaranteed to match the source used to build the OS, but it’s usually close eno
Topic: App & System Services SubTopic: Core OS Tags:
10h
Reply to NSKeyedArchiving issue
Hey Claude31, it’s nice for me to be helping you for a change (-: It’s hard to tell exactly what’s going wrong here without know more about the objects in play. However, in general, when you decode something from a secure keyed archive, you have to tell the system what type you’re expecting. That’s the key factor is what makes it secure. Over the years I’ve helped a bunch of folks with problems like this. All of these threads have code snippets from me that you should find useful: Question about including all project classes in ofClasses parameter when using NSKeyedUnarchiver.unarchivedObject(ofClasses:from:) Fragment large size data sent and received using NSKeyedArchiver.archivedData in GameCenter Unarchiving an object with custom classes XPC, Swift, ObjC, and arrays NSKeyedUnarchiver decodeObjectOfClasses failed NSKeyedUnarchiver decodeObjectOfClasses failed 'unarchiveTopLevelObjectWithData' was deprecated Use unarchivedObject(ofClass:from:) instead NSkeyedArchiver fails when trying to archive sub
Topic: App & System Services SubTopic: General Tags:
11h
Entitlement not found
Dears, this is my first ever piece of code on Mac. I wanted to try ShazamKit. I created App Id and enabled App Service ShazamKit. I properly configured my app (a very small test app) with the proper boundle id, Team and entitlements file. I keep receiving this error in the Signing in section: Automatic signing failed Xcode failed to provision this target. Please address the following issues preventing automatic signing from creating a valid profile. Entitlement com.apple.developer.shazamkit not found and could not be included in profile. This likely is not a valid entitlement and should be removed from your entitlements file I noticed the message is mentioning profile...does it refer to a Profile as in Certificate/Identifiers/Devices/Profiles/Keys/Services option? I did not create any Profile. I just enabled the App Service under Certificates, Identifiers & Profiles=>Identifiers=>Edit your App ID Configuration=>App Services Thx!
1
0
193
11h