General:
TN3151 Choosing the right networking API
Networking Overview document — Despite the fact that this is in the archive, this is still really useful.
TLS for App Developers DevForums post
Choosing a Network Debugging Tool documentation
WWDC 2019 Session 712 Advances in Networking, Part 1 — This explains the concept of constrained networking, which is Apple’s preferred solution to questions like How do I check whether I’m on Wi-Fi?
TN3135 Low-level networking on watchOS
Adapt to changing network conditions tech talk
Foundation networking:
DevForums tags: Foundation, CFNetwork
URL Loading System documentation — NSURLSession, or URLSession in Swift, is the recommended API for HTTP[S] on Apple platforms.
Network framework:
DevForums tag: Network
Network framework documentation — Network framework is the recommended API for TCP, UDP, and QUIC on Apple platforms.
Network Extension (including Wi-Fi on iOS):
See Network Extension Resources
Wi-Fi Fundamentals
Wi-Fi on macOS:
DevForums tag: Core WLAN
Core WLAN framework documentation
Wi-Fi Fundamentals
Secure networking:
DevForums tags: Security
Apple Platform Security support document
Preventing Insecure Network Connections documentation — This is all about App Transport Security (ATS).
Available trusted root certificates for Apple operating systems support article
Requirements for trusted certificates in iOS 13 and macOS 10.15 support article
About upcoming limits on trusted certificates support article
Apple’s Certificate Transparency policy support article
Technote 2232 HTTPS Server Trust Evaluation
Technote 2326 Creating Certificates for TLS Testing
QA1948 HTTPS and Test Servers
Miscellaneous:
More network-related DevForums tags: 5G, QUIC, Bonjour
On FTP DevForums post
Using the Multicast Networking Additional Capability DevForums post
Investigating Network Latency Problems DevForums post
Local Network Privacy FAQ DevForums post
Extra-ordinary Networking DevForums post
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Foundation
RSS for tagAccess essential data types, collections, and operating-system services to define the base layer of functionality for your app using Foundation.
Posts under Foundation tag
200 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I've noticed that NSTaks has this property as of macOS 14.4
@property (nullable, copy) NSData *launchRequirementData API_AVAILABLE(macos(14.4)) API_UNAVAILABLE(ios, watchos, tvos, visionos);
It has no documentation whatsoever. Even google search has no clue. Does this have anything to do with code signature requirements validation? Any explanations and examples would be appreciated!
Hello,
I am getting an EXC_BREAKPOINT and trying figure out how to debug this crash.
Some background on func getDecodeResults(noOfDecodes: ) which the crashlog is pointing to:
I believe this crash might be related to the unsafe pointers I'm using for communication between our C code and Swift. Below are the relevant implementation details:
I create an UnsafeMutablePointer for a struct type DECODE_RESULTS, defined internally.
The Swift code allocates fixed memory for this pointer, which is then passed to a C library for initialization and modification.
In the getDecodeResults function (where the crash log points), the first step is converting a C array starting at the UnsafeMutablePointer into a Swift array.
Here’s a snippet for context:
// In class initialization:
private var decodeResults: UnsafeMutablePointer<DECODE_RESULTS>
decodeResults = UnsafeMutablePointer<DECODE_RESULTS>.allocate(capacity: maxNumberOfBarcodes)
// Initialize decodeResults in the C library
// In getDecodeResults function:
let results = Array(UnsafeBufferPointer(start: decodeResults, count: Int(noOfDecodes)))
Crash Log:
Thread 6 name: Dispatch queue: com.padlocdocks.padlocscan.PLSBarcodeScanner._scanQueue
Thread 6 Crashed:
0 AilaDecoder 0x101d995a8 DecoderManager.getDecodeResults(noOfDecodes:) (in AilaDecoder) (DecoderManager.swift:0) + 38312
I'm unsure if (DecoderManager.swift:0) indicates the root cause or if it’s an erroneous reference.
01 AilaDemo-2025-01-17-041022_symbolicated.txt
In iOS 18, we encountered a crash:
Thread 4 name: com.apple.root.user-interactive-qos
Thread 4 Crashed:
0 CoreFoundation 0x18c4f9b10 __CFCheckCFInfoPACSignature + 4
1 CoreFoundation 0x18c53ed64 CFBundleGetInfoDictionary + 24
2 CoreFoundation 0x18c53ed1c CFBundleGetIdentifier + 16
3 Foundation 0x18b153740 -[NSUserDefaults(NSUserDefaults) _initWithSuiteName:container:] + 84
4 UIKitCore 0x18ef26ef0 ___UIKitUserDefaults_block_invoke + 40
5 libdispatch.dylib 0x1941ee0d0 _dispatch_client_callout + 20
6 libdispatch.dylib 0x1941ef918 _dispatch_once_callout + 32
7 UIKitCore 0x18ef9de28 _UIKitUserDefaults + 80
8 UIKitCore 0x18f058a7c ___UIKitPreferencesOnce_block_invoke + 20
9 libdispatch.dylib 0x1941ee0d0 _dispatch_client_callout + 20
10 libdispatch.dylib 0x1941ef918 _dispatch_once_callout + 32
11 UIKitCore 0x18f056c8c _UIKitPreferencesOnce + 80
12 UIKitCore 0x18f0563b8 ___UIApplicationMainPreparations_block_invoke + 20
13 libdispatch.dylib 0x1941ec370 _dispatch_call_block_and_release + 32
14 libdispatch.dylib 0x1941ee0d0 _dispatch_client_callout + 20
15 libdispatch.dylib 0x1941fff60 _dispatch_root_queue_drain + 860
16 libdispatch.dylib 0x194200590 _dispatch_worker_thread2 + 156
17 libsystem_pthread.dylib 0x2136ffc40 _pthread_wqthread + 228
18 libsystem_pthread.dylib 0x2136fc488 start_wqthread + 8
Below image show more details:
And after set a symbol breakpoint:
[NSUserDefaults _initWithSuiteName:container:]
We found that at the beginning of app launch, the system will call it:
It not always crash, but sometimes especially when app upgrade, what the root cause maybe?
When using:
[[NSUserDefaults alloc] initWithSuiteName:@"TestSuiteName"];
It sometimes cause crash, the crash detail is:
Thread 4 name: com.apple.root.user-interactive-qos
Thread 4 Crashed:
0 CoreFoundation 0x1963f9b10 __CFCheckCFInfoPACSignature + 4
1 CoreFoundation 0x19643ed64 CFBundleGetInfoDictionary + 24
2 CoreFoundation 0x19643ed1c CFBundleGetIdentifier + 16
3 Foundation 0x195053740 -[NSUserDefaults(NSUserDefaults) _initWithSuiteName:container:] + 84
4 UIKitCore 0x198e26ef0 ___UIKitUserDefaults_block_invoke + 40
5 libdispatch.dylib 0x19e0ee0d0 _dispatch_client_callout + 20
6 libdispatch.dylib 0x19e0ef918 _dispatch_once_callout + 32
7 UIKitCore 0x198e9de28 _UIKitUserDefaults + 80
8 UIKitCore 0x198f58a7c ___UIKitPreferencesOnce_block_invoke + 20
9 libdispatch.dylib 0x19e0ee0d0 _dispatch_client_callout + 20
10 libdispatch.dylib 0x19e0ef918 _dispatch_once_callout + 32
11 UIKitCore 0x198f56c8c _UIKitPreferencesOnce + 80
12 UIKitCore 0x198f563b8 ___UIApplicationMainPreparations_block_invoke + 20
13 libdispatch.dylib 0x19e0ec370 _dispatch_call_block_and_release + 32
14 libdispatch.dylib 0x19e0ee0d0 _dispatch_client_callout + 20
15 libdispatch.dylib 0x19e0fff60 _dispatch_root_queue_drain + 860
16 libdispatch.dylib 0x19e100590 _dispatch_worker_thread2 + 156
17 libsystem_pthread.dylib 0x21d7dfc40 _pthread_wqthread + 228
18 libsystem_pthread.dylib 0x21d7dc488 start_wqthread + 8
and for more detail crash info can see the attachment image
.
And Refer to the API's description:
/// -initWithSuiteName: initializes an instance of NSUserDefaults that searches the shared preferences search list for the domain 'suitename'. For example, using the identifier of an application group will cause the receiver to search the preferences for that group. Passing the current application's bundle identifier, NSGlobalDomain, or the corresponding CFPreferences constants is an error. Passing nil will search the default search list.
- (nullable instancetype)initWithSuiteName:(nullable NSString *)suitename API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0)) NS_DESIGNATED_INITIALIZER;
It seems using a constants string is a wrong way.
Does any one know what to root cause?
Prior to 18.x, this has worked for years. However, if a port is included, the behavior in 18.x is to return "///some/path". In all previous versions it correctly returns "/some/path".
Is this a bug, or documented change we missed?
func relativeURLString(for urlString: String) -> String? {
guard var components = URLComponents(string: urlString) else { return nil }
components.host = nil
components.scheme = nil
// WE FOUND IF YOU NIL THE PORT BEFORE HOST AND SCHEME, IT WORKS
components.port = nil
return components.string
}
Hello,
I have the app localised to many languages and its variants, like English from Australia or Dutch from Belgium.
My phone language is en_UK and the region is configured to ES.
I cannot find a way to get the regional language code (ex: en_au, nl_be), it always gets simplified to the language (ex: en, nl), or adds my device region (ex: en-ES, nl-ES).
Here I attach some examples while I have the app on en_au
Locale.preferredLanguages
▿ 3 elements
- 0 : "en-ES"
- 1 : "ca-ES"
- 2 : "es-ES"
Bundle.main.preferredLocalizations
▿ 1 element
- 0 : "en"
NSLocale.current.languageCode
▿ Optional<String>
- some : "en"
Locale.current
▿ en_001@rg=eszzzz (fixed en_001@rg=eszzzz)
- identifier : "en_001@rg=eszzzz"
- locale : "fixed en_001@rg=eszzzz"
Locale.autoupdatingCurrent.languageCode
▿ Optional<String>
- some : "en"
Locale.current.languageCode
▿ Optional<String>
- some : "en"
Locale.preferredLanguages[0]
"en-ES"
how to save the state of my APP when I open another APP so that It can restore when I re-open it?
my app will use over 10mb memory so if I open another APP(my app will go background) it will closed at all.
when I re-open it it will restart.
but I do not want it I want if I open Page A and then it go background and when I re-open it it still is Page A and do not restart.
I've got some materials in an app's bundle (some info.plist values, and some images in .xcassets files etc.)
If I access them from within an app extension (a notification service extension, notification content extension for example), then it appears to work.
However while running the extensions in the debugger, there were some messages in the console saying the app bundle wasn't loaded.
So despite it working, this message made me wonder if its not a safe practice and it working was luck and/or timing etc. and if the materials should instead be duplicated within the extension bundle and obtained from there instead of accessing them from the app bundle?
Hello, we are processing the first network permission request transaction on iOS. We have found that when the CTCellularData is in the kCTCellularDataNotRestricted state and we attempt to perform a network access in the callback function, an exception is reported. How can we resolve this issue? I’ve seen that some solutions on the internet suggest adding a delay of 1 second. Are there any other methods?
I have a class object created dynamically using Runtime, and I want to release some manually allocated memory resources when this object is deallocated. To achieve this, I added a custom implementation of the dealloc method using the following code:
SEL aSel = NSSelectorFromString(@"dealloc");
class_addMethod(kvoClass, aSel, (IMP)custom_dealloc, method_getTypeEncoding(class_getInstanceMethod(kvoClass, aSel)));
However, I encountered some issues. If I don't call the superclass's dealloc method in the cus_dealloc function, the superclass's dealloc implementation will not be executed. On the other hand, if I explicitly call the superclass's dealloc method, the program crashes.
Here is the implementation of the cus_dealloc function:
void custom_dealloc(id self, SEL _cmd) {
// Release other memory
![]("https://developer.apple.com/forums/content/attachment/c7b0c16b-be23-4776-b8db-f22b661c5e7d" "title=iShot_2025-01-03_19.31.34.png;width=1080;height=1895")
Class superClass = class_getSuperclass(object_getClass(self));
void (*originIMP)(struct objc_super *, SEL, ...) = (void *)objc_msgSendSuper;
struct objc_super *objcSuper = &(struct objc_super){self, superClass};
originIMP(objcSuper, _cmd);
}
demo
Context: SwiftUI TextField with a String for simple math using NSExpression.
I first prepare the input string to an extent but a malformed input using valid characters still fails, as expected. Let's say preparedExpression is "5--"
let expr = NSExpression(format: preparedExpression)
gives
FAULT: NSInvalidArgumentException: Unable to parse the format string "5-- == 1"; (user info absent)
How can I use NSExpression such that either the preparedExpression is pre-tested before asking for actual execution or the error is handled in a polite way that I can use to alert the user to try again.
Is there a Swift alternative to NSExpression that I've missed?
We have a sample code that initialises an NSAttributed string with simple HTML code and the result differs massively since XCode 16 and iPadOS 18 SDK.
DESCRIPTION OF PROBLEM Since Xcode Version 16.1 HTML content passed into an NSAttributedString is not rendered correctly. Specifically, enumeration characters (such as bullet points or numbers) and the proper indentation for text within list items are missing. As a result, the structure of the HTML content, especially ordered and unordered lists, is not displayed as expected.
STEPS TO REPRODUCE A UILabel was added to the view in a new Objective-C project in Xcode.
A HTML string containing and Tags was converted into an NSAttributedString (With NSAttributedString::initWithData and NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType Parameter)within the viewDidLoad method and assigned to the UILabel.
Expected Result:
The lists should be displayed correctly with enumeration characters and appropriate indentation, as shown in the attached screenshot expected_result.jpeg.
Same Code still works as expected using XCode 15.x
Actual Result:
The list is displayed without enumeration characters or indentation, which matches the attached screenshot actual_result.jpeg.
Sample Code
NSString *html = @"Es ist wichtig, dass Sie Ihren Arzt informieren:\n<ol>\n\t<li><strong>HIER !!!!!!! </strong>Wenn Sie gegenwärtig mit Zometa®, dass die gleiche aktive Substanz enthält wie Aclasta® behandelt werden.</li>\n</ol>\n\n<ul>\n\t<li><strong>Hier !!!!!!</strong> Wenn Sie Nierenbeschwerden haben oder hatten, denn Ihre Nieren müssen korrekt funktionieren, um das überflüssige Aclasta ® das für Ihre Knochen nicht benötigt wird, ausscheiden zu können.</li>\n\t<li>Wenn sie Medikamente einnehmen, die Kortsion als Bestandteil enthalten (z. B. Prendisolon oder Dexamethason)</li>\n\t<li>Wenn sie unter schlechter Zahngesundheit oder Zahnfleischerkrankungen leiden oder wenn eine Zahnextraktion geplant ist</li>\n</ul>\n";
NSString *textAttr = [NSString stringWithFormat:@"<span style=\"font-family:Arial; line-height: 80%%; font-size:10px;\">%@</style>", html];
NSData *data = [textAttr dataUsingEncoding:NSUTF16StringEncoding];
NSAttributedString *string = [[NSAttributedString alloc] initWithData:data
options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
NSCharacterEncodingDocumentAttribute: @(NSUTF16StringEncoding)}
documentAttributes:nil error:nil];
self.label.numberOfLines = 0;
self.label.attributedText = string;
Greetings
is forKey:fileSize considered accessing non-public API?
has your app been rejected at review stage due to this?
let resources = PHAssetResource.assetResources(for: asset)
if let resource = resources.first {
if let fileSize = resource.value(forKey: "fileSize") as? Int {
return fileSize
}
}
Hi everyone,
I am wondering under which settings the camera(s) were set by the time they were calibrated.
For instance, one aspect that is easy to find is the reference resolution of the images taken when calibrating the intrinsics, this is by retrieving
intrinsicMatrixReferenceDimensions.
Making sure that the principal point is referenced to the by the time resolution used when the calibration was ongoing.
However, recently I saw that there are focusing modes that potentially displace the lens' physical position.
Settings like:
AutoFocusRangeRestriction: none, near, far
setFocusModeLocked: Locks the lens position at the specified value, and sets the focus mode to a locked state.
My concern lies the impact this focusing lens displacements can have on the intrinsic matrix parameters, like these parameters no longer describe the camera since the lens position has changed.
In simple words, what is the focus 'mode'/'range' the cameras were set when calibrating them for intrnisics?
Hello dear community,
I have the sample code from Apple “CapturingDepthUsingLiDAR” to access the LiDAR on my iPhone 12 Pro. My goal is to use the “photo output” function to generate a point cloud from a single image and then save it as a ply file. So far I have tested different approaches to create a .ply file from the depthmap, the intrinsic camera data and the rgba values. Unfortunately, I have had no success so far and the result has always been an incorrect point cloud.
My question now is whether there are already approaches to this and whether anyone has any experience with it.
Thank you very much in advance!!!
Hi everyone,
I’m encountering a crash in my app and need help understanding what’s causing it and how to resolve it.
As stated in the crash report, the issue is caused by exceeding the system-wide per-process port limit. Can you tell me how to locate and identify why this is happening?
Below are the full report of the crash log:
crash.log
Summary of Crash:
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Incident Identifier: B509FF2B-C8D8-4E9F-B664-E24464CFD5F8
CrashReporter Key: b390cfe931a83efde49bd8b523023a275b55ef64
Hardware Model: iPhone14,2
Process: MyApp [22515]
Path: /private/var/containers/Bundle/Application/F73212A7-4CB9-485A-A8B7-8114F4E9A9AB/MyApp.app/MyApp
Identifier: com.beeasy.app.id.enterprise
Version: 3.41.38-ID-MySDKMemory-12261114 (3.41.38-ID-MySDKMemory-12261114)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.beeasy.app.id.enterprise [515]
Date/Time: 2024-12-29 01:29:48.3023 +0800
Launch Time: 2024-12-26 16:38:36.7895 +0800
OS Version: iPhone OS 16.6.1 (20G81)
Release Type: User
Baseband Version: 2.80.01
Report Version: 104
Exception Type: EXC_RESOURCE (SIGKILL)
Exception Codes: 0x000000000001c1d6, 0x0000000000000000
Termination Reason: PORT_SPACE 14123288431433990614 (Limit 115158 ports) Exceeded system-wide per-process Port Limit
Triggered by Thread: 64
Thread 64 name: AURemoteIO::IOThread
Thread 64 Crashed:
0 libsystem_kernel.dylib 0x20ce5eca4 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x20ce71b74 mach_msg2_internal + 80
2 libsystem_kernel.dylib 0x20ce71e4c mach_msg_overwrite + 540
3 libsystem_kernel.dylib 0x20ce5f1e8 mach_msg + 24
4 libEmbeddedSystemAUs.dylib 0x238bb2148 void* caulk::thread_proxy<std::__1::tuple<caulk::thread::attributes, AURemoteIO::IOThread::IOThread(AURemoteIO&, caulk::thread::attributes const&, caulk::mach::os_workgroup_managed const&)::'lambda'(), std::__1::tuple<>>>(void*) + 556
5 libsystem_pthread.dylib 0x22dcda6b8 _pthread_start + 148
6 libsystem_pthread.dylib 0x22dcd9b88 thread_start + 8
I need to convert user input to HID key codes, and while for English it's pretty easily done, for other languages not so much. On Mac there is UCKeyTranslate function, but on iOS I couldn't find anything like this.
Is there a good way to achieve this?
I don't know why? 🤷 My uuid and imi as well as ip have been leaked, I don't know what to do? Can someone help me?
I have been battling this intermittent error for some time. It is generally random and has been difficult to reproduce until yesterday when I stumbled across a way to reproduce it each time. I can cause the code to throw this error:
Task <70E3909F-8C30-4F34-A8B0-4AF3B41DD81B>.<1> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=-2103, _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundDownloadTask <70E3909F-8C30-4F34-A8B0-4AF3B41DD81B>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"BackgroundDownloadTask <70E3909F-8C30-4F34-A8B0-4AF3B41DD81B>.<1>",
"LocalDownloadTask <70E3909F-8C30-4F34-A8B0-4AF3B41DD81B>.<1>"
), NSLocalizedDescription=The request timed out., _kCFStreamErrorDomainKey=4, NSErrorFailingURLStringKey=https://redacted*, NSErrorFailingURLKey=https://redacted*}
*"redacted" is the backend URL, and it is the correct and same path for each
immediately after restarting an actual device. I have been over the following threads with no results:
What is kCFStreamErrorCodeKey=-4 (kCFStreamErrorDomainKey=4)
Request timed out with _kCFStreamErrorCodeKey=60
How to better diagnose -1001 "The request timed out." URLSession errors
Random timed out error on app start
Because I was able to reproduce it, I have been able to get the following logs:
Console Logs.txt
Last bit of information is that I had Network Instruments running, and when this error occurred, I found that the Connection ID was "No Connection" and it appears the request was never actually sent, though it waited the full time out for a backend response.
Any help would be appreciated. This data request is being used after sending a certain APNs to update necessary data in the background, and has been the source of many user complaints.
I have been trying to accept drops from Apple Mail which do supply data with type identifiers : com.apple.mail.email
The problem is that even though the drop says it does contain items for com.apple.mail.email it does provide the items for com.apple.mail.email.
Mail dropped from Microsoft Outlook however confirms to the protocols and returns the items for com.apple.mail.email
Is this a known issue with Apple Mail and is there are reason for what seems to be a non-compliance to it own standards in Apple Mail?