Files and Storage

RSS for tag

Ask questions about file systems and block storage.

Posts under Files and Storage tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

APIs available or ways in which I can browse and read files from below mentioned sources?
Hi, so, what I'm looking to do is to provide a browsing screen for the below in my app i.e., construct the browsing UI for it and then when user selects a file here, I want to be able to open and read from it, example the 'on my iphone; tab in files has a specific path to it, if I use this to get folder structure and construct my own way of how the browse ui is supposed to look like. The storages/browsing options I want to show are, Local Storage: The folders shown when we go to the 'On my iPhone' tab in the Files app. Remote Storages like, Network Shared Folder/drive: Similar to the connect to server option that is shown in the Files app, and in files app on selecting files I get a path that I can work with, but I also wanted to know how this mount happens i.e., if file gets downloaded and changes synced or folder is actually mounted on file system. Cloud Storage: Like amazon s3, etc, can I provide a way to connect to these inapp and browse them and what would I get as path when I select a file. or can I show this option as locations in my app similar to the way it is shown in Files app. Sync Folders: Like onedrive, etc. Same as above can I have them in app or show them as locations Wireless Storage: Is there a way to detect a bluetooth storage being connected here, and how do I display the browse ui for it with my app? Removable Storage: Similarly, can I detect if a pendrive was connected to iPhone and show the browsing ui for it? what would the path look like FTP and http links: how to browse the former and stream data from the latter. Please let me know if you have any inputs on which is possible and how. Thanks in advance
5
0
369
Oct ’23
iOS 17 Airdropped file not opening in our app and instead opening in files app
Our application is configured to handle a custom file type with the extension .ptw. Until the release of iOS 17, when we used Airdrop to send a .ptw file, it would seamlessly open directly in our app on the receiving device. However, since iOS 17, we've noticed a change in behavior where the .ptw file is now being automatically saved to the Files app. To access it in our app, we must manually tap the share button and select our app from the sharing menu. I'm curious to know if others have experienced this change as well, and whether this is the expected behavior in iOS 17 or We are missing some configurations to regain the previous behaviour. If anyone has any insights, workarounds, or suggestions regarding this issue, please share them here.
2
1
1.1k
Oct ’23
fileManager.copyItem with overwrite?
I'm would like to make a copy of a folder with files and folders in it before I do anything to them. When I naively fileManager.copyItem() I get errors about .DS_Store files already existing (I think the Finder might be creating them before the copy gets to it). The destination directory is empty at the start of the process. Is there any way to tell copyItem to overwrite? Is replaceItemAt() a way to do this, with backupItemName set to the original name and withoutDeletingBackupItem set in options? That seems so convoluted. Is there a better way?
5
0
956
Oct ’23
How do we delete our apps "Data & Documents" when developing on Unreal Engine for iOS?
We published an app for iOS which accidentally stores a ton of photos in "Data & Documents". The app is live on the App Store, but currently the only way for a user to delete this bloat is to uninstall and re-install the app. Updating does not delete it. We fixed the bug, and put in a notice on the App Store page, but we'd rather take care of this on our end. The app was developed using Unreal Engine 5.1.1. The bloat is caused by Apple ARKit having had the should_write_camera_image_per_frame turned on (see https://docs.unrealengine.com/5.0/en-US/PythonAPI/class/AppleARKitSettings.html). The images are saved to Container/Documents/CameraImages. How can we make it so the next version we push to App Store will delete the contents of this folder upon launch?
0
0
391
Oct ’23
Is there any API for Full Disk Access in MacOS?
From this post, it is clear there was API as such to know if the FDA was granted or not. https://developer.apple.com/forums/thread/114452 But this post is 4 years old. I tried to find one that would ease my work, but to my surprise we are still there. So how an Application decide to know if FDA given then proceed, otherwise show a custom message/screen etc? Apple should expose and API in Terminal, Plist, Cocoa.
1
0
405
Oct ’23
FileProvider's eviction is failing with resource busy error though no file is open
I have applied content policy as "downloadEagerlyAndKeepDownloaded" on the folder which i want to materialise (want to implement windows similar feature Always keep on this device feature in mac os in FileProvider). For root item the policy is downloadLazily and for rest of the item it is inherited. The issue i am facing is, while dematerialising the folder, the file provider'e evictItem api is continuously failing with resource busy error though there is no file from that folder in an open state. And it keeps giving the same error and unable to dematerialise that folder.
1
0
515
Oct ’23
The correct way to write files to /Library
Hello - I’m creating an app that needs to copy ColorSync profiles to the /Library/ColorSync/Profiles directory on macOS and was wondering what is the correct / sanctioned way to write to the /Library directory is? The app won’t be in the App Store. The app needs to run on Big Sur through Sonoma. I spent some time working with ColorSyncProfileInstall() but that seems to want to ask the user permission every single time the function is called - and this app can install up to 25 profiles at a time. (There are actually hundreds of profiles that can be chosen that will come from a server). I’m currently looking at using SMJobBless but that sure seems like using an atomic bomb to swat a mosquito. Any thoughts if SMJobBless is the right way to go? (SMAppService for 13 and on). Thanks!
1
0
682
Oct ’23
How to clean up UNNotificationAttachments?
I use a UNNotificationServiceExtension to download an image into temporaryDirectory that is attached as an UNNotificationAttachment to the notification. FileManager.default.temporaryDirectory .appendingPathComponent(UUID(). .appendingPathExtension(image.ext) data.write(to: fileUrl) let attachment = ... attachments.append(attachment) The documentation for UNNotificationAttachment say I am responsible to manage the storage space for such attachments: The system limits the amount of storage space allocated for attachments for each app. To delete attachments, use the methods of the UNUserNotificationCenter class to remove the notification requests that contain those attachments. https://developer.apple.com/documentation/usernotifications/unnotificationattachment Do I need to check in my AppDelegate if there are any notifications that are no longer displayed and remove their files? If so, how how to get a list of notifications that are no longer displayed?
0
0
393
Oct ’23
Does URLByResolvingBookmarkData consume any resources on iOS?
My app saves the file URLs obtained from UIDocumentPickerViewController as bookmark data and reads them on the "history screen". In the "history screen", whenever viewWillAppear is called in ViewController, URLByResolveBookmarkData is called for all bookmarks to check if the file has been deleted or moved. (Please see code below) - (void)refresh { NSManagedObjectContext* context = self.managedObjectContext; // read all bookmarks NSArray<HistoryItem*>* all = [self histories]; [all enumerateObjectsUsingBlock:^(HistoryItem * _Nonnull item, NSUInteger idx, BOOL * _Nonnull stop) { BOOL isStale; NSURL* url = [NSURL URLByResolvingBookmarkData: item.bookmark options: 0 relativeToURL: nil bookmarkDataIsStale: &isStale error: nil]; if(url == nil) { // file is deleted [context deleteObject: item]; } else { item.filename = url.lastPathComponent; if(isStale) { // file is moved NSData *data = [url bookmarkDataWithOptions: 0 includingResourceValuesForKeys: 0 relativeToURL: nil error: nil]; if(data != nil) { item.bookmark = data; } } } }]; [context save: nil]; } Then, after many calls to viewWillAppear, calling startAccessingSecurityScopedResource on the URL obtained by URLByResolvingBookmarkData returns NO. I suspect that URLByResolveBookmarkData is consuming some resources, because the problem reproduces even if I change the code inside the block to only call URLByResolveBookmarkData, and it doesn't reproduce when I empty the block. Does URLByResolvingBookmarkData consume any resources? If so, how do I release the consumed resources? OS: iOS 15 Xcode: 15.0
3
0
334
Oct ’23
Xcode 15 adding simulator runtime (xcrun simctl runtime add) , requires Security & Privacy approval
I am following the instructions at : https://developer.apple.com/documentation/xcode/installing-additional-simulator-runtimes. When I run sudo xcrun simctl runtime add "/Users/<user_name>/Downloads/iOS_17.0.1_Simulator_Runtime.dmg" I get an error : (1) Operation not permitted Accessing '/Users/<user_name>/Downloads/iOS_17.0.1_Simulator_Runtime.dmg' requires Security & Privacy approval. I get the same error even if Xcode in the Applications folder or the Downloads folder. If the .dmg is mounted or not. How can grant access to the .dmg ?
2
0
2.1k
Oct ’23
Need custom file access for developer tool. What can I do?
Hi, I have a developer tool that often needs access to files outside of the file the user has selected. For example, they can easily select a file that contains a reference to an include file NOT in the current folder or a descendent. But I still need access to that file. How do I handle this, on the latest version of MacOS? Right now it just fails to give me access to the file, making it look like our Mac version is WAY BEHIND the Windows version. Oh and this needs to be in the App Store eventually, but right now I need it to be available outside of it, so I have to use my Developer ID and notarized. I think I've got all of that nailed down, but I'm still having file permission issues. My entitlements currently (which doesn't work): com.apple.security.cs.disable-library-validation com.apple.security.cs.disable-executable-page-protection com.apple.security.app-sandbox com.apple.security.files.user-selected.read-write Thank you, -Chilton
2
0
494
Oct ’23
Are these entitlements correct for file access?
I have an app that needs to read a file the user selects from an Open dialog. Right now it works fine on my machine (of course), but doesn't let my app access the file on other systems. I code signed it using my Apple Developer ID. I have notarized it. I have checked it all with the notaryTool and it shows NO ERRORS and as far as I can tell, no warnings either. Here's the entitlements: com.apple.security.cs.disable-library-validation com.apple.security.cs.disable-executable-page-protection com.apple.security.app-sandbox com.apple.security.files.user-selected.read-write What could I be doing wrong? Thank you, -Chilton
1
0
367
Oct ’23
how to get iphone15 other disk path?
I'm from china,english is not well,in UIDocumentPickerViewController inMode:UIDocumentPickerModeOpen select the storage device path directoty ,I get the path string :file:///private/var/mobile/Library/LiveFiles/com.apple.filesystems.userfsd/D33D4EE8-E75C-3B21-8126-C5FD453D3D5B/ ,then use it will pop up UIDocumentPickerViewController window, ,there are any other api to obtain this path and to write and read storage device and no pop up viewcontroller?like iFile use api no UI.
2
0
244
Oct ’23
TCC Databases
Hello, There is something i do not understand about TCC: I have allowed Terminal app to Full Disk Access. I was able to open my current user's TCC.db file with sqlite3 from terminal. I was able to delete entries in access table with sqlite3. I had no errors, but these changes haven't been applied. My question is why was I able to modify TCC.db file ? Is there a specific thing to do to flush privileges ? I have a second question: When an application fires an NSOPenDialog on a cocoa application, the selected file access rule bypasses TCC. This is normal because this is an intent from user. But this file access seems to be stored somewhere because if i reboot computer, my cocoa application can read this file again, without NSOpenDialog opening. I have tried to look in current user's TCC.db file but i did not found anything. My question is: where is this information stored ? Thanks
2
0
664
Oct ’23
Changing Default Folder Name in Files App for iOS App
Hello, I'm working on an iOS app called "scribe-frontend-ios," and I'd like to change the default folder name that the app creates in the Files app on iOS. Currently, when the app saves files to the Files app, they all go into a folder named "scribe-frontend-ios." However, I want to just call this folder Scribe. I've tried modifying the Info.plist file in my Xcode project by adding the "NSFileProviderServiceName" key with a custom folder name, but it doesn't seem to have any effect. I've also set "LSSupportsOpeningDocumentsInPlace" to true to indicate that my app supports opening documents in place. Can someone please provide guidance on how to change the default folder name for the app in the Files app? Is there a step I might be missing, or is there another way to achieve this? Any help or advice would be greatly appreciated. Thank you!
0
0
419
Oct ’23
Sonoma extremely slow / hangs opening folders in ~/Library/Containers
My app iterates over all folders on disk and queries metadata of each folder. After Sonoma was released, a bunch of users (but not all) complained that the app has become very slow or stalls indefinitely while performing the scan. I have narrowed down that the delay occurs in POSIX open() function, and the folders it stalls on are folders inside ~/Library/Containers and ~/Library/Group Containers, which store data of sandboxed apps. My app is not sandboxed itself, and the problem doesn't happen on all Macs, only on a subset of Macs. I read it in WWDC transcripts that in macOS Sonoma, Apple has introduced additional privacy access control to these particular folders, and my guess is that the delays and stalling are related to this new macOS feature. Is anyone else is experiencing this problem? Can I do something to work around this problem? Or is this a bug of macOS Sonoma and I should report it to Apple?
1
0
877
Oct ’23
Issue with importing files from File browser to the app via SwiftUI
I'm getting the following error message on on iOS 17.1 and Xcode 15.0.1 The view service did terminate with error: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method} In my info.plist I have given access to all file related permissions to rule out any issues Supports opening documents in place -> YES #if os(iOS) .fileImporter(isPresented: $isiOSFilePickerShown, allowedContentTypes: [.item], allowsMultipleSelection: false, onCompletion: { result in do{ guard let selectedURL: URL = try result.get().first else { return } guard selectedURL.startAccessingSecurityScopedResource() else { return } //Some operation with selectedURL } catch let e{ print("error reading file \(e)") } }) #endif
0
0
442
Nov ’23