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
AGAM99 link login terbaik karena adap lisensi resmi dari mpo play yang memberikan tahta tersebut yang dapat bertanggung jawab penuh dan kami tetap mengutamakan pelayanan member setia kami bahkan semua customer agen Agam99 dan bisa anda unduh melalui apk Agam99 bisa bermain di mobile maupun di laptop dan komputer
When the usesGroupingSeparator is set to yes on iOS18, the groupingSize value becomes 3. groupingSize is different from 0 in earlier iOS18 versions. Is it a bug or will the subsequent official version also make relevant adjustments? We need to adapt the app in advance。
let formatter = NumberFormatter()
let temp = NSNumber(floatLiteral: value)
formatter.usesGroupingSeparator = true;
print(formatter.string(from: temp) ?? "","--",formatter.groupingSize)
Print results below:
iOS18 2222222 -- 0
earlier iOS18 2,222,222 -- 3
iOS18 beta版本,usesGroupingSeparator设置为yes后,groupingSize值变成了3.与iOS18以下groupingSize值为0不一样。是bug还是后续正式版本也做相关调整?
let formatter = NumberFormatter()
let temp = NSNumber(floatLiteral: value)
formatter.usesGroupingSeparator = true;
print(formatter.string(from: temp) ?? "","分割位数",formatter.groupingSize)
//iOS18以下打印结果:2222222 分割位数 0;iOS18打印结果:2,222,222 分割位数 3
iOS18 beta版本,usesGroupingSeparator设置为yes后,groupingSize值变成了3.与iOS18以下groupingSize值为0不一样。是bug还是后续正式版本也做相关调整?
let formatter = NumberFormatter()
let temp = NSNumber(floatLiteral: value)
formatter.usesGroupingSeparator = true;
print(formatter.string(from: temp) ?? "","分割位数",formatter.groupingSize)
//iOS18以下打印结果:2222222 分割位数 0;iOS18打印结果:2,222,222 分割位数 3
App getting terminated as the app enters background state. No crash logs are generated.
I have collected this log from Console(Mac app)by connecting iPhone and sending my app to background.
There is no meaningful reason or code I can get from the logs. Can you please help me with what does 'explanation:BG Kill Demo ' means ?
My app is a VoIP app. App depends on voip apns notifications to receive information about new Voip calls from server.
I am posting the logs collected from console app here.
default 14:29:55.265590-0400 audiomxd -CMSessionMgr- CMSessionMgrHandleApplicationStateChange: Sending stop command to com.myapp.bundleid with pid '2933' because client is background suspended and there is no AirPlay video session for it
default 14:29:55.265753-0400 dasd Received state update for 2933 (app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>, running-suspended-NotVisible
default 14:29:55.265908-0400 locationd Received state update for 2933 (app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>, running-suspended-NotVisible
default 14:29:55.265994-0400 locationd {"msg":"invoking applicationStateChange handler", "StateChangeData":"{\n BKSApplicationStateAppIsFrontmost = 0;\n BKSApplicationStateExtensionKey = 0;\n SBApplicationStateDisplayIDKey = "com.myapp.bundleid";\n SBApplicationStateKey = 2;\n SBApplicationStateProcessIDKey = 2933;\n SBMostElevatedStateForProcessID = 2;\n}"}
default 14:29:55.266083-0400 locationd {"msg":"Post Application State Change Notification", "notification":"BackgroundTaskSuspended", "pid":2933, "bundleId":"com.myapp.bundleid"}
default 14:29:55.267019-0400 locationd {"msg":"#CLIUA AppMonitor notification", "notification":"BackgroundTaskSuspended", "pid":2933, "bundleId":"com.myapp.bundleid", "ClientKey":"icom.myapp.bundleid:"}
default 14:29:55.267061-0400 locationd {"msg":"skip erasing #CLIUA for RunningBoard Process State. Does not exists", "bundleId":"com.myapp.bundleid"}
default 14:29:55.267678-0400 watchdogd Received state update for 2933 (app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>, running-suspended-NotVisible
default 14:29:55.267765-0400 useractivityd Received state update for 2933 (app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>, running-suspended-NotVisible
default 14:29:55.267934-0400 symptomsd Received state update for 2933 (app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>, running-suspended-NotVisible
default 14:29:55.267982-0400 wifid Received state update for 2933 (app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>, running-suspended-NotVisible
default 14:29:55.268228-0400 UserEventAgent Received state update for 2933 (app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>, running-suspended-NotVisible
default 14:29:55.268275-0400 callservicesd Received state update for 2933 (app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>, running-suspended-NotVisible
default 14:29:55.268338-0400 WirelessRadioManagerd Received state update for 2933 (app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>, running-suspended-NotVisible
default 14:29:55.269217-0400 runningboardd Acquiring assertion targeting [app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>:2933] from originator [osservice<com.apple.dasd>:76] with description <RBSAssertionDescriptor| "DAS: Application is docked." ID:33-76-44901 target:2933 attributes:[
<RBSDomainAttribute| domain:"com.apple.dasd" name:"DockApp" sourceEnvironment:"(null)">
]>
default 14:29:55.269572-0400 runningboardd Assertion 33-76-44901 (target:[app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>:2933]) will be created as active
default 14:29:55.270431-0400 runningboardd [app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>:2933] Set jetsam priority to 30 [0] flag[1]
default 14:29:55.270658-0400 runningboardd Calculated state for app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>: running-suspended (role: None) (endowments: (null))
default 14:29:55.273005-0400 runningboardd Received termination request from [osservice<com.apple.dasd>:76] on <RBSProcessPredicate <RBSProcessHandlePredicateImpl| app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>:2933>> with context <RBSTerminateContext| explanation:BG Kill Demo reportType:None maxTerminationResistance:Interactive>
default 14:29:55.274715-0400 runningboardd Executing termination request for: <RBSProcessPredicate <RBSProcessHandlePredicateImpl| app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>:2933>>
default 14:29:55.275034-0400 runningboardd [app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>:2933] Terminating with context: <RBSTerminateContext| explanation:BG Kill Demo reportType:None maxTerminationResistance:Interactive>
default 14:29:55.275122-0400 runningboardd [app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>:2933] terminate_with_reason() success
default 14:29:55.275768-0400 SpringBoard [app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>:2933] Workspace connection invalidated.
default 14:29:55.275790-0400 SpringBoard [app<com.myapp.bundleid(AD9F24FF-321B-48U6-895F-723CDA943372)>:2933] Now flagged as pending exit for reason: workspace client connection invalidated
default 14:29:55.275815-0400 backboardd Connection removed: IOHIDEventSystemConnection uuid:C2525EA6-A052-480B-B83D-4BD62C29C6EC pid:2933 process:MyApp type:Passive entitlements:0x0 caller:BackBoardServices: + 280 attributes:{
HighFrequency = 1;
bundleID = "com.myapp.bundleid";
pid = 2933;
} state:0x1 events:9 mask:0x800 dropped:0 dropStatus:0 droppedMask:0x0 lastDroppedTime:NONE
default 14:29:55.275988-0400 backboardd Removing client connection <BKHIDClientConnection: 0xd43cd1f40; IOHIDEventSystemConnectionRef: 0xd415d5800; vpid: 2933(v1C3E); taskPort: 0x84D8B; bundleID: com.myapp.bundleid> for client: IOHIDEventSystemConnection uuid:C2525EA6-A052-480B-B83D-4BD62C29C6EC pid:2933 process:MyApp type:Passive entitlements:0x0 caller:BackBoardServices: + 280 attributes:{
HighFrequency = 1;
bundleID = "com.myapp.bundleid";
pid = 2933;
} state:0x1 events:9 mask:0x800 dropped:0 dropStatus:0 droppedMask:0x0 lastDroppedTime:NONE source:HID
default 14:29:55.288098-0400 runningboardd [app<com.myapp.bundleid(AD9F24F321B-48U6C7-895F-723CDA943372)>:2933] termination reported by launchd (15, 0, 9)
default 14:29:55.289192-0400 runningboardd Removing process: [app<com.myapp.bundleid(AD9F24F321B-48U6C7-895F-723CDA943372)>:2933]
default 14:29:55.289331-0400 runningboardd Removing launch job for: [app<com.myapp.bundleid(AD9F24F321B-48U6C7-895F-723CDA943372)>:2933]
default 14:29:55.289582-0400 runningboardd Removed job for [app<com.myapp.bundleid(AD9F24F321B-48U6C7-895F-723CDA943372)>:2933]
default 14:29:55.289706-0400 runningboardd Removing assertions for terminated process: [app<com.myapp.bundleid(AD9F24F321B-48U6C7-895F-723CDA943372)>:2933]
I have a custom class named CodeReadModel, which contains another custom class named CodeDataModel. The former contains the latter as an array like the following.
class CodeReadModel: NSObject, NSSecureCoding {
class var supportsSecureCoding: Bool { true }
let identifier: String
let codeDataModels: [CodeDataModel]
init(identifier: String, codeDataModels: [CodeDataModel]) {
self.identifier = identifier
self.codeDataModels = codeDataModels
}
required init(coder decoder: NSCoder) {
self.identifier = decoder.decodeObject(forKey: "identifier") as! String
self.codeDataModels = decoder.decodeObject(forKey: "codeDataModels") as! [CodeDataModel]
}
func encode(with coder: NSCoder) {
coder.encode(identifier, forKey: "identifier")
coder.encode(codeDataModels, forKey: "codeDataModels")
}
}
And I want to unarchive an object with the following.
func importCodeReaderSnippetNext(fileURL: URL) {
do {
NSKeyedUnarchiver.setClass(CodeReadModel.self, forClassName: "CodeReadModel")
NSKeyedUnarchiver.setClass(CodeDataModel.self, forClassName: "CodeDataModel")
let data = try! Data(contentsOf: fileURL)
if let codeReadModel = try NSKeyedUnarchiver.unarchivedObject(ofClass: CodeReadModel.self, from: data) {
}
} catch {
print("Error: \(error.localizedDescription)")
}
}
And I will get an error because codeReadModel contains another custom class, which cannot be decoded. How can I resolve this problem? Muchas thankos.
Hi,
python "import foundation" crushes without error message (but with a macos crush report) if the app is codesigned with Developer ID Application Certificate.(Without codesign, it works fine.)
1-test_simple_foundation.py(already attached):
import socket
import Foundation
print("hallo")
2-Install Nuitka:
pip install Nuitka
3-Generate App File via Nuitka:
echo *** | sudo -S python3.9 -m nuitka --run --standalone --macos-create-app-bundle --macos-app-mode=ui-element --macos-app-icon=icons/app_icon.png --include-data-dir=icons=icons test_simple_foundation.py
4-Copy app file under /applications
5-Execute test_simple_foundation.app file from terminal ./Applications/test_simple_foundation.app/Contents/MacOS/test_simple_foundation and observer that "hallo" is printed out
6-Codesign with following sh file(already attached):
7-Execute test_simple_foundation.app file from terminal ./Applications/test_simple_foundation.app/Contents/MacOS/test_simple_foundation and observer that code freezes with a macos crush report(already attached), after import Foundation nothing printed out.
MacOS_crush_report.txt
build-app_no_sand-sh.txt
test_simple_foundation-py.txt
pip list freeze.txt
app.entitlements.txt
Requirement:
python3.9 -m nuitka --version
1.9rc5
Commercial: None
Python: 3.9.12 (v3.9.12:b28265d7e6, Mar 23 2022, 18:22:40)
Flavor: CPython Official
Executable: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9
OS: Darwin
Arch: x86_64
Version C compiler: /usr/bin/clang (clang).
MacOS: Sonoma 14.2.1
1,6 GHz Dual-Core Intel Core i5
8 GB 2133 MHz LPDDR3
One of our apps has some failing unit tests that I traced back to a change in the way Calendar.date(from:) works on iOS 18 beta (22A5307d) as compared to earlier versions. The simple demo unit test below passes in iOS 17.5 and fails in 18 beta 3. I did not test this in other beta versions.
import XCTest
final class DateComponentsMath_Tests: XCTestCase {
func testAddingWeek() throws {
var components = DateComponents(
year: 2024,
weekOfYear: 1,
yearForWeekOfYear: 2024
)
let date1 = Calendar.current.date(from: components)!
// add a few weeks to the components
components.weekOfYear = components.weekOfYear! + 5
let date2 = Calendar.current.date(from: components)
XCTAssertNotEqual(date1, date2, "We added five weeks to the components so this should not result in the same date")
}
}
It appears that in iOS 18 (22A5307d), year, weekOfYear, and yearForWeekOfYear are no longer enough to uniquely specify a date. With those three values, Calendar.date(from:) always returns January 1 of the specified year. In earlier versions of iOS this was not the case.
I submitted this as FB14323984
In the recent MacOS Sequoia Beta 3 NSTextAttachment initialized with custom data and an Image cell as attachmentCell are shown as a file icon istead of the image cell.
I am creating a NSAttributedString and showing it in NSTextView like this:
NSTextAttachment *attachment = [[NSTextAttachment alloc] initWithData:[text dataUsingEncoding:NSUTF8StringEncoding] ofType:nil];
attachment.attachmentCell = [[NSTextAttachmentCell alloc] initImageCell:img];
NSMutableAttributedString *res = [[NSMutableAttributedString alloc] initWithAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]];
...
Starting from Xcode 16 Beta 2, NSValue.CGSizeValue is no longer available on watchOS, whereas this method was supported in previous versions of Xcode. The Xcode header files mark this method as unavailable on watchOS, but after manually modifying the Xcode files to remove the unavailable macro, the code compiles and runs normally. Is there a change in this API that makes it unsupported on watchOS, or is this an error?
Previously, I submitted feedback FB14072192, and the status of this feedback was updated to "Unable to diagnose with current information" without any further response. If this is indeed an issue, I hope it can be fixed.
I have an iPad 10 running iOS 18. I changed my icons to dark and it went well except for the Microsoft 365
I am developing a watchOS-only app, and whenever I attempt to make a network request, it always fails and throws the following error:
Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline."
I noticed that when I turn off Wi-Fi and Bluetooth in the settings of the iPhone paired with the Apple Watch (thus disconnecting the Apple Watch from the iPhone), my app can successfully connect to the network.
Additionally, when the app contains both an iOS app and a watchOS app, after granting network permissions on the iOS app, the watchOS app can access the network normally when connected to the iPhone.
When opening some system apps on the Apple Watch (such as the "Workout" app), the app will display a network permission request similar to that on iOS, but this request does not automatically pop up when my watchOS app attempts to access the network.
Is there a way to request network permissions in a watchOS-only app so that it can access the network while connected to the iPhone?
It looks like that, with Sequoia, it is not possible to open an NSURLSession or any other TCP connection to a machine on the local network if the application is not in the "Applications" folder. That is pretty inconvenient when debugging or running via Xcode since the build folder is not within the Applications folder.
And, yes, the NSLocalNetworkUsageDescription key and description strings are in the Info.plist file (and it asks for permission).
How can we expect to debug applications like that ?
Is anybody else experiencing this ?
Dear All,
Going through the list of currency codes in
Locale.commonISOCurrencyCodes
the following expression returns currency names
Locale.autoupdatingCurrent.localizedString(forCurrencyCode: currencyCode)
Surprisingly, this expression does not return names for some of the most common currency codes like EUR, USD and other.
How do I get a full list of names?
Any hint appreciated!
I need to decode JSON into a class. The JSON has a field called "Type", and I cannot declare a property with that name in my class since Type is a reserved word.
I tried declaring CodingKeys, but that doesn't work unless I declare EVERY property in the CodingKeys. This class has about a hundred properties and I have others like it, I do not want to do this.
Is there a better solution?
After iOS beta 2. download in iPhone 12 touch not work properly. Please fix this issue and please understand my problem. It’s a difficult problem for me. Please fix this issue as soon as possible.
Hello, I cannot accept that our completely original dating project was rejected by the App Store with the message 'there are too many similar applications'. How can I overcome this problem?
Hello,
I recently encountered an issue following the transfer of my app between Apple Developer accounts and would appreciate any insights or solutions.
Here's a summary of the situation:
App Transfer: I transferred an app from one Apple Developer account to another. The app's bundle ID remained unchanged during this process.
App Update: After the transfer, I integrated a new feature into the app and pushed the updated version to TestFlight under the new account.
Installation Issue: When I installed the TestFlight version of the app from the new account on my device, which already had the app installed from the old account, the app logged out the user. It appears that the UserDefaults data was not retained, resulting in the loss of stored user data.
My hypothesis is that the transfer between accounts caused the user defaults to reset, leading to the data loss.
Has anyone else experienced this issue, and if so, are there any recommended solutions or best practices to prevent UserDefaults from resetting during such transfers?
Thank you in advance for your assistance.
NSString *filePath = @"/var/mobile/Media/DCIM/100APPLE/IMG_0800.MP4";
NSURL *fileURL = [NSURL fileURLWithPath:filePath];
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:fileURL options:nil];
Before iOS 18, you could access AVAsset using the method mentioned above, but starting from the iOS 18 beta version, the following error appears
Error Domain=NSCocoaErrorDomain Code=257 "未能打开文件“IMG_0800.MP4”,因为你没有查看它的权限。" UserInfo={NSURL=file:///var/mobile/Media/DCIM/100APPLE/IMG_0800.MP4, AVErrorFailedDependenciesKey=(
"assetProperty_AssetType"
), NSUnderlyingError=0x30c497f60 {Error Domain=NSOSStatusErrorDomain Code=-12203 "(null)"}}
Hello VisionOS Developer Community,
I am currently working on a demo application for VisionOS, tailored for the Vision Pro. In my application, I have implemented a feature to prevent the screen from sleeping using the following code:
UIApplication.shared.isIdleTimerDisabled = true
This works perfectly on iOS, ensuring the screen remains active regardless of other system settings. However, I've run into a snag with VisionOS. Even with isIdleTimerDisabled set to true, the screen still sleeps when I take off the Vision Pro.