Files and Storage

RSS for tag

Ask questions about file systems and block storage.

Pinned Posts

Posts under Files and Storage tag

209 Posts
Sort by:
Post not yet marked as solved
4 Replies
877 Views
I have a question about the file system of macOS and iOS. I tried to play an audio from the local download folder. But I failed because my application seems not to have the permission to read it. I get the error Error Domain=NSOSStatusErrorDomain Code=-54 "permErr: permissions error (on file open)". So I think it's something different from other systems like Windows. How are these permissions handled and how can I get the permission to read a file? I read something about Sandboxing but my app doesn't even start when I turn on "App Sandbox" in the settings.
Posted
by
Post not yet marked as solved
3 Replies
636 Views
Hello, I need to get all files (recursively) from an iCloud Drive folder. So I use UIDocumentPickerController with UTType.folder. Then I use FileManager to get all files from the picked folder, but when I try to access it with startAccessingSecurityScopedResource it return false. It's work perfectly if I dont get files by FileManager but directly by the UIDocumentPickerController when configured for multiple files selection. How can I access to all files from a picked directory with permission granted ? Is it at least possible ? Thanks
Posted
by
JHW
Post not yet marked as solved
1 Replies
297 Views
Which one is the best between Xcode 14.3 and Xcode 15 Beta. As I have the two on my laptop and my laptop is out of storage, which make it run slowly, I don't know which one to uninstall and the one to spare. Your advice will be really appreciated.
Posted
by
Post not yet marked as solved
0 Replies
380 Views
I'm working with NSFileProviderReplicatedExtension for macOS app. I want to apply default badge on files(For example, com.apple.icon-decoration.badge.warning, com.apple.icon-decoration.badge.pinned, .. etc). I am unable to see any badge when I open the folder mounted by the Extension. I've defined NSFileProviderDecorations in NSExtension as follows : <dict> <key>NSFileProviderDecorations</key> <array> <dict> <key>BadgeImageType</key> <string>com.apple.icon-decoration.pinned</string> <key>Category</key> <string>Badge</string> <key>Identifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER).cyfile</string> <key>Label</key> <string>CydriveFile</string> </dict> </array> <key>NSExtensionFileProviderDocumentGroup</key> <string>$(TeamIdentifierPrefix)com.example.app-group</string> <key>NSExtensionFileProviderSupportsEnumeration</key> <true/> <key>NSExtensionPointIdentifier</key> <string>com.apple.fileprovider-nonui</string> <key>NSExtensionPrincipalClass</key> <string>$(PRODUCT_MODULE_NAME).FileProviderExtension</string> </dict> I have implemented the class Item that's implementing the following Protocols : NSObject, NSFileProviderItemProtocol, NSFileProviderItemDecorating and when returning decorations for that item I'm just doing this : class Item : ... { ... static let decorationPrefix = Bundle.main.bundleIdentifier! static let heartItem = NSFileProviderItemDecorationIdentifier(rawValue: "\(decorationPrefix).cyfile") var decorations: [NSFileProviderItemDecorationIdentifier]? { var decos = [NSFileProviderItemDecorationIdentifier]() decos.append(CyItem.heartItem) return decos } } As far as i can tell I've completed all the requirements for getting the badge to show up.
Posted
by
Post not yet marked as solved
1 Replies
489 Views
I have an application running in the sandbox which launches an application bundle using NSTask. The main app entitlements enable sandbox add the User Selected File Read/Write permission. <dict> <key>com.apple.security.app-sandbox</key> <true/> <key>com.apple.security.files.user-selected.read-write</key> <true/> </dict> The child app entitlements enable sandbox and inherit. <dict> <key>com.apple.security.app-sandbox</key> <true/> <key>com.apple.security.inherit</key> <true/> </dict> When invoke NSSavePanel *savePanel = [NSSavePanel savePanel] in the child process, system will throw the error.The error message prompt that missing the User Selected File Read/Write permission. However, I have already added this permission in the main app, and I have set up the inherit in the child-process as well. The child process cannot add the User Selected File Read/Write permission again because it add sandbox and inherit in entitlements by the doc EnablingAppSandbox . It appears that the system is not inheriting this permission for the child process. panel[60195:2499353] [OpenSavePanels] Unable to display save panel: your app is missing the User Selected File Read/Write app sandbox entitlement. Please ensure that your app's target capabilities include the proper entitlements. And the error stack. [miscellany] CLIENT ERROR: remote view delegate NSSavePanel lacks method which can react to the details of Error Domain=com.apple.ViewBridge Code=14 "(null)" UserInfo={com.apple.ViewBridge.error.hint=-[NSViewServiceMarshal bootstrap:withReply:] caught NSInternalInconsistencyException '+[NSOpenAndSavePanelService loadViewToService:isOpenPanel:appCentric:] : failed entitlements check' with backtrace ( "0 CoreFoundation __exceptionPreprocess + 242", "1 libobjc.A.dylib objc_exception_throw + 48", "2 CoreFoundation -[NSException raise] + 9", "3 com.apple.appkit.xpc.openAndSavePan com.apple.appkit.xpc.openAndSavePan + 16852", "4 AppKit -[NSViewController _loadViewIfRequired] + 72", "5 AppKit __24-[NSViewController view]_block_invoke + 27", "6 AppKit NSPerformVisuallyAtomicChange + 132", "7 AppKit -[NSViewController view] + 123", "8 ViewBridge -[NSViewServiceMarshal _bootstrap:replyData:completion:] + 1826", "9 ViewBridge -[NSViewServiceMarshal bootstrap:withReply:] + 245", "10 CoreFoundation __invoking___ + 140", "11 CoreFoundation -[NSInvocation invoke] + 305", "12 CoreFoundation -[NSInvocation invokeWithTarget:] + 70", "13 ViewBridge -[NSVB_ViewServiceImplicitAnimationDecodingProxy forwardInvocation:] + 178", "14 CoreFoundation ___forwarding___ + 756", "15 CoreFoundation _CF_forwarding_prep_0 + 120", "16 CoreFoundation __invoking___ + 140", "17 CoreFoundation -[NSInvocation invoke] + 305", "18 CoreFoundation -[NSInvocation invokeWithTarget:] + 70", "19 ViewBridge -[NSVB_QueueingProxy forwardInvocation:] + 321", "20 CoreFoundation ___forwarding___ + 756", "21 CoreFoundation _CF_forwarding_prep_0 + 120", "22 CoreFoundation __invoking___ + 140", "23 CoreFoundation -[NSInvocation invoke] + 305", "24 CoreFoundation -[NSInvocation invokeWithTarget:] + 70", "25 CoreFoundation ___forwarding___ + 756", "26 CoreFoundation _CF_forwarding_prep_0 + 120", "27 CoreFoundation __invoking___ + 140", "28 CoreFoundation -[NSInvocation invoke] + 305", "29 ViewBridge __deferNSXPCInvocationOntoMainThread_block_invoke + 142", "30 ViewBridge __wrapBlockWithVoucher_block_invoke + 37", "31 ViewBridge kNotRunningOnAppKitCompatibleThread_block_invoke + 323", "32 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12", "33 CoreFoundation __CFRunLoopDoBlocks + 398", "34 CoreFoundation __CFRunLoopRun + 2015", "35 CoreFoundation CFRunLoopRunSpecific + 560", "36 HIToolbox RunCurrentEventLoopInMode + 292", "37 HIToolbox ReceiveNextEventCommon + 657", "38 HIToolbox _BlockUntilNextEventMatchingListInModeWithFilter + 64", "39 AppKit _DPSNextEvent + 858", "40 AppKit -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1214", "41 ViewBridge __77-[NSViewServiceApplication vbNextEventMatchingMask:untilDate:inMode:dequeue:]_block_invoke + 111", "42 ViewBridge -[NSViewServiceApplication _withToxicEventMonitorPerform:] + 114", "43 ViewBridge -[NSViewServiceApplication vbNextEventMatchingMask:untilDate:inMode:dequeue:] + 151", "44 ViewBridge -[NSViewServiceApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 99", "45 AppKit -[NSApplication run] + 586", "46 AppKit NSApplicationMain + 817", "47 libxpc.dylib _xpc_objc_main + 867", "48 libxpc.dylib xpc_main + 96", "49 ViewBridge xpc_connection_handler + 0", "50 ViewBridge NSViewServiceMain + 1789", "51 com.apple.appkit.xpc.openAndSavePan main + 178", "52 dyld start + 1903" ), com.apple.ViewBridge.error.description=NSViewBridgeErrorServiceBootstrap}
Posted
by
Post marked as solved
5 Replies
2.0k Views
Issue This issue is reproducible on iOS 17 beta 4 and iOS 17.0 (21A5303d) public beta. When try to create a folder using the FileManager API, the app crashes with the following stack trace. Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “Samples” in the folder “…”." UserInfo={NSURL=file://…/Samples.app/, NSUnderlyingError=0x28100cf00 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} What is the user impact? Users will not be able to run the app on iOS 17 Steps to Reproduce Create a new project Add the following code import SwiftUI struct ContentView: View { var body: some View { Text("Hello, world!") .onAppear { _ = makeTemporaryDirectory() } } /// Creates a temporary directory. private func makeTemporaryDirectory() -&gt; URL { try! FileManager.default.url( for: .itemReplacementDirectory, in: .userDomainMask, appropriateFor: Bundle.main.bundleURL, create: true ) } } Build and run the app. It crashes on the force try line. O/S: iOS 17 (Beta 4) / iOS 17.0 (21A5303d) Device: iPad Pro Gen 4, iPhone 11. Only happens on real device, not on the simulators
Posted
by
Post not yet marked as solved
1 Replies
559 Views
3D assets such as models, textures, animations, etc., can significantly inflate app bundle sizes. To mitigate this, loading these assets from a remote URL is the way to go. But how does someone load a ModelEntity from a hosted URL? The current method is to load a Model3D: let url = URL(string: "my-url")! Model3D(url: url) But this does not pack all the features of a ModelEntity which can be used in a RealityView. Such as anchoring, animations, advanced gestures, etc. How do I load a remote URL into a ModelEntity?
Posted
by
Post marked as solved
1 Replies
384 Views
Hello, in my app I need the current amount of free space on a certain volume. I use the following code to the this information: if let mountedVolumeURLs = FileManager.default.mountedVolumeURLs(includingResourceValuesForKeys: nil) { for volumeUrl in mountedVolumeURLs { guard let values = try? self.url.resourceValues(forKeys: [.volumeTotalCapacityKey, .volumeAvailableCapacityKey]) else { continue } let totalBytes = values.allValues[.volumeTotalCapacityKey] as? UInt64 ?? 0 let freeBytes = values.allValues[.volumeAvailableCapacityKey] as? UInt64 ?? 0 // This is not always correct. } } When writing to a volume and then calling the code above, a wrong amount is returned. I suspect that there is still some cacheing going on. Is there any function that I can call to get this information from the file system without any cacheing? I guess an alternative would be to get a list of all files, get their sizes, add them up and subtract that number from the total bytes of the volume. But maybe there is a more elegant solution. I also tried something like this: let handle = try FileDescriptor.open(volumeUrl.path, .writeOnly, options: .create, permissions: .ownerReadWrite, retryOnInterrupt: true) fcntl(handle.rawValue, F_FULLFSYNC) But this did not help. I would appreciate any help. Regards
Posted
by
Post not yet marked as solved
1 Replies
289 Views
There's a slightly tweaked FAT16 implementation used on some Akai samplers. I've created an emulator of one of those samplers. It supports USB volume i/o with a custom FAT16 implementation. All of this works, but currently goes via the deprecated AuthorizationExecuteWithPrivileges for achieving raw USB volume access. The mechanism I specifically rely on currently is to, with elevated privileges, change the ownership of /dev/diskN, and then with normal privileges I can open a file handle against that disk device. Yesterday I looked into migrating to SMJobBless, but it also turns out to be deprecated. Does any of the macOS SDKs support my use case? Should I look into writing a DriverKit or IOKit driver? Any tips or guidance would be appreciated. Ideally I can implement a flow where the user is only required to approve with admin privileges once and after that has raw block device access to a restricted set connected volumes -- FAT16/ms-dos volumes that have a special volume label, or a special flag set in the boot sector.
Posted
by
Post not yet marked as solved
0 Replies
299 Views
Is it possible to indirectly delete data stored in the stock iOS "File" app from any external app (without opening the File app)? As reference information, we have confirmed that when data is deleted from a third-party file app (e.g. Readdle's documents(https://readdle.com/ja/documents) the data is also deleted from the genuine iOS file app.
Posted
by
Post not yet marked as solved
1 Replies
705 Views
Hello, I have an app in the App Store that is your typical cleaner app. The app searches for files from deleted apps and can remove them. Under macOS Sonoma the app does no longer work. When deleting files, the following message appears in the Console: System Policy: App(1636) deny(1) file-write-unlink The app has scoped bookmarks for the folder and additionally I added Full Disk Access for my app - it still does not work? Is there another layer on top of that? The app works perfectly fine on Big Sur, Monterey and Ventura. Regards, Sascha
Posted
by
Post not yet marked as solved
1 Replies
840 Views
An iOS app running in simulator has complete access to the Mac's file system: // Files in protected directory like Desktop, Documents, Calendar, etc will need additional permissions. let filesInSystem = FileManager.default.enumerator(at: .currentDirectory(), includingPropertiesForKeys: nil)?.allObjects This isn't the case when running in device as the app is sandboxed. Is the same possible when running in simulator? More specifically, is there a way to restrict access to the Mac's file system when running an app in the Simulator? This is particularly useful when trying out binaries/frameworks that are not open sourced.
Posted
by
Post marked as solved
3 Replies
756 Views
I'm using this build script: https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/customizing_the_notarization_workflow/customizing_the_xcode_archive_process?language=objc To create and notarize a dmg. In Xcode 15 it fails when calling /usr/bin/hdiutil create .... The fail error message is: could not access /Volumes/Bike/Bike.app - Operation not permittedhdiutil: create failed - Operation not permitted I have found that I can work around the problem by giving Xcode 15 full disk access. Is there a way that I can make my script run without having to give Xcode full disk access?
Posted
by
Post not yet marked as solved
1 Replies
514 Views
My goal is to try and get a unified logging system set up where logging from an iOS app and its extensions (primarily a notification service extension) get written into one central repository. So I was planning on setting up CocoaLumberjack in the app and the extension to use the same file path/name, adding the group capability to the app and the extensions and specifying the shared group directory as the file path. By default, for an app, CocoaLumberjack writes its files to: var/mobile/Containers/Data/Application/05464D4A-20F6-4E1F-9DBC-3109C053A1E8/Library/Caches/Logs/ On a Mac using an application such as iExplorer the above file and be located and viewed and copied etc. For an extension, it writes them to: /var/mobile/Containers/Data/PluginKitPlugin/5542F5EA-EB3A-4728-B33E-4E57C1B7B3B4/Library/Caches/Logs/ Now if I configure Cocoalumberjack to instead write the logger file to the shared group directory, then that will be at: /private/var/mobile/Containers/Shared/AppGroup/6CD5AF2C-54C9-46EF-B831-997B1DD6664F/ However its not possible using iExplorer to access this location. Using a Mac connected to the iPhone, is there an app or tool etc., that will enable me to locate the log file if it's created in the above AppGroup location?
Posted
by
Post not yet marked as solved
16 Replies
3k Views
Hi guys, has anyone seen this issue? When installing an application, which requires Full Disk Access (kTCCServiceSystemPolicyAllFiles), user enables this feature, but after reboot, OS automatically turns it off. Filed feedback in case it's a new issue. Any idea how to fix it? Any workaround to keep Full Disk Access enabled? Thanks.
Posted
by
Post not yet marked as solved
0 Replies
298 Views
I'm trying to use autofs to mount some macFUSE filesystems. However, autofs requires custom filesystems to provide /sbin/mount_* and this directory is not writable nor modifiable via synthentic.conf Using a launch agent or daemon is not desirable as there is a non-blocking delay before the filesystem gets mounted which causes a race condition. Is there any other option to let diskarbitrationd or autofs to automatically mount a macFUSE filesystem?
Posted
by
Post marked as Apple Recommended
4.4k Views
Since updating to iOS 17 there doesn't seem to be a way to automatically open files AirDropped into any applications. The files get downloaded to the Files application and you can open them from there, but previously you could open them straight in another application. There doesn't seem to be any documentation to this change. Is there still a way to open AirDropped files directly in a non-Apple published application?
Posted
by