On macOS, the Finder allows to connect to a server and store the login credentials. When creating a bookmark to a file on a server and resolving it again, the server is mounted automatically (unless I provide the option URL.BookmarkResolutionOptions.withoutMounting).
I just tried connecting to my Mac from my iPad via SMB in the Files app and storing a bookmark to a file on the server, but disconnecting the server and trying to resolve the bookmark throws the error (I translated the English text from Italian):
Error Domain=NSFileProviderErrorDomain Code=-2001 "No file provider was found with the identifier "com.apple.SMBClientProvider.FileProvider"'" UserInfo={NSLocalizedDescription=No file provider was found with the identifier "com.apple.SMBClientProvider.FileProvider"., NSUnderlyingError=0x302a1a340 {Error Domain=NSFileProviderErrorDomain Code=-2013 "(null) "}}
Every time I disconnect and reconnect to the server, selecting the same file returns a different path. The first time I got
/private/var/mobile/Library/LiveFiles/com.apple.filesystems.smbclientd/WtFD3Ausername/path/to/file.txt
The next time WtFD3A changed to EqHc2g and so on.
Is it not possible to automatically mount a server when resolving a bookmark on iOS?
The following code allows to reproduce the issue:
struct ContentView: View {
@State private var isPresentingFilePicker = false
@AppStorage("bookmarkData") private var bookmarkData: Data?
@State private var url: URL?
@State private var stale = false
@State private var error: Error?
var body: some View {
VStack {
Button("Open") {
isPresentingFilePicker = true
}
if let url = url {
Text(url.path)
} else if bookmarkData != nil {
Text("couldn't resolve bookmark data")
} else {
Text("no bookmark data")
}
if stale {
Text("bookmark is stale")
}
if let error = error {
Text("\(error)")
.foregroundStyle(.red)
}
}
.padding()
.fileImporter(isPresented: $isPresentingFilePicker, allowedContentTypes: [.data]) { result in
do {
let url = try result.get()
if url.startAccessingSecurityScopedResource() {
bookmarkData = try url.bookmarkData()
}
} catch {
self.error = error
}
}
.onChange(of: bookmarkData, initial: true) { _, bookmarkData in
if let bookmarkData = bookmarkData {
do {
url = try URL(resolvingBookmarkData: bookmarkData, bookmarkDataIsStale: &stale)
} catch {
self.error = error
}
}
}
}
}
Core OS
RSS for tagExplore the core architecture of the operating system, including the kernel, memory management, and process scheduling.
Post
Replies
Boosts
Views
Activity
Hi all,
I use the FileManager trashIitem function to put a file in the trash.
If it is only one file, then the option to put it back is available.
If, however, several files are deleted, the option to put it back is only available for the first
deleted file. All others cannot be put back.
The problem has been known for at least 10 years.
See Put back only works for the first file.
NSWorkspace recycle has the same problem.
It seems to be due to .DS_Store in the trash. The files that are in the trash are stored there. This may also lead you to believe that the trashItem function is working properly because the deleted files are still in the .DS_Store file.
If I call trashItem or recycle several times and wait 2 seconds between calls, then the option to put it back is available for all of them.
That obviously can't be the solution. Waiting less than 2 seconds only offers to put the first file back.
So trashItem and recycle are the same as remove, with the difference that you can look at the files in the trash can again, but not put them back.
Are there other ways?
The Finder can also delete multiple files and put them all back.
On macOS, we have didMountNotification but there doesn't seem to be an equivalent for iOS. Is there a way to be notified when a volume is mounted on iOS? I would like to use it in my iOS app I'm currently porting from macOS, which starts a synchronization from the volume (which has been previously selected in a NSOpenPanel) as soon as it's mounted.
Hi: Our group would like to forward logs from our Macs in our integration/production environments to a central server. I haven't found any good documentation for this yet.
Can anyone point me to a way to forward to a Graylog or syslog-based server?
We're not against cobbling together an app or script using "log stream" to send the info ourselves, but that seems extreme for what I'd think is a very common use case.
Crashed: com.apple.libcache.memorypressure
0 libsystem_platform.dylib 0x4ce4 _os_unfair_lock_recursive_abort + 36
1 libsystem_platform.dylib 0x1e1c _os_unfair_lock_lock_slow + 308
2 libcache.dylib 0x3a50 cache_remove_all + 56
3 CoreFoundation 0xd8d18 -[NSCache dealloc] + 84
4 Photos 0x505e4 -[PHSafeNSCacheDelegateReflector cache:willEvictObject:] + 216
5 CoreFoundation 0xbe524 __NSCacheCallDelegateWillEvictObjectCallbackWithValue + 76
6 CoreFoundation 0xbe43c __NSCacheValueRelease + 104
7 libcache.dylib 0x3998 _value_entry_remove + 120
8 libcache.dylib 0x3898 _entry_evict + 188
9 libcache.dylib 0x37c8 _evict_last + 108
10 libcache.dylib 0x3108 _cache_enforce_limits + 104
11 libcache.dylib 0x16f4 ___cache_handle_memory_pressure_event_block_invoke + 92
12 libdispatch.dylib 0x13394 _dispatch_block_async_invoke2 + 148
13 libdispatch.dylib 0x3fa8 _dispatch_client_callout + 20
14 libdispatch.dylib 0xd76c _dispatch_workloop_invoke + 2172
15 libdispatch.dylib 0x1738c _dispatch_root_queue_drain_deferred_wlh + 288
16 libdispatch.dylib 0x16bd8 _dispatch_workloop_worker_thread + 540
17 libsystem_pthread.dylib 0x3680 _pthread_wqthread + 288
18 libsystem_pthread.dylib 0x1474 start_wqthread + 8
Hello,
I am working on application which licenses depends on number of user sessions which logged in.
The problem is the application "Migration Assistant" creates new session for "Setup User" and it leads to licenses leak.
# cat /etc/passwd | grep Setup
_mbsetupuser:*:248:248:Setup User:/var/setup:/bin/bash
Are there any difference between _mbsetupuser and users which is created by administrator via "System Settings" or dscl?
(e.g. specific user id range which using is restricted by system).
Are there any way to detect _mbsetupuser and be sure this user is predefined during system install?
Thank you in advance,
Pavel
When my app launches, it makes maybe 9 or so network requests to load initial data. It also reads some data from disc.
Sporadically, I'm seeing an issue where some of the network requests succeed, but anything involving reading from disc does not load immediately. I'm able to move around in the app, tap buttons, swap tabs, swipe pages, so my main actor isn't stuck. Other data that don't involve disc reading / writing is also blank. About 2 minutes in, suddenly everything loads (both stuff from disc and stuff from the network), nearly instantly, the way it should have done when the app launched.
Server logs show more initial network requests succeed than we can see data loaded in the app, and then about 2 minutes later, there's a flood of the rest of the requests which then succeed.
The responses to some of these initial network requests cause us to make other network requests, and the sever sees some of those start right away.
However, other consequences of these first requests are to touch the disc (to search for manually-cached data), and anything that is supposed to happen after that does not succeed until the 2 minute mark.
But what bothers me is some things in the app which don't touch the disc also seem to have successful network requests.
I'm seeing it on an iPhone 14Pro running iOS 18.2.1, with 607 GB of disc space available.
When I take screenshots of the loading screens in my app during the apparent freeze, the clock in the screenshots are right - they reflect the clock at the moment I took the screenshot, but the EXIF data in all dozen or so images shows the exact second 2 minutes later when the server gets the resulting flood of network requests. Screenshots taken after the freeze is over have exif timestamps that match the screenshots, as short as 5 seconds after the freeze ends. The screenshot file names, though sequential, are out of order. for instance, some screenshots from 12:58 have file names numbered after screenshots taken at 12:59. but not all are out of order.
This seems like disc contention has spread outside the app, and is impacting the system writing the images to disc.
How do I diagnose a cause for this? How does disc contention affect the networking? I have caching turned off for my network requests. We only have a manual image cache, but I don't know how that would stall the display of data that should fetch and display without attempting to hit the image cache.
This happens maybe a couple of times a day for some people, maybe once every couple of weeks for others, but of course, it never when we're trying to debug it.
Hey fellow developers,
I’m developing an app that mounts network shares (SMB, AFP, Secure WebDAV, CIFS) using the NetFSMountURLAsync function.
Recently, mounting WebDAV shares has stopped working — it fails with error code 22, but I can’t find a definitive reason for the failure. It simply doesn’t work. However, using Finder to connect to the same WebDAV share works flawlessly, so it doesn’t appear to be a server-side issue.
Strange Behavior
I’ve noticed something interesting:
If I create a new Xcode project and set Signing Certificate to Sign to Run Locally, the app mounts the WebDAV share without any issues.
As soon as I change the signing option to anything else (e.g., Development), the share no longer mounts, and the app fails with error 22.
Even if I switch back to Sign to Run Locally, the app remains broken and refuses to mount the share.
Rebuilding the app, restarting Xcode, and clearing derived data/caches do not restore functionality. The only workaround I’ve found is to create a new Xcode project and copy the code over.
Additionally:
Mounting SMB and AFP shares always works without issues.
The app is properly sandboxed.
My certificates are valid until at least 2027.
Granting the app Full Disk Access does not resolve the issue.
System Log Insights
Looking at the system log, I found several mounting-related messages. On failure, one stands out:
System Policy: webdavfs_agent() deny(1) file-mount <Path to the mount directory in the Documents directory of the example project>
Questions
Does anyone have any idea how to debug or resolve this issue?
Is there a way to reset the example project to a working state? Are there any caches or system states I might have missed?
I’d prefer not to recreate all my certificates and configurations, as I don’t see any reason why they would affect only WebDAV mounting while everything else works fine.
Reproducing the Issue
I’ve created a minimal SwiftUI example to reproduce the problem. Just create a new macOS SwiftUI project, replace ContentView with my code, update the details to match your WebDAV share, and enable Outgoing Network Connections in the entitlements.
Any help or insights would be greatly appreciated!
Example Code
import SwiftUI
import NetFS
struct ContentView: View {
let mounter = WebDAVMounter()
var body: some View { VStack { Button("Test mount") { test() } } .padding() }
func test() { mounter.mount() }
}
class WebDAVMounter {
private var requestID: AsyncRequestID?
func mount() {
let username = <# username #>
let password = <#password#>
let serverURL = URL(string: "<#https://webfiles/Work~Home#>")!
let usedMountPoint = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
let openOptions = NSMutableDictionary()
openOptions[kNAUIOptionKey] = kNAUIOptionNoUI
let mountOpts = NSMutableDictionary()
mountOpts[kNetFSSoftMountKey] = true
print("server URL: \(serverURL) usedMountPoint: \(usedMountPoint) username: \(username) password: \(password) sessionOpts: \(openOptions) mountOptions \(mountOpts)")
NetFSMountURLAsync(serverURL as CFURL,
usedMountPoint as CFURL,
username as CFString?,
password as CFString?,
openOptions as CFMutableDictionary,
mountOpts as CFMutableDictionary,
&requestID,
DispatchQueue.main,
{ status, asyncRequestId, mountedDirs in print("mount_report: \(status), mountedDirs: \(String(describing: mountedDirs))")})
}
}
The Developer documentation for IOKit marks it as available for iOS 16+ but I had a hard time finding a way to import it into an iOS project.
I finally managed to do that using a bridging header file and iokit_linking.hpp. Why is it that hard to make it work on iOS? Is it okay to do it this way?
If I use any IOKit methods and/or properties in my app will I be able to submit it to the App Store?
Thanks.
The simple test case is this:
@max[git:master]$ /usr/bin/ssh max ls /Volumes
Macintosh HD
TM2
me
me9
@max[git:master]$
and
@max[git:master]$ /usr/bin/ssh max /bin/bash -c "ls /Volumes"
Applications
Calibre Library
Desktop
...
The latter is NOT doing an ls of /Volumes/ but of my $HOME directory.
This is a recent change. I've had a script that is > 10 years old that just started failing.
Here's another look:
@max[git:master]$ /usr/bin/ssh max /bin/bash -c "cd /Volumes && pwd"
/Users/layer
@max[git:master]$ echo $?
0
@max[git:master]$
It's weird that it just silently ignores the cd.
This is on
ProductVersion: 15.3
BuildVersion: 24D60
Hello everyone.
After a lot of research and some tests from various sources, I have actually built a small SerialDriverKit IOUserSerial driver. Unfortunately, the documentation on the official sites is tight-lipped and very thin. At least I have a running driver instance. Now my request and question: Can anyone give me a tip on how to get the data from the serial client? I have already called IOUserSerial::ConnectQueues(...) in the IOUserSerial::Start() method and I got the IOMemoryDescriptors for interrupt, RX and TX to my driver instance. I tried to get access to the memory in the method IOUserSerial::TxDataAvailable() with IOMemoryDescriptor::CreateMapping(...).
Unfortunately, no data is coming in. It's always 0x00. Here is the OS log:
kernel: (org.eof.tools.VSPDriver.dext)
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriver] init called.
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] constructor called.
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriver] start called.
kernel: (org.eof.tools.VSPDriver.dext) IOUserSerial::: 40 0x600000da4058
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] Start called.
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] Connect INT/RX/TX buffer.
kernel: (org.eof.tools.VSPDriver.dext) IOUserSerial::: 59 0x600000da4058
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] prepare TCP socket.
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriver] driver started successfully.
kernel: DK: VSPDriver-0x100000753::start(IOUserResources-0x100000116) ok
...
... some client serial setup stuff
...
kernel: (IOUserSerial) IOUserSerial::hwResetFIFO: 1076 ==>0
kernel: (IOUserSerial) IOUserSerial::hwResetFIFO: 1076 <==
kernel: (IOUserSerial) IOUserSerial::hwResetFIFO: 1076 locklevel = 1
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriver] HwResetFIFO called.
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] HwResetFIFO called.
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] HwResetFIFO: tx=0 rx=1
kernel: (IOUserSerial) IOUserSerial::hwResetFIFO: 1076 ==>0
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriver] TxDataAvailable called.
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable called.
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: address=0x104c22000 length=16384
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: debug TX buffer
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
kernel: (org.eof.tools.VSPDriver.dext) [VSPDriverPrivate] TxDataAvailable: TX> 0x00
There doesn't seem to be a background mode that will allow an iPhone app to run in the background in order to communicate with its watch app, which is running in the foreground on the watch. Have I missed something?
Related but not quite the same: say the iPhone app can run in the background to get location updates. But it only wants to do so when the watch app is running. Is there a way that the watch app can wake, or even start, the iPhone app, and for the iPhone app to then enable location updates?
(I have previously implemented Bluetooth background modes - I think I could achieve both of the above if I had the watch and the iPhone communicate using my own BTLE protocol, rather than using Watch Connectivity. Is this true?)
Hi Team,
We recently conducted a BLE throughput test by sending 2MB of data from the peripheral to the central on both Android and iOS devices. We observed significantly lower throughput on iOS compared to Android. We would appreciate any suggestions or best practices to improve BLE throughput on iOS.
Observations and Potential Bottlenecks:
Number of Packets per Connection Event: On all iPhone models tested, the average number of packets per connection event is only 5, regardless of the device model. Is this a limitation of iOS? Can this be adjusted at the application level?
Connection Interval Configuration: Our peripheral requests a lower connection interval (7.5ms) using the "Connection Parameter Update Request" packet, but iOS does not honor it.
Is there a way to configure or request a specific connection interval on iOS?
What factors influence iOS’s decision to accept or reject the requested connection interval?
Here are our stats done on different phones:
Notes:
Throughput Formula: Throughput = (1000ms * number of packets * packet size) / Connection interval (ms)
Both Central and Peripheral support BLE version 5.X.
Low power mode on iOS is disabled.
The application was in the foreground during the test on iOS.
Packet size after headers: 242 bytes.
Are there other factors or iOS configurations that might impact BLE throughput?
We would appreciate any insights or recommendations to improve throughput on iOS devices.
Hi all, I'm trying to write a little utility app that can detect when my bluetooth mouse is connected and turn natural scrolling off. I started by creating a Swift Package with swift package init --type excecutable and then wrote the following code in main.swift:
import CoreHID
let manager = HIDDeviceManager()
let notifications = await manager.monitorNotifications(
matchingCriteria: [.init(primaryUsage: .genericDesktop(.mouse))]
)
for try await notification in notifications {
switch notification {
case .deviceMatched(let device):
print("Matched:", device.deviceID)
let client = HIDDeviceClient(deviceReference: device)
print(await client?.manufacturer ?? "Unknown")
case .deviceRemoved(let device):
print("Removed:", device.description)
let client = HIDDeviceClient(deviceReference: device)
print(await client?.manufacturer ?? "Unknown")
@unknown default:
print("Unknown: \(notification)")
}
}
This program successfully detects my bluetooth mouse and correctly prints "Logitech", but when it gets to a second device, it crashes with the error message I put in the title: EXC_BREAKPOINT (code=1, subcode=0x1f9e0e13c).
If I run the program without my bluetooth mouse connected, it just crashes immediately so I can only assume this second device is the trackpad.
I added some log statements in addition to the prints so I could check unified logging in Console but nothing really stood out. No code signing errors, no permission denials, nada.
My environment:
MacBook Air 13-inch, M3, 2024
MacOS 15.1 (24B83)
Xcode Version 16.0 (16A242d)
swift-tools-version: 6.0
$ swift --version
swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx15.0
Has anyone seen this before or have ideas on how to investigate further?
Hello.
In my app, I need to implement the following mechanism: I need to collect data from nearby Bluetooth devices, process them, and send this information to the server at short intervals, including when the app is minimized. Is this possible on iOS?
BGProcessingTask has restrictions related to battery saving policies and does not guarantee task execution at specific intervals. Additionally, there is a limitation on background task execution, which can occur no more frequently than every 15 minutes.
However, some apps, such as Google Maps, work in the background and update geolocation data. Could you suggest a solution for this task?
Thanks for any help on this topic
How to encrypt bytes with CCM method in KMP?
Hello everyone,
I am currently working on a project for the health sector.
Basically we have some Bluetooth low energy devices that have a button.
When this button is pressed (usually for emergency situation), this event should alert our backend and therefore send help.
Is it technically possible to do this on IOS?
I am aware that apple have very strict restrictions in relation to background services, and after doing some research I found that it's impossible to run any custom code if the app is terminated by the user.
Is there a way to make a request for such special cases so that apple allows us to actually launch the app (or if not possible send a http request) when this beacon button is pressed (Of course with the bluetooth device already connected to the Iphone) even if the app is completely terminated.
Thanks :)
It seems apps will never truly be suspended when debugging.
Is this true? Is there ANY way to accurately test apps that need to go through full suspended + wakeup states while connected to XCode debugger?
Hi,
I'm developing a multi-platform project in Windows, Mac and Linux. I am trying to create a wrapper class in Go that will query system information and history.
I see that the Unified Logging System is a sophisticated way to get all sorts of kernel information (and even a long history including rotated logs). However, I am struggling to see how I can use the APIs in other languages aside from Swift itself (or C). I do not want to use the log or last commands to query information in separate child processes in my project. I would like to simply query the database itself, similar to using OSLog in Swift.
If this is something that is entirely proprietary or not possible, let me know :)
I'm trying to persist a bookmark to an external device (mass storage controller connected via camera adapter) across disconnection / reconnection, but it is failing at startAccessingSecurityScopedResource.
The URL is initially retrieved using
UIDocumentPickerViewController *documentProvider;
documentProvider = [[UIDocumentPickerViewController alloc] initForOpeningContentTypes:[NSArray arrayWithObjects:UTTypeFolder, nil]];
documentProvider.delegate = self;
documentProvider.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:documentProvider animated:YES completion:nil];
and then persisted to a bookmark using
DeviceBookmark = [url bookmarkDataWithOptions:NSURLBookmarkCreationMinimalBookmark includingResourceValuesForKeys:nil relativeToURL:nil error:nil]
When accessing the resource I use
NSURL *url = [NSURL URLByResolvingBookmarkData:DeviceBookmark options:NSURLBookmarkResolutionWithoutUI relativeToURL:nil bookmarkDataIsStale:&isStale error:&error]
to retrieve the new URL.
If I don't remove the MSC then the retrieved URL remains the same and functions as expected. If I remove and reconnect the MSC then the URL changes, I get true for isStale and nil for error but startAccessingSecurityScopedResource fails.
I've been banging my head against this for about a day now, but can't see what the issue can be. I've tried adding some related permissions to the entitlements, but this seems to be macOS related as far as I can tell.
What am I missing?!