Files and Storage

RSS for tag

Ask questions about file systems and block storage.

Pinned Posts

Posts under Files and Storage tag

211 Posts
Sort by:
Post not yet marked as solved
5 Replies
80 Views
Hello, i am trying to record logs in my network extension class, and then i want to read it in my application class, i.e. viewModel. However, i am unable to read the data. I have tried different ways like UserDefaults, Keychain, FileManager, NotificationCenter and CoreData. I have also used Appgroups but still there is blocker for reading data outside the scope of Extension class.
Posted
by
Post not yet marked as solved
0 Replies
69 Views
Hi all, I'm implementing Intune MAM to secure applications on iOS. However, I need my users to be able to save files (e.g. attachments in an email in the Outlook app) to iOS Files. To do so, I'm trying to put Files in exception of my Intune MAM policy and I need to obtain the Files "CFBundleURLSchemes" value from the info.plist file of the Files app. I'm not able to get that information. Are any of you able to get that somehow? Thanks!
Posted
by
Post not yet marked as solved
1 Replies
74 Views
Hello, It is possible to restrict Documents folder access with TCC. But when an applications shows a standard "file open" dialog, it is possible to access this directory to open a file. macOS allows file access in this case because it is an intentional action from user. So i suppose there is a kind of whitelist for all files path opened through "file open" dialog. I would like to know how i can access this whitelist and how i can remove entries. Thanks
Posted
by
Post not yet marked as solved
8 Replies
164 Views
Hi, I have been working on some kind of network filtering app for iOS using Content Filter Provider. And I have stored rules for each domain. As of right now, I use UserDefaults with my app's bundle suite to store and observe rules. I have also read this documentation page for UserDefaults link. Is it okay to use UserDefaults in my case, if I have rules added/modified dynamically as the flow is intercepted, or should I pick some other approach like Core Data, SwiftData, etc.? Thank you!
Posted
by
Post not yet marked as solved
1 Replies
90 Views
Hi, I am having this rare issues, where a handful of my users are crashing when trying to access their realm file. This is the error I'm seeing: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=3 "Failed to open file at path '/var/mobile/Containers/Data/Application/BCA5E4BC-5923-4D7E-8142-AB49B32A7E59/Documents/default.realm.lock': Operation not permitted" UserInfo={Error Code=3, NSFilePath=/var/mobile/Containers/Data/Application/BCA5E4BC-5923-4D7E-8142-AB49B32A7E59/Documents/default.realm.lock, Error Name=PermissionDenied, NSLocalizedDescription=Failed to open file at path '/var/mobile/Containers/Data/Application/BCA5E4BC-5923-4D7E-8142-AB49B32A7E59/Documents/default.realm.lock': Operation not permitted} and I can report that for all for those users, it seems that identiferForVendor has returned nil. So it looks like that's the common denominator. Any idea on what other data I can log or what's the issue here? Thanks..!
Posted
by
Post not yet marked as solved
0 Replies
85 Views
I have an ansible provisioner that is being triggered, but keeps failing because it cannot write a file out under /System/Volumes/Data/home. There are no files in that directory to clean up. When I do a df it shows that filesystem mount size as 0Bi. I ran the disk utility, but that did not resolve it either. Any help would be greatly appreciated. This is blocking my local development.
Posted
by
Post not yet marked as solved
2 Replies
188 Views
I'm trying to use some files within my application without transfering them to the app's file system, I've managed to do that and by using a bookmark (https://developer.apple.com/documentation/professional_video_applications/fcpxml_reference/asset/media-rep/bookmark/using_bookmark_data) I can access the same directory automatically on every new app laucnh. But if the external device gets disconnected and connected again, or the mobile device is restarted, I've noticed a change in the external device's URL and I also get an error retrieving the bookmark Error Domain=NSFileProviderErrorDomain Code=-2001 "No valid file provider found with identifier ‘com.apple.filesystems.UserFS.FileProvider’." UserInfo={NSLocalizedDescription=No valid file provider found with identifier ‘com.apple.filesystems.UserFS.FileProvider’., NSUnderlyingError=0x302a45a40 {Error Domain=NSFileProviderErrorDomain Code=-2013 "(null)"}} Is there a way that I can automatically regain access to the external device directory, or is using the UIDocumentPickerViewController the only way to access it again? Thanks!
Posted
by
Post not yet marked as solved
1 Replies
161 Views
Hello~I want to ask a storage issue I had recently. I found that my file writing will fail frequently if the iOS device enable iCloud Photos and the used storage is more than device storage. ex. iCloud Photos 707.8 GB used and choose to optimize iPhone Storage iOS Device UI shows that 185 GB is available (total 256 GB in device) What I need is to write a big file to upload later and I use FileHandle to generate it: ex. let fileWriter = try? FileHandle(forWritingTo: url) while !bufferIsAtEnd() { let data = readChunckFromBuffer() do{ try fileWriter.write(contentsOf: data) }catch{ return false } } fileWriter.close() The file needs about 40GB space to write, but I always get disk full error even though iOS UI shows me the device space is enough ( 185GB ) This issue disappeared if I turn off iCloud Photos. I think that the available 185 GB seems to be locked by iCloud storage optimization(The total device storage 256GB is smaller than 707GB used in iCloud Photos) and makes my file writing failed. I could not always turn off iCloud Photos since it is inconvenient but I do not know how to resolve the disk full issue when iCloud Photos enabled. Any suggestion will be very appreciated!
Posted
by
Post not yet marked as solved
2 Replies
168 Views
It seems that the first time I open my app after the phone is restarted, the app does not properly access UserDefaults. When my app is launched, I pull relevant user settings / preferences from UserDefaults. I recently noticed (after some users reached out about issues) that the first time the app is opened after a restart, the app appears as though all user settings / preferences have been erased. If the app is force quit and reopened, the user data seems to come back normally. If the user takes action in the app before force quitting, though, UserDefaults will be written to with these new, empty values (essentially erasing what used to be in UserDefaults). This makes it seem as though right after the phone is restarted, the app is unable to pull data from UserDefaults for some reason. Has anyone else seen this issue? It could also be due to the lifecycle of my app and how I access UserDefaults, so if others don't have this issue it would be great to hear how you handle this.
Posted
by
Post not yet marked as solved
1 Replies
160 Views
I am using NetFS's NetFSMountURLAsync api to mount SMB share in mac os app. I am able to mount the share however this share is not automatically appearing in Finder's sidebar. I tried using LSSharedFileListInsertItemURL to make the mount point available in Finder's side bar however facing crash on line, kLSSharedFileListItemBeforeFirst.takeRetainedValue() from below code snippet. let itemType: CFString = kLSSharedFileListFavoriteItems.takeRetainedValue() if let list: LSSharedFileList = LSSharedFileListCreate(nil, itemType, nil)?.takeRetainedValue() { let inPropertiesToSet: CFMutableDictionary = CFDictionaryCreateMutable(nil, 1, nil, nil) CFDictionaryAddValue(inPropertiesToSet, unsafeBitCast(kLSSharedFileListVolumesNetworkVisible, to: UnsafeRawPointer.self), unsafeBitCast(kCFBooleanTrue, to: UnsafeRawPointer.self)) let driveUrl = URL(fileURLWithPath: mountPoint) let shareUrl: CFURL = driveUrl as CFURL if let item: LSSharedFileListItem = LSSharedFileListInsertItemURL( list, kLSSharedFileListItemBeforeFirst.takeRetainedValue(), nil, iconRef, shareUrl, inPropertiesToSet, nil) { let itemRefId = LSSharedFileListItemGetID(item) let itemRefIdStr = "\(itemRefId)" userDefaults.set(itemRefIdStr, forKey: mountPoint) } } Anything wrong in above code? Also since this api is deprecated is there any alternative API to achieve this. The goal is to make the mount point available in Finder's sidebar so that user can easily access it.
Posted
by
Post not yet marked as solved
4 Replies
253 Views
I would like to get notified, when a specific file gets opened or closed by another application. I tried different things like DispatchSource, FSEvents and kqueue, but nothing worked. The only option so far is searching for all process ids, that accesses the file with proc_listpidspath (or with the command line tool lsof). Unfortunately I need to use a Timer for this. But checking i. e. every second will need a lot of CPU, so I'm curious, if there is a built in notification in macOS?
Posted
by
Post not yet marked as solved
2 Replies
215 Views
I use UserDefaults to store a variety of user data / preferences. Recently, I have started getting somewhat frequent complaints from users that their settings have been reset. There doesn't appear to be a rhyme or reason to the issue (some users have all of their data reset just once, while others are seeing that one of their settings resets very frequently). I haven't been able to pinpoint what the root cause is, but I figure that it must have something to do with UserDefaults (either all of it or only certain keys) somehow getting erased. As I figure out the root cause, I figure that a good solution in the meantime is to backup UserDefaults in some way (e.g. perhaps to iCloud?). Is there a standard / best-practice way of doing this?
Posted
by
Post marked as solved
1 Replies
161 Views
I'm a bit confuse on the file permission between root and admin account. I'm developing the background user agent process, and I created the agent plist file with the permission R&W for my admin account. When I tried to load my agent process with launchd, it said the plist file permission is not right. Only after I change the plist file owner to root chown root my.plist, did everything work. From the above situation, it seems that the root user cannot access files that are only authorized to the admin user. Admin account also can't access files authorized only to root, unless you add sudo or enter the password when the request admin password box pops up. But by sudo or password, it just temporarily converts your account from admin to root account. So am I right in my speculation?
Posted
by
Post marked as solved
3 Replies
204 Views
Hello, I am having some trouble with an application accessing and running SQlite database queries. The error I am getting is (5642) SQLITE_IOERR_SEEK when trying to sqlite_step_stement in the database. See https://www.sqlite.org/rescode.html#ioerr_seek A bit of background, it is an application in Unreal Engine, and everything was working fine in Unreal Engine 4. The application uses a SQlite database on disk to store and fetch data. This database is saved to the documents folder. (I also tried other folders to see if that would make a difference) But since switching to a new version of the engine, Unreal Engine 5, in a build I am getting errors when trying to read/write to the database. This only happens in a build .app file. The only big difference I can find is that in the new engine when making a build the codesigning is already done in the engine. I don't see why those settings would break anything though. It also has an entitlements file, but I also edited it and made sure it has the same entitlements settings as my own scripts that are run afterwards. I am overwriting the codesigning with our own CI/CD scripts afterwards. The .app file is codesigned, notarized and stapled by that script. Also I use an entitlements file to set certain values. It doesn't seem to be a code related issue, as everything is working fine when running the application "in editor". But only when creating a final .app build. It doesn't matter if this build is in Debug or Shipping. My first thought was to try more entitlements settings. But I tried the following and I am still getting the same errors: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.security.cs.debugger</key> <true/> <key>com.apple.security.cs.disable-executable-page-protection</key> <true/> <key>com.apple.security.cs.disable-library-validation</key> <true/> <key>com.apple.security.automation.apple-events</key> <true/> <key>com.apple.security.app-sandbox</key> <false/> <key>com.apple.security.cs.allow-dyld-environment-variables</key> <true/> <key>com.apple.security.cs.allow-jit</key> <true/> <key>com.apple.security.cs.allow-unsigned-executable-memory</key> <true/> <key>com.apple.security.files.downloads.read-write</key> <true/> <key>com.apple.security.network.client</key> <true/> <key>com.apple.security.network.server</key> <true/> </dict> </plist> I also am thinking that it might be a different issue as the application is able to create a database file in the documents folder, just not able to do the read write inside the database. These values are just set to try if any of these settings "fix" the issue, but thus far no luck. As there is nothing I can find in Unreal Engine related forums, and I also do not have a lot of experience with all the options when making Mac builds. I was hoping someone on this forum could think of a reason why a .app file would have problems with reading and writing to a SQlite database.
Posted
by
Post not yet marked as solved
0 Replies
176 Views
Hello. I am trying to load my own Image Based Lighting file in a visionOS RealityView. I used the code you get when creating a new project from scratch and selecting the immersive space to full when creating the project. With the sample file Apple provides, it works. But when I put my image in PNG, HEIC or EXR format in the same location the example file was in, it doesn't load and the error states: Failed to find resource with name "SkyboxUpscaled2" in bundle In this image you can see the file "ImageBasedLight", which is the one that comes with the project and the file "SkyboxUpscaled2" which is my own in the .exr format. if let immersiveContentEntity = try? await Entity(named: "Immersive", in: realityKitContentBundle) { content.add(immersiveContentEntity) do{ let resource = try await EnvironmentResource(named: "SkyboxUpscaled2") let iblComponent = ImageBasedLightComponent(source: .single(resource), intensityExponent: 0.25) immersiveContentEntity.components.set(iblComponent) immersiveContentEntity.components.set(ImageBasedLightReceiverComponent(imageBasedLight: immersiveContentEntity)) }catch{ print(error.localizedDescription) } Does anyone have an idea why the file is not found? Thanks in advance!
Posted
by
Post not yet marked as solved
2 Replies
254 Views
I have an app with IAP which uses a URLSession object to download files from a server. The download part of the code is: let request = URLRequest(url: fromURL, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: timeoutInterval) let (data, response) = try await downloadSession.data(for: request) This code has been working without trouble for over a year with thousands of downloads. Now I have a user with a new iPhone (iOS 17.3.1) which refuses to download, failing at the above code (judging by the high level logs). My question is this: What sort of things should we be looking at in order to diagnose this issue? So far we have done the following: He has no general download issue (eg Safari works fine) His network access is 'normal' and the problem persists when the network is changed (4G, wifi etc) He runs a VPN (Nord) but the problem persists when this is off He has no 3rd party AV software His phone is not in lockdown mode Any pointers would be appreciated! NB I have no physical access to his device (yet!)
Posted
by
Post not yet marked as solved
1 Replies
206 Views
Hi, I have an issue that I don't understand, and I need help. I am using Pipe() in Swift, and I found that if I create more than 2560 (more or less) pipes, I cannot create more. The call fails with Too many open files, even though I closed all the files associated with the pipes. This is a minimal code to reproduce the issue: for i in 0...1278 { NSLog("Testing: \(i)") let stdin_pipe = Pipe() let stdin_file = fdopen(stdin_pipe.fileHandleForReading.fileDescriptor, "r") var stdout_pipe = Pipe() var stdout_file = fdopen(stdout_pipe.fileHandleForWriting.fileDescriptor, "w") if (stdout_file == nil) { let errorString = String(cString: strerror(errno)) NSLog("Could not create an output stream. Error: \(errorString)") } do { // I'm really trying to close everything (but it doesn't matter): close(stdout_pipe.fileHandleForWriting.fileDescriptor) close(stdin_pipe.fileHandleForReading.fileDescriptor) try stdout_pipe.fileHandleForWriting.close() try stdin_pipe.fileHandleForReading.close() try stdout_pipe.fileHandleForReading.close() try stdin_pipe.fileHandleForWriting.close() } catch { NSLog("Error in closing pipes in MyExtension: \(error.localizedDescription)") } } It will work for i going to 0 to 1277, and fail for i == 1278. The error (obtained from strerror(errno) is Too many files open, even though there are around 6 file descriptors opened (I checked). What am I doing wrong?
Posted
by
Post not yet marked as solved
6 Replies
255 Views
I have a file named ä.txt (with German umlaut) on my FTP server. I select it like this: let openPanel = NSOpenPanel() openPanel.runModal() let source = openPanel.urls[0] Running this code unexpectedly throws an error: do { print(try source.checkResourceIsReachable()) } catch { print(error) // Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory” } Manipulating the URL also seems to change the underlying characters: print(source) // file:///Volumes/abc.com/httpdocs/%C3%A4.txt print(URL(fileURLWithPath: source.path)) // file:///Volumes/abc.com/httpdocs/a%CC%88.txt Note that both variants of the URL above also throw the same error when running URL.checkResourceIsReachable(). If I download the file to my Mac, then both variants print file:///Users/me/Downloads/a%CC%88.txt and neither of them throws an error when running URL.checkResourceIsReachable(). What is the problem? How can I correctly access this file on the FTP server?
Posted
by