I'm working on a build system similar to Bazel where each build action runs in a sandbox. The sandbox contains only the files that the user defined as input to ensure that the build action doesn't have any implicit dependencies. Bazel achieves this by creating a "symlink forest" to the original source files. This works, but I have observed fseventsd using significant CPU during a Bazel build, presumably because of all the symlinks that get created.
Is there a way to disable file events for a directory or a volume? The "File System Events Programming Guide" in the Documentation Archive mentions placing an empty file named no_log in the .fseventsd directory at the root of the volume, but when testing on macOS 15.5 with APFS that appears to no longer work.
Related, is a "symlink forest" the best way to create a sandbox like this? Or is there a different method one can use to provide a view of a subset of the files in a directory tree? I read up on the App Sandbox but that seems too coarse grained. Something like Linux's overlayfs would work well, and maybe one can achieve a similar functionality with firmlinks? Curious about folks thoughts here.
Thanks in advance!
Files and Storage
RSS for tagAsk questions about file systems and block storage.
Posts under Files and Storage tag
200 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
The URL directory obtained by UIDocumentPickerVieweController can be read and written in the directory after calling startAccessingDecurityScopeResource. However, after restarting the app, if the URL saved in the package is called startAccessingDecurityScopeResource again and returns NO, UIDocumentPickerVieweController must be called again to retrieve the URL, and then startAccessingDecurityScopeResource must be called again before continuing the operation. This is too troublesome. Is there a way to continue reading and writing operations in the URL directory after restarting the app?
Hi all,
I have repeatedly the issue that a certain .strings file in my app's bundle has the extended files attribute com.apple.quarantine set. Consequently the submission fails with the following mail notification:
We noticed one or more issues with a recent delivery for the following app:
[...]
ITMS-91109: Invalid package contents - The package contains one or more files with the com.apple.quarantine extended file attribute, such as “abcdef.strings”. This attribute isn’t permitted in macOS apps distributed on TestFlight or the App Store. Please remove the attribute from all files within your app and upload again.
I'm able to resubmit the bundle after cleaning the file attribute via xattr -d -r com.apple.quarantine..., but the funny thing is it happens again and again - on a .strings file which hasn't been downloaded (but manually created), shouldn't be under Gatekeeper's quarantine, and wasn't edited in the meantime.
Is anybody else observing the same issue with macOS 15.4.1, Xcode 16.3?
Greetings, Matthias
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
Files and Storage
Localization
Will the ES_EVENT_TYPE_NOTIFY_OPEN event be called back when the user has already returned es_respond_flags_result(client, msg, 0, false) in ES_EVENT_TYPE_AUTH_OPEN?
I believe the ES_EVENT_TYPE_NOTIFY_OPEN event should not be triggered if the user has already denied the open operation in the ES_EVENT_TYPE_AUTH_OPEN response handler. However, during my testing, ES_EVENT_TYPE_NOTIFY_OPEN was still being called even after I blocked the open process. Is this behavior correct?
Hello everyone,
I’m working on an iOS app that uses the new DeviceActivity framework to monitor and report user screen‐time in an extension (DeviceActivityReportExtension). I need to persist my processed screen‐time data into a standalone SQLite database inside the extension, but I’m running into issues opening and writing to the database file.
Here’s what I’ve tried so far:
import UIKit
import DeviceActivity
import SQLite3
class DeviceActivityReportExtension: DeviceActivityReportExtension {
private var db: OpaquePointer?
override func didReceive(_ report: DeviceActivityReport) async {
// 1. Construct path in app container:
let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.mycompany.myapp")
let dbURL = containerURL?.appendingPathComponent("ScreenTimeReports.db")
// 2. Open database:
if sqlite3_open(dbURL?.path, &db) != SQLITE_OK {
print("❌ Unable to open database at \(dbURL?.path ?? "unknown path")")
return
}
defer { sqlite3_close(db) }
// 3. Create table if needed:
let createSQL = """
CREATE TABLE IF NOT EXISTS reports (
id INTEGER PRIMARY KEY AUTOINCREMENT,
date TEXT,
totalScreenTime DOUBLE
);
"""
if sqlite3_exec(db, createSQL, nil, nil, nil) != SQLITE_OK {
print("❌ Could not create table: \(String(cString: sqlite3_errmsg(db)))")
return
}
// 4. Insert data:
let insertSQL = "INSERT INTO reports (date, totalScreenTime) VALUES (?, ?);"
var stmt: OpaquePointer?
if sqlite3_prepare_v2(db, insertSQL, -1, &stmt, nil) == SQLITE_OK {
sqlite3_bind_text(stmt, 1, report.date.description, -1, nil)
sqlite3_bind_double(stmt, 2, report.totalActivityDuration)
if sqlite3_step(stmt) != SQLITE_DONE {
print("❌ Insert failed: \(String(cString: sqlite3_errmsg(db)))")
}
}
sqlite3_finalize(stmt)
}
}
However:
Path issues: The extension’s sandbox is separate from the app’s. I’m not sure if I can use the same App Group container, or if there’s a better location for an on‐extension database.
Entitlements: I’ve added the App Group (group.com.mycompany.myapp) to both the main app and the extension, but the file never appears, and I still get “unable to open database” errors.
My questions are:
How do I correctly construct a file URL for an SQLite file in a DeviceActivityReportExtension?
Is SQLite the recommended approach here, or is there a more “Apple-approved” pattern for writing data from a DeviceActivity extension?
Any sample code snippets, pointers to relevant Apple documentation, or alternative approaches would be greatly appreciated!
We have a launch daemon which can check for team identifier and some other signing information of any application on machine and match it with provided information to confirm the validity of the application/binary. We use SecStaticCodeCreateWithPath to read the signing information of the app/binary which works in most cases.
However, for some third party daemon processes, the static code creation fails with error "Operation not permitted". We are having difficult time identifying why static code creation would fail specially when our process is running with root privileges.
Can you please help us understand in what scenario can this API fail with this error? Can there be any process or rule which can deny creating static code of a process like endpoint security extensions/daemon?
We are using default flags in SecStaticCodeCreateWithPath.
Recently, some feedback has been received. After users upgrade to ipados 17.7.7 and return to the login status and restart the App, it will become invalid. We checked the log and found that the content stored in NSUserdefault would be lost after restarting the App. Has anyone encountered this problem?
Hello,
I am working on a daemon which collects information about disk space usage on macOS.
APFS has quite complex structure and there is a challenge to get detailed info.
My application must provide disk usage by APFS containers.
Are there any recommended way to get space usage by particular APFS volume?
Are there any recommended way to get free space on particular APFS container?
Are there any recommended way to enumerate APFS containers and volumes?
I am using Disk Arbitration to get APFS info. However, I get restricted info about space usage because I get get disk usage for mounted volumes only.
Are there any public API (daemon-safe) which allows to easily get disk space usage on macOS?
Thank you in advance,
Pavel
How do I gain access to the Documents folder? Under targets, "signing and capabilities", App Sandbox, I can see the Music folder, Desktop... but not Documents.
I found the live activity process cannot write to the app group and FileManger, can only read the app group.
When I write using FileManager in a live activity process, the console prompts me with a permission error.
When I write using UserDefault(suit:) in the live activity process, I read a null value in the main app.
Is this the case for real-time event design? I haven’t seen any documentation mentioning this.
Does anyone know, thank you very much.
Hi All,
I am looking for a terminal command to get the exact same output as the file count you recieve when using Get Info in finder.
The closest i can get is using the find command with flags:
find 'path/to/folder' -not -path '*/\.*' -and -not -path '*\.key/*' -and -not -path '*\.numbers/*' -and -not -path '*\.pages/*' -and -not -path '*__MACOSX/*' -and -not -path '*\.pdf/*' -and -not -path '*\.app/*' -and -not -path '*\.rtfd/*' | wc -l
I will be searching on an external volume that sometimes produces keynote save files that finder sometimes sees as a package and sometimes sees as a folder. If a folder finder counts the items contained if a package it doesn't, I need the command or script to mimic this behaviour.
In the example of the screenshot get info on the top folder produces a count of 14 and the find command produces a count of 23.
There are also other behaviours that differ the file count between them but i'm not sure what causes them.
Any help on a solution it being a command or script would be much apreciated.
Thanks,
James
Testing Environment: iOS 18.4.1 / macOS 15.4.1
I am working on an iOS project that aims to utilize the user's iCloud Drive documents directory to save a specific directory-based file structure. Essentially, the app would create a root directory where the user chooses in iCloud Drive, then it would populate user generated files in various levels of nested directories.
I have been attempting to use NSMetadataQuery with various predicates and search scopes but haven't been able to get it to directly monitor changes to files or directories that are not in the root directory.
Instead, it only monitors files or directories in the root directory, and any changes in a subdirectory are considered an update to the direct children of the root directory.
Example
iCloud Drive Documents (Not app's ubiquity container)
User Created Root Directory (Being monitored)
File A
Directory A
File B
An insertion or deletion within Directory A would only return a notification with userInfo containing data for NSMetadataQueryUpdateChangedItemsKey relating to Directory A, and not the file or directory itself that was inserted or deleted. (Query results array also only contain the direct children.)
I have tried all combinations of these search scopes and predicates with no luck:
query.searchScopes = [
rootDirectoryURL,
NSMetadataQueryUbiquitousDocumentsScope,
NSMetadataQueryAccessibleUbiquitousExternalDocumentsScope,
]
NSPredicate(value: true)
NSPredicate(format: "%K LIKE '*.md'", NSMetadataItemFSNameKey)
NSPredicate(format: "%K BEGINSWITH %@", NSMetadataItemPathKey, url.path(percentEncoded: false))
I do see these warnings in the console upon starting my query:
[CRIT] UNREACHABLE: failed to get container URL for com.apple.CloudDocs
[ERROR] couldn't fetch remote operation IDs: NSError: Cocoa 257 "The file couldn’t be opened because you don’t have permission to view it."
"Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)""
But I am not sure what to make of that, since it does act normally for finding updates in the root directory.
Hopefully this isn't a limitation of the API, as the only alternative I could think of would be to have multiple queries running for each nested directory that I needed updates for.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
Files and Storage
iCloud Drive
Foundation
Hello,
I am trying to get space which is consumed by APFS volume. The call getattrlist() works fine on macOS 15 (Apple silicon). However, it returns EINVAL on macOS 11.7.10 (Intel) if ATTR_VOL_SPACEUSED is defined.
struct VolAttrBuf
{
u_int32_t length;
off_t spaceUsed;
} __attribute__((aligned(4), packed));
int64_t GetVolumeSpaceUsed(const std::string& mountPath)
{
struct attrlist attrList;
std::memset(&attrList, 0, sizeof(attrList));
attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
attrList.volattr = ATTR_VOL_INFO | ATTR_VOL_SPACEUSED;
VolAttrBuf attrBuf;
if (getattrlist(mountPath.c_str(), &attrList, &attrBuf, sizeof(attrBuf), 0) ||
attrBuf.length > sizeof(attrBuf))
{
std::cout << "getattrlist() failed with errno (" << errno << ")" << std::endl;
return -1;
}
return attrBuf.spaceUsed;
}
Is it bug or ATTR_VOL_SPACEUSED is unsupported on macOS 11?
Are there any other way to get space which is used on an APFS volume? (C++)
Thank you in advance,
Pavel
As of 2025-05-03, when a macOS user enables iCloud Drive synchronization for Desktop & Documents in US region, does iCloud filter xattrs upon upload or later when downloading back to another macOS host? Or is it the case that iCloud has no filtering of third-party xattrs? Where can I find the technical document outlining exactly what iCloud does with xattrs set on macOS host files and folders synchronized with iCloud Drive?
After uploading the app archive generated by Xcode (which passed validation), I received an email stating one or more files had the com.apple.quarantine extended file attribute and to remove the attribute before uploading the archive again. A particular PNG file was identified.
In the terminal, I ran the command:
xattr -d com.apple.quarantine
The response was: "No such xattr: com.apple.quarantine"
I also ran "xattr -rd" on the directory containing all app files. No response.
The identifed PNG file at fault is a screenshot used only in the app's User Guide. It was created 5 years ago using Apple software: Ctrl-Shift-4 to capture the image, Preview to resize.
Given the file does not have the quarantine extended attribute, I can only conclude that Xcode is adding the attribute when building the archive. How do I stop Xcode from adding the attribute?
I have search Google with numerous search criteria and check the Apple Developer Forum, but could only find how to remove the attribute using xattr; nothing about Xcode adding the attribute when building an archive.
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
Organizer Window
Files and Storage
Until a few days ago, I had a bit of code that could download a file from elsewhere to my home drive, "Users/eric".
Today, the code downloads the file to "locat", but the following no longer works
let _ = try fileManager.copyItem(atPath: locat, toPath: "/Users/eric/file.txt" )
After a careful search, I've changed the network to allow Network connections, and set User Selected and Downloads Folder to Read/Write without any luck.
I am using Catalina and SwiftUI on a recent Mac (2023). As well, it was working just a few days ago. Any ideas or pointers?
Topic:
App & System Services
SubTopic:
Core OS
Tags:
Swift Packages
SwiftUI
Files and Storage
App Sandbox
I'm an iOS developer, and I've been testing our app in iOS 18.0 Beta. I noticed that there's a problem with the font rendering, and after troubleshooting, I've found out that it's caused by the removal of the PingFang.ttc font in 18.0.
I would like to ask the reason for removing this font file and which font should be used to display Chinese in the future?
My test device is an iPhone 11 Pro and the system version is iOS 18.0 (22A5297). I have also tested Beta 1 and it has the same issue.
In previous versions of the system, the PingFang font is located in this directory /System/Library/Fonts/LanguageSupport/PingFang.ttc. But in iOS 18.0, the font file in this directory has become Kohinoor.ttc, and I've tested that this font can't display Chinese either.
I traversed the following system font directories and could not find the PingFang.ttc font file.
/System/Library/Fonts/AppFonts
/System/Library/Fonts/Core
/System/Library/Fonts/CoreAddition
/System/Library/Fonts/CoreUI
/System/Library/Fonts/LanguageSupport
/System/Library/Fonts/UnicodeSupport
/System/Library/Fonts/Watch
Looking for answers, thanks for the help!
I‘m getting tired of having to reinstall apps because of the amount of datas. I deleted alot of photos. Deleted apps. The thing that gets my storage full is the System data. I searched up for tutorials, it was full with clearing safari history or deleting old messages, offloading apps. I did them all, none of them decreased my system data and its at 12GB while my phone‘s GB is only up to 64GB. I use IOS 16 Iphone 11. Can someone help?
This is with SDL2 and C++
Due to the new security design of Sequoia involving the sandboxed helper processes (via ViewBridge) to show open/save panels, my existing code for invoking Open/SaveAs/FolderSelect dialogs no longer works and instead terminates with ViewBridge Code=14 "(null)" error.
Even in the simplest of forms such as;
nfdresult_t NFD_OpenDialogN_With_Impl(nfdversion_t version,
nfdnchar_t** outPath,
const nfdopendialognargs_t* args) {
nfdresult_t result = NFD_CANCEL;
NSOpenPanel* dialog = [NSOpenPanel openPanel];
if ([dialog runModal] == NSModalResponseOK) {
result = NFD_OKAY;
}
return result;
}
...Will no longer work.
My Question is essentially, how can I resolve this NSUserDefaults domain empty/nil issue ( currently I don't pass anything for sharing defaults during the process ).
Dump of fault provided in crash.txt ( the program doesn't actually crash, it just doesn't invoke the file-open dialog )
crash.txt
A filesystem of my own making exibits the following undesirable behaviour.
ClientA
% echo line1 >>echo.txt
% od -Ax -ctx1 echo.txt
0000000 l i n e 1 \n
6c 69 6e 65 31 0a
0000006
ClientB
% od -Ax -ctx1 echo.txt
0000000 l i n e 1 \n
6c 69 6e 65 31 0a
0000006
% echo line2 >>echo.txt
% od -Ax -ctx1 echo.txt
0000000 l i n e 1 \n l i n e 2 \n
6c 69 6e 65 31 0a 6c 69 6e 65 32 0a
000000c
ClientA
% od -Ax -ctx1 echo.txt
0000000 l i n e 1 \n l i n e 2 \n
6c 69 6e 65 31 0a 6c 69 6e 65 32 0a
000000c
% echo line3 >>echo.txt
ClientB
% echo line4 >>echo.txt
ClientA
% echo line5 >>echo.txt
ClientB
% od -Ax -ctx1 echo.txt
0000000 l i n e 1 \n l i n e 2 \n l i n e
6c 69 6e 65 31 0a 6c 69 6e 65 32 0a 6c 69 6e 65
0000010 3 \n l i n e 4 \n \0 \0 \0 \0 \0 \0
33 0a 6c 69 6e 65 34 0a 00 00 00 00 00 00
000001e
ClientA
% od -Ax -ctx1 echo.txt
0000000 l i n e 1 \n l i n e 2 \n l i n e
6c 69 6e 65 31 0a 6c 69 6e 65 32 0a 6c 69 6e 65
0000010 3 \n \0 \0 \0 \0 \0 \0 l i n e 5 \n
33 0a 00 00 00 00 00 00 6c 69 6e 65 35 0a
000001e
ClientB
% od -Ax -ctx1 echo.txt
0000000 l i n e 1 \n l i n e 2 \n l i n e
6c 69 6e 65 31 0a 6c 69 6e 65 32 0a 6c 69 6e 65
0000010 3 \n \0 \0 \0 \0 \0 \0 l i n e 5 \n
33 0a 00 00 00 00 00 00 6c 69 6e 65 35 0a
000001e
The first write on clientA is done via the following call chain:
vnop_write()->vnop_close()->cluster_push_err()->vnop_blockmap()->vnop_strategy()
The first write on clientB first does a read, which is expected:
vnop_write()->cluster_write()->vnop_blockmap()->vnop_strategy()->myfs_read()
Followed by a write:
vnop_write()->vnop_close()->cluster_push_err()->vnop_blockmap()->vnop_strategy()
The final write on clientA calls cluster_write(), which doesn't do that initial read before doing a write.
I believe it is this write that introduces the hole.
What I don't understand is why this happens and how this may be prevented.
Any pointers on how to combat this would be much appreciated.