Team-scoped keys introduce the ability to restrict your token authentication keys to either development or production environments. Topic-specific keys in addition to environment isolation allow you to associate each key with a specific Bundle ID streamlining key management.
For detailed instructions on accessing these features, read our updated documentation on establishing a token-based connection to APNs.
Delve into the world of built-in app and system services available to developers. Discuss leveraging these services to enhance your app's functionality and user experience.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'm trying to create a UIImage from a MKLookAroundScene, after the user has moved the scene, by looking (and moving) around. Is this possible?
When I use MKLookAroundSnapshotter with the modified scene, I always get an image of the original (starting) scene.
STEPS TO REPRODUCE
Create a scene using MKLookAroundSceneRequest with coordinates.
Use LookAroundPreview with a binding to MKLookAroundScene to get changes to the scene (based on looking around).
User begins LookAround, moving the scene location and view.
User ends LookAround
The preview displays the updated scene properly.
The scene's cameraFrameOverride values reflect the pitch, roll, yaw, and location changes.
Pass the updated scene to MKLookAroundSnapshotter to get an image.
Display the Image.
The Image is the original scene (not what is displayed in the preview).
Hello all,
I am quite new to iOS and Swift, and before venturing further, I feel it's better to ask for advice.
I have build a Type I diabetes simulator running as a NodeJS application on a server. The clients authenticate via a browser using Fitbit/Google oauth2, set up a virtual patient, then take care of the patient 24/7. The app imports the users steps and heartrate, as these influence the blood sugar variations. (https://cgmsim.com)
I designed a companion app with Expo, adding high/log blood glucose alerts with push notifications. If the user doesn't have a Fitbit tracker or doesn't use Google Fit, I'd like to send their HealthKit step counts to the backend. (Using sensor data directly in Android).
It works using Expo's Background Fetch and TaskManager, but the uploads from the iOS device are very irregular. I set up silent push notifications from the backend to wake up the app in the background and trigger the step count upload. It works, but it is not reliable enough.
I now wrote my first local native module for iOS, where a HKObserverQuery listening for new step events, making the upload and sending the count to the JS for rendering. I used enableBackgroundDelivery and BackgroundTask for uploading the results. All the entitlements and Info.plist entries should be ok. Still my app works well only in the foreground, and not upload at all happens when in the background.
As we all do, I asked Claude, and it assured me th app should work. I have doubts though, as I noticed how strict iOS is about executing background tasks. So... should I even expect this to work ?
My app crashes when a button is pressed, however only on a small percentage of devices. I can't reproduce it on my end, but I have a crash log from a TestFlight user. Any thoughts on what this crash log could be indicating?
crashlog.crash
Since updating to iOS v17.4.1 our safari extension no longer functions as it used to
We are experiencing issues where our content script is not getting initialized, On devices running iOS 17.4.1, the content script included in our extension does not appear to run. There are no logs from the content script in the console, whereas on other versions and devices, it operates as expected. Our Extension relies con communication between the background and content scripts in order for us to render various popups to our users, based on our logs as of iOS 17.4.1 this communication is not successful, we can see messages being sent from the background script but as mentioned above nothing on the content script side.
This behavior happens majority of the time and on random sites, sometimes opening the same site in a new tab would work but not always. There are also times where we would only receive our popups after opening the safari menu and interacting with our extension via this menu.
Please assist with a way forward
Topic:
App & System Services
SubTopic:
General
Tags:
Extensions
Safari
Safari and Web
Safari Extensions
I have developed and distributed a Mac app on App Store. From the Organizer in Xcode, I noticed that it has a lot of crashes. And 90% of these crashes is the same crash as following:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00007ff81ce27112 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007ff81ce5d233 pthread_kill + 263
2 libsystem_c.dylib 0x00007ff81cda9d10 abort + 123
3 libc++abi.dylib 0x00007ff81ce1a0b2 abort_message + 241
4 libc++abi.dylib 0x00007ff81ce0b1fd demangling_terminate_handler() + 266
5 libobjc.A.dylib 0x00007ff81cd08509 _objc_terminate() + 96
6 libc++abi.dylib 0x00007ff81ce194d7 std::__terminate(void (*)()) + 8
7 libc++abi.dylib 0x00007ff81ce19488 std::terminate() + 56
8 libdispatch.dylib 0x00007ff81cca6cdd _dispatch_client_callout + 28
9 libdispatch.dylib 0x00007ff81cca9746 _dispatch_continuation_pop + 460
10 libdispatch.dylib 0x00007ff81ccbaa5a _dispatch_source_invoke + 2150
11 libdispatch.dylib 0x00007ff81ccb3518 _dispatch_main_queue_callback_4CF + 759
12 CoreFoundation 0x00007ff81cf625d9 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9
13 CoreFoundation 0x00007ff81cf236ae __CFRunLoopRun + 2752
14 CoreFoundation 0x00007ff81cf2252d CFRunLoopRunSpecific + 563
15 HIToolbox 0x00007ff825b403e1 RunCurrentEventLoopInMode + 292
16 HIToolbox 0x00007ff825b40137 ReceiveNextEventCommon + 587
17 HIToolbox 0x00007ff825b3fed5 _BlockUntilNextEventMatchingListInModeWithFilter + 70
18 AppKit 0x00007ff81f94d8f0 _DPSNextEvent + 886
19 AppKit 0x00007ff81f94bf5c -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1411
20 AppKit 0x00007ff81f93e359 -[NSApplication run] + 586
21 AppKit 0x00007ff81f9121f8 NSApplicationMain + 816
How to fix this issue?
I have created a NEPacketTunnelProvider which seems to work currently in testing.
However I have noticed that the DNS do not go through the TUN interface, even setting a bogus DNS server in NEPacketTunnelNetworkSettings still has no effect and I'm able to browse just fine.
I also know that there is the DNS Proxy Provider, can it be used in conjuction with Packet Tunnel Provider?
Though from what I have read this is not available for the general public and can only be used on supervised / managed devices?
Are there any supported methods of running a local DNS server, say on 127.0.0.1 and redirect all DNS queries to this server?
I've been trying to access the NSMetaData information for mb4 objects that I legally downloaded from third party websites without DRM protection. I posted a request in the app forum before and didn't receive any responses from anyone, so it occurred to me to use the example apple code provided on NSMetaData Objects.
Steps to reproduce: download the "simpleiclouddocument" example and changed the document extension to Mb4. It seems the query fails because the documents are outside the application directory, so I expanded the search scope to include "NSMetaDataQueryAccessibleExternalDocumentsScope" and the files are still not found.
I have the URL of the file that I want the MetaData for. I understand that NSMetaData has an init object that works with a URL but it only works on MacOS and not iOS. I have alternatively tried using LPLinkPresentation and AVMetdataItem but these two alternatives appear to limit the metadata fields I can access and there is no additional object data on how to expand the links to access the other metadata items associated with the file, specifically the Author field as Mb4 files have authors in addition to other audio metadata settings. If there is additional information somewhere on those two classes that identifies how I can access the rest of the metadata fields that would likewise correct my problem.
The app needs to maintain internet communication under the following conditions:
Both Wi-Fi and cellular networks are active.
The Wi-Fi network has no internet connection.
The cellular network has an active internet connection.
Topic:
App & System Services
SubTopic:
Networking
as part of the iOS 17 apple added Network details capability to the shortcut app
is there any update about the ability of getting the Network details such as RSSI , PHY in iOS 18?
In my recent endeavor, I aimed to introduce new Fetch Index Elements to the Core Data model of my iOS application. To achieve this, I followed a process of lightweight migration, detailed as follows:
Navigate to Editor > Add Model Version to create a new version of the data model.
Name the new version with a sequential identifier (e.g., MyAppModelV3.xcdatamodel) based on the naming convention of previous models.
Select the newly created version, MyAppModelV3.xcdatamodel, as the active model.
Mark this new version as the "Current" model in the Xcode properties panel on the right.
In the new version of the model, MyAppModelV3.xcdatamodel, and add the new Fetch Index Elements there. Also, insert "v3" in the Versioning Hash Modifier field of affected entity, to indicate this modification.
Upon reflection, I realized that creating a new version of the xcdatamodel might not have been necessary for this particular case. However, it appears to have caused no adverse effects on the application's functionality.
During testing, I executed the application in a simulated environment, initially running an older version of the app to inspect the database content with SQLite DB Browser. I then upgraded to the latest app version to verify that the migration was successfully completed without causing any crashes. Throughout this testing phase, I employed the -com.apple.CoreData.MigrationDebug 1 flag to monitor all SQL operations, ensuring that indexes were appropriately dropped and recreated for the affected entity.
Following thorough testing, I deployed the update to production. The majority of users were able to upgrade to the new app version seamlessly. However, a small fraction reported crashes at startup, indicated by the following error message:
Fatal error: Unresolved error Error Domain=NSCocoaErrorDomain Code=134110 "An error occurred during persistent store migration." UserInfo={NSUnderlyingError=0x2820ad3e0 {Error Domain=NSCocoaErrorDomain Code=134100 "The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store." UserInfo={metadata={ NSPersistenceFrameworkVersion = 1338; NSStoreModelVersionChecksumKey = "qcPf6+DfpsPrDQ3j1EVXcBIrFe1O0R6IKd30sJf4IrI="; NSStoreModelVersionHashes = { NSAttachment = {length = 32, ...
Strangely, the only way I could replicate this issue in the simulator was by running the latest version of the app followed by reverting to an older version, a scenario unlikely to occur in a real-world setting. This raises the question: How could this situation arise with actual users, considering they would typically move from an old to a new version rather than the reverse?
I am reaching out to the community for insights or advice on this matter. Has anyone else encountered a similar problem during the Core Data migration process? How did you resolve it?
Hi,
I am inserting two models where the "unique" attribute is the same. I was under the impression, that this should result in an upsert and not two inserts of the model, but that is not the case.
See the test coding below for what I am doing (it is self contained, so if you want to try it out, just copy it into a test target). The last #expect statement fails because of the two inserts. Not sure if this is a bug (Xcode 16 beta 2 on Sonoma running an iOS 18 simulator) or if I am missing something here...
// MARK: - UniqueItem -
@Model
final class UniqueItem {
#Unique<UniqueItem>([\.no])
var timestamp = Date()
var title: String
var changed = false
var no: Int
init(title: String, no: Int) {
self.title = title
self.no = no
}
}
// MARK: - InsertTests -
@Suite("Insert Tests", .serialized)
struct InsertTests {
var sharedModelContainer: ModelContainer = {
let schema = Schema([
UniqueItem.self,
])
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
do {
return try ModelContainer(for: schema, configurations: [modelConfiguration])
} catch {
fatalError("Could not create ModelContainer: \(error)")
}
}()
@Test("Test unique.")
@MainActor func upsertAndModify() async throws {
let ctx = sharedModelContainer.mainContext
try ctx.delete(model: UniqueItem.self)
let item = UniqueItem(title: "Item \(1)", no: 0)
ctx.insert(item)
let allFD = FetchDescriptor<UniqueItem>()
let count = try ctx.fetchCount(allFD)
#expect(count == 1)
let updatedItem = UniqueItem(title: "Item \(1)", no: 0)
updatedItem.changed = true
ctx.insert(updatedItem)
// we should still have only 1 item because of the unique constraint
let allCount = try ctx.fetchCount(allFD)
#expect(allCount == 1)
}
}
Feedback ID: FB15148112
Hello, I have submitted a feedback on feedback assistant. I am using iphone 14 pro ios 17.5.1.
Since yesterday, I can not enter settings app. and on some screens my phone crashes.
While deleting an app, also system crashes.
Can you look at the logs at sysdiagnose_2024.09.16_23-52-06+0300_iPhone-OS_iPhone_21F90.tar.gz ?
Thank you
I want to share my ticket here due to current issue is very crucial for me.
Ticket:
Which of the following did you encounter on-screen when the system crash occurred?
Gray Loading Spinner appeared over black screen
What were you doing on the device just before the crash occurred?
whatever i do
Please describe the issue and what steps we can take to reproduce it:
when i open settings, it is not opening and also when i switch between screens it freezes and shutdown with spinner. i am very sad :( i can not use my phone.
it began today morning
i am software engineer, i try to find log details via xcode but i could not catch it. only localization text missings error exist on logs. but i could not find the solution.
please help me
thank you
Topic:
App & System Services
SubTopic:
Core OS
Hi everyone,
I'm currently working on testing in-app purchases for my app, and I'm having issues with logging into a sandbox account on my iPhone.
Here's the situation:
I created a sandbox account via App Store Connect.
I signed out of my regular Apple ID from the App Store and attempted to log in with my sandbox account during an in-app purchase.
I receive a verification code on my phone, and it seems like the login is working. However, after entering the code, I keep getting redirected back to the "Sign in with Apple Account" screen. It doesn’t fully log me in.
I’ve tried resetting network settings, restarting the device, and even creating a new sandbox account, but nothing seems to work.
I'm running the app through Expo prebuild and attempting to test purchases, but without being able to log into the sandbox environment, I can’t move forward.
Has anyone encountered this issue before or know how to fix it? Any help would be greatly appreciated!
Thanks!
When users share a file with my app I am having trouble 5-10% of the time obtaining the file meta data, specifically creation and modified time and size.
Using SwiftUI with the code below..
.onOpenURL { url in
var fileSize: Int64 = 0
var creationTime: Date = Date(timeIntervalSince1970: 0)
var modificationTime: Date = Date(timeIntervalSince1970: 0)
do {
let fileAttributes = try FileManager.default.attributesOfItem(atPath: url.path)
fileSize = fileAttributes[FileAttributeKey.size] as? Int64 ?? 0
creationTime = fileAttributes[FileAttributeKey.creationDate] as? Date ?? Date(timeIntervalSince1970: 0)
modificationTime = fileAttributes[FileAttributeKey.modificationDate] as? Date ?? Date(timeIntervalSince1970: 0)
<SNIPPED CODE no other tries though and not involving above variables>
} catch {
// quite confident I am ending up here because variables after the above code aren’t being set and there are no other try blocks,
// so FileManager.default.attributesOfItem(atPath: url.path) must be throwing….
}
<SNIPPED CODE>
To attempt to resolve this, I added in a 0.5 second wait cycle if creationTime == 0 and modificationTime == 0 , so if obtaining both metadata fails, wait 0.5 seconds and try again, try this a max of 3 times and then give up. I don’t know how often I am entering this code (didn’t instrument the app for it), but am still getting times when metadata comes back blank which means this code wasn’t successful after 3 tries.
I assume the file would only become visible and sharable with my app after it has completed being written by the original app/process. Perhaps it hasn’t finalized yet? Is there a way to detect this so I can tell the user in my share screen to wait and try again?
I am assuming that the file has finished writing though since when I read the data from the file contents, it’s good data and complete even when metadata failed.
I will be instrumenting the above code in my next app version, just hoping to fix it right now since users are emailing saying my app is broken.
Thanks!
Topic:
App & System Services
SubTopic:
Core OS
Tags:
File Provider
Files and Storage
APFS
Inter-process communication
Users will receive a unique ID, if a user enters another user's ID they will go to a view where both have access to the information, being able to change, add, delete...
(Paired, available on App Store)
Public container is not secure, private with ckshare doesn't seem to work for what I would like, plus the content is very confusing
I need something that uses native Apple technologies to build this system.
Hi all,
I'm developing an TCP socket SDK in C. The SDK is using Apple Network Framework and encountered some wired bad access issue occasionally on function nw_connection_send.
Looking into the trace stack, it was bad access issue in nw_write_request_create, when it is trying to release a reference. However, I could not found more doc/source code details about nw_write_request_create.
// on socket destroy, we will release the related nw_connection.
increase_ref_count(socket)
nw_connection_t nw_connection = socket->nw_connection;
dispatch_data_t data = dispatch_data_create(message_ptr->ptr, message_ptr->len, dispath_event_loop, DISPATCH_DATA_DESTRUCTOR_FREE);
// > Bad Access here <
// While I check `nw_connection` and `data`, both seems available while the function get called. I tried to call dispatch_retain on `data`, but it was not helpful.
nw_connection_send( nw_connection, data, NW_CONNECTION_DEFAULT_MESSAGE_CONTEXT, false, ^(nw_error_t error) {
// process the message, we will release message_buf in this function.
completed_fn(message_buf);
reduce_ref_count(socket)
}
While I check nw_connection and data, both seems available while the function get called. I tried to call dispatch_retain on data, but it was not helpful. Is there any way to narrow down which object is releasing?
As the issue happened occasionally (9 failure out of 10 attempts when I run multiple unit tests at the same time, and I rarely see it when I ran a single unit test).
I would assume it was actually a race condition here. Is there a way to track down which object is released?
I do understand it would be hard to track without knowing more design details of my SDK, but any related suggestions or ideas would be appreciated. Thanks in advance.
More related source code:
struct nw_socket{
nw_connection_t nw_connection;
nw_parameters_t socket_options_to_params;
dispatch_queue_t event_loop;
// ... bunch of other parameters...
struct ref_count ref_count;
}
static int s_socket_connect_fn(
const struct socket_endpoint *remote_endpoint,
struct dispatch_queue_t event_loop)
{
nw_socket = /*new socket memory allocation, increasing ref count*/
nw_endpoint_t endpoint = nw_endpoint_create_address(/* process remote_endpoint */);
nw_socket->nw_connection = nw_connection_create(endpoint, nw_socket >socket_options_to_params);
nw_release(endpoint);
nw_socket->nw_connection->set_queue(nw_socket->nw_connection, event_loop);
nw_socket->event_loop = event_loop;
nw_connection_set_state_changed_handler(nw_socket->nw_connection, ^(nw_connection_state_t state, nw_error_t error) {
// setup connection handler
}
nw_connection_start(nw_socket->nw_connection);
nw_retain(nw_socket->nw_connection);
}
// nw_socket is ref counted, call the destroy function on ref_count reduced to 0
static void s_socket_impl_destroy(void *sock_ptr) {
struct nw_socket *nw_socket = sock_ptr;
/* Network Framework cleanup */
if (nw_socket->socket_options_to_params) {
nw_release(nw_socket->socket_options_to_params);
nw_socket->socket_options_to_params = NULL;
}
if (nw_socket->nw_connection) {
nw_release(nw_socket->nw_connection);
// Print here, to make sure the nw_connection was not released before nw_connection_send call.
nw_socket->nw_connection = NULL;
}
// releasing memory and other parameters
}
static int s_socket_write_fn(
struct nw_socket *socket,
const struct bytePtr* message_ptr, // message_ptr is a pointer to allocated message_buf
socket_on_write_completed_fn *completed_fn,
void *message_buf) {
// Ideally nw_connection would not be released, as socket ref_count is retained here.
increase_ref_count(socket->ref_count);
nw_connection_t nw_connection = socket->nw_connection;
struct dispatch_queue_t dispatch_event_loop = socket->event_loop;
dispatch_data_t data = dispatch_data_create(message_ptr->ptr, message_ptr->len, dispath_event_loop, DISPATCH_DATA_DESTRUCTOR_FREE);
// > Bad Access here <
// While I check `nw_connection` and `data`, both seems available while the function get called. I tried to call dispatch_retain on `data`, but it is not helpful.
nw_connection_send( nw_connection, data, NW_CONNECTION_DEFAULT_MESSAGE_CONTEXT, false, ^(nw_error_t error) {
// process the message, we will release message_buf in this function.
completed_fn(message_buf);
reduce_ref_count(socket)
}
}
Hi all,
My co-worker today noticed that on his Mac running a beta of Sequoia, the IPv6 multicast functionality of our application was no longer working. This same executable works fine under Sonoma and earlier versions of MacOS, and has worked fine for a number of years. Under Sequoia, however, calls to sendto() a packet to an IPv6-link-local-multicast address (e.g. ff12::bead:cede:deed:feed, preceeded by a call to setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, ...) to specify the appropriate network interface index) return -1 and set errno to EHOSTUNREACH aka "No route to host".
The interesting thing about it is, this problem only occurs if we launch our app by double-clicking on its icon; if we instead run the app from Terminal (e.g. by entering ./MyApp.app/Contents/MacOS/MyApp), the multicast functionality works as expected. Our app is signed and notarized in all the usual expected ways.
My question is, is this "just" a networking regression in the Sequoia beta, or is there some new requirement in macOS/Sequoia for IPv6-link-local-multicast-using apps to have a multicast entitlement (a la iOS) or something?
I have a volumetric app. I am trying to present a review prompt using SKStoreReviewController's requestReview(in:) I'm using the code below:
if let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
SKStoreReviewController.requestReview(in: scene)
}
When this code executes, though, I get a crash with the error:
Presentations are not permitted within volumetric window scenes.
What is the proper way to do this for a volumetric app?
I tried to use XCTest to test my own project that uses EndpointSecurity, but when I created the esClient I got an error:ES_NEW_CLIENT_RESULT_ERR_NOT_PRIVILEGED, indicating that it was not root.
This makes it impossible for me to do coverage tests for the ESClient application. Is there any way I can implement this ESClient test? If so, how should I use it? The project is a macOS program, if I use gcov, but I find I can't get coverage. Using __gcov_flush will indicate that there is no symbol
#if !TARGET_IPHONE_SIMULATOR
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
setenv("GCOV_PREFIX", [documentsDirectory cStringUsingEncoding:NSUTF8StringEncoding], 1);
setenv("GCOV_PREFIX_STRIP", "13", 1);
#endif
extern void __gcov_flush(void);
__gcov_flush();
#endif
Topic:
App & System Services
SubTopic:
Processes & Concurrency
Tags:
Xcode
XCTest
Testing
Endpoint Security
Hello,
I'm trying to implement a PIN request feature for a Sony TV in my iOS app. The goal is to keep the PIN entry window open on the TV until the user enters the PIN. However, I'm encountering an issue where the connection is closed immediately when using Swift's URLSession, while the same request works as expected in Postman.
Here's my Swift code:
let parameters = """
{
"method": "actRegister",
"params": [
{
"clientid": "MyDevice:1",
"nickname": "My Device",
"level": "private"
},
[
{
"value": "yes",
"function": "WOL"
}
]
],
"id": 1,
"version": "1.0"
}
"""
guard let postData = parameters.data(using: .utf8) else {
completion(.failure(NSError(domain: "Invalid data", code: 0, userInfo: nil)))
return
}
var request = URLRequest(url: URL(string: "http://\(ipAddress)/sony/accessControl")!,timeoutInterval: 30)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
completion(.failure(error))
return
}
guard let data = data else {
completion(.failure(NSError(domain: "No data received", code: 0, userInfo: nil)))
return
}
if let responseString = String(data: data, encoding: .utf8) {
print("Response: \(responseString)")
}
}
task.resume()
When I send this request using Postman, the PIN window on the TV stays open as expected. I receive a 401 response, which is normal for this type of request. In Postman, I can simulate the unwanted behavior by sending the request twice in quick succession, which closes the PIN window.
However, when I run this code in the iPhone Simulator, the PIN window on the TV closes immediately after appearing.
What I've tried:
Increasing the timeoutInterval
Using URLSession.shared.dataTask and URLSession(configuration:delegate:delegateQueue:)
Implementing URLSessionDataDelegate methods
Expected behavior: The PIN window should stay open on the TV until the user enters the PIN or a timeout occurs.
Actual behavior: The PIN window appears briefly on the TV and then closes immediately.
Questions:
Why does the behavior differ between Postman and my Swift code?
How can I modify my Swift code to keep the connection open and the PIN window displayed on the TV?
Is there a way to prevent URLSession from automatically closing the connection after receiving the 401 response?
Any insights or suggestions would be greatly appreciated. Thank you!
Environment:
iOS 15+
Swift 5
Xcode 13+
Topic:
App & System Services
SubTopic:
Networking