Post not yet marked as solved
Hello everybody,
I am struggling with accessing files from the Location OneDrive through UIDocumentViewController.
The error says:
Error Domain=NSCocoaErrorDomain Code=260 "Die Datei „Testfile.txt“ konnte nicht geöffnet werden, da sie nicht existiert." UserInfo={NSFilePath=/private/var/mobile/Containers/Shared/AppGroup/11E04153-649E-416F-9860-2EA9C0913A18/File Provider Storage/item|1|18a17c69%2D5d6d%2D4b16%2Db388%2D4a9834e9440b/Testfile.txt, NSUnderlyingError=0x281202310 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
The Controller is initialised the following way:
let ctrl = UIDocumentPickerViewController(forOpeningContentTypes: [.image, .audio, .video, .item, .content])
And in the delegate method I do the following:
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
guard let documentUrl = urls.first else { return }
guard documentUrl.startAccessingSecurityScopedResource() else {
parent.errorText = "Developer Error: Can't access security scoped resource."
return
}
defer {
documentUrl.stopAccessingSecurityScopedResource()
}
do {
let data = try Data(contentsOf: documentUrl)
} catch {
parent.errorText = error.localizedDescription
}
}
Any help is appreciated!
Thanks
Post not yet marked as solved
I was successfully able to get the callback for file reads for the files in my mounted folder. Now we need to implement some read protection on top of that, we need to only allow some specific applications to access the data through the File provider.
for that, we need to get the name or any information regarding the Application that requested the read.
one thing I've seen is the request.requestingExecutable , which is coming nil for all the applications trying to read the files in the mounted folder. But i do get applications name for the things done by finder (drag&drop and Copy paste) .
What are the ways I can get the reading Application names ?
and what could be done for implementing data leak features working in pair with the File Provider Extension ?
Post not yet marked as solved
Recently I've had a project which always had behaved normally start placing new files in my home folder. I'm not sure what started this, but I've found out that the issue occurs if the project folder or one of its parents have a Finder tag. I don't know if the same happens with the 'old' Finder labels. I'm surprised this hasn't been discussed yet, one would think at least one developer would be using tags in their filesystem.
Xcode 15.1 seems to default to the first parent it can find that doesn't hava a tag. I don't know about earlier versions.
Apparently, the solution is to remove the tag AND clear the build data. An Xcode restart seems not to be needed.
Post not yet marked as solved
Here's how my app used to work:
On one device, generate a text file with a custom extension.
Send it via AirDrop or in Messages to another device.
Open the file in another copy of my app.
The app processes the data correctly the way I want.
Now, when I try to do this, I get this:
Error Domain=NSCocoaErrorDomain Code=257 "The file “Shopping List.sld” couldn’t be opened because you don’t have permission to view it." UserInfo={NSFilePath=/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/Downloads/Shopping List.sld, NSUnderlyingError=0x282280a50 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
file:///private/var/mobile/Library/Mobile%20Documents/com~apple~CloudDocs/Downloads/Shopping%20List.sld
I think this broke with the iOS 17 upgrade.
What permissions or capabilities do I need to add to my app to do that, and how do I go about adding them? I am quite new to xCode and iOS developement, but I had this working before.
I like to find a way to identify network volumes, and whether they're run by certain servers, e.g. specifically whether they're on a Synology NAS.
Reason is that Synology, while apparently supporting the Spotlight-over-SMB API, comes with a lot of bugs, requiring me to work around them when searching on those volumes with the macOS Spotlight API.
I could, of course, ask the user to "configure" each mounted volume in my software, but I'd rather do this automagically, if possible, as it's less prone to user mistakes.
So, my question is: Is there a way to learn a bit more about the server of a mounted network volume? E.g., if I could learn its IP address, I could try to connect to it via http protocol and then maybe get a useful response that identifies it as being from Synology.
Or, alternatively, can I tell which SMB volumes are served by a Mac, so that I can at least assume that those handle Spotlight calls correctly, while I assume anything else is buggy (so far, AFAIK, Synology is the only other SMB server that supports Spotlight search).
I've tried to find some data in the IORegistry, but that doesn't seem to store anything about network vols. The statfs function doesn't seem to give me anything for that either, nor do the various fcntl calls as far as I could tell.
I also checked with the DA apis, e.g.:
DASessionRef daSession = DASessionCreate (NULL);
CFURLRef furl = CFURLCreateWithFileSystemPath(NULL, CFSTR("/Volumes/TheNAS"), kCFURLPOSIXPathStyle, true);
DADiskRef daDisk = DADiskCreateFromVolumePath (NULL, daSession, furl);
if (daDisk) {
CFDictionaryRef daInfo = DADiskCopyDescription (daDisk);
NSLog(@"%@", daInfo);
}
However, this only prints basic information:
DAVolumeKind = smbfs;
DAVolumeMountable = 1;
DAVolumeName = TheNAS;
DAVolumeNetwork = 1;
DAVolumePath = "file:///Volumes/TheNAS/";
Where, then, does Finder's "Get Info" get the smb path from, for example?
So, I'm looking into startaccessingsecurityscopedresource() function and from my current understanding this is to get temporary access to files/folders you don't implicitly have access to i.e., that don't belong to your sandbox. I can understand what it means wrt macOS, iOS, iPadOS, but what does it mean in watchOS and tvOS where there isn't any file sharing between different apps? And what is it's relevance wrt using iCloud (if there is any?)
Post not yet marked as solved
I want to store sensitive data, which has to be removed when the application is moved to bin, but not when the application is updated (install newer version of application). When I move application to bin the data still remain on the MacBook so when I install the application again, the sensitive data is loaded. This problem is only on macOS, because iOS and iPadOS clear all data when I uninstall them.
I tried many options of storing. SQLite file stored in applicationSupportDirectory, temporaryDirectory, but nothing worked. I also tried to store this data using UserDefaults, but also unsuccessful.
I expect that I install application and it will store this data somewhere, when I update the application, the data remain, but when I uninstall this application by moving it to BIN, it will remove this data.
Post not yet marked as solved
Hi
So Apple Support sent me here ... (Case: 102237195769 if anyone has access)
My entire file system seems to be tagged with "com.apple.provenance" tags ... they're everywhere
drwxr-xr-x@ 3 jon staff 96 20 Jan 2023 .vs-kubernetes
com.apple.provenance 11
drwxr-xr-x@ 5 jon staff 160 21 Jun 2023 .vscode
com.apple.provenance 11
drwxr-xr-x 12 jon staff 384 28 Feb 00:17 .vscode-server
drwxr-xr-x@ 3 jon staff 96 11 Dec 2022 .warp
com.apple.provenance 11
-rw-r--r--@ 1 jon staff 691 29 Nov 19:14 .wget-hsts
com.apple.provenance 11
-rw-r--r--@ 1 jon staff 361 11 Dec 15:55 .zprofile
com.apple.provenance 11
-rw-r--r--@ 1 jon staff 300 23 Jul 2023 .zprofile.bak
com.apple.provenance 11
-rw-r--r--@ 1 jon staff 136 4 Dec 2022 .zprofile.pysave
com.apple.provenance 11
-rw------- 1 jon staff 16802 27 Feb 22:20 .zsh_history
drwx------@ 7 jon staff 224 21 Feb 14:28 .zsh_sessions
com.apple.provenance 11
-rw-r--r--@ 1 jon staff 1681 24 Feb 18:24 .zshrc
Now I don't know if this is related to the CrossOver (aka Wine) problem we're experiencing, or if it's a coincidence .. however I'd like to understand why every file that gets created ends up with this tag.
When installing a Bottle in CO none of the shortcuts appear within the CO App .. which is where we started all of this.
jon@ziggy ~ % cd Library/Application\ Support
jon@ziggy Application Support % ls -lad@ CrossOver
drwxr-xr-x 7 jon staff 224 28 Feb 02:02 CrossOver
jon@ziggy Application Support % cd CrossOver
jon@ziggy CrossOver % ls -la@
total 784
drwxr-xr-x 7 jon staff 224 28 Feb 02:02 .
drwx------+ 184 jon staff 5888 28 Feb 08:56 ..
drwxr-xr-x 3 jon staff 96 28 Feb 01:59 Bottles
-rw-------@ 1 jon staff 239584 28 Feb 01:59 cxfixes.xml
com.apple.provenance 11
-rw-------@ 1 jon staff 256 28 Feb 01:59 cxfixes.xml.sha256
com.apple.provenance 11
-rw-------@ 1 jon staff 155031 28 Feb 02:02 gstreamer-1.0-registry.x86_64.bin
com.apple.provenance 11
drwxr-xr-x 5 jon staff 160 28 Feb 01:59 tie
Problem Summary
The Desktop shortcut keeps randomly vanishing from the Finder Favourites section
Every file is tagged as com.apple.provenance and despite trying to clear the tags (which does work) they re-appear moments later.
At this stage .. I've run out of ideas, Codeweavers support has gone silent and Apple Support said "try developer.apple.com" ... sigh
Last night I flattened my M1 MBP and reinstalled. All looked good until Migration Assistant got involved and then it migrated across whatever is doing this as the problem persists.
Post not yet marked as solved
Anyone have any experience, started to get permission and failed to stat error for apple script which has shell do rysnc to backup files after moving files to new drive.
Post not yet marked as solved
Hi,
I am trying to create a hard link on MacOS(Mac Catalyst App) between files using
[self linkItemAtURL:fromURL toURL:toURL error:&error];
Source Path for MacOS -
/var/folders/lf/dt_4nxd945jdry2241phx0_40000gn/T/net.appname.AppName/documents/...
Destination Path for MacOS -
/Users/username/Library/Group Containers/group.net.appname.AppName.shared/Message/Media/...
Although the same code works fine on iOS, but getting following error on MacOS
Error Domain=NSCocoaErrorDomain Code=513 couldn’t be linked because you don’t have permission to access, Operation not permitted
Source Path for iOS -
/Users/user/Library/Developer/CoreSimulator/Devices/B4054540-345F-4D90-A3C5-DA6E6469A3FC/data/Containers/Data/Application/B4AB7D70-491C-49E5-9A3F-27E66EC3423D/tmp/documents/...
Destination Path for iOS -
/Users/user/Library/Developer/CoreSimulator/Devices/B4054540-345F-4D90-A3C5-DA6E6469A3FC/data/Containers/Shared/AppGroup/842B248E-CCA6-4B5C-82BD-2858EADD3A90/Message/Media/...
However, interestingly if I try to copy the file, it works perfectly fine on MacOS as well. I am unable to understand if it is the permission issue, it should not work with copy as well.
Does anyone have any reason/solution to this behaviour?
Post not yet marked as solved
I have app that is using container for small settings data and iCloud for larger storage, but I also want to be able to save to local documents folder. When I do that the url that is created is not local docs, but:
path: file:///var/mobile/Containers/Data/Application/85A8B8C9-C0C3-4843-A74C-5A951F593790/Documents/Dialog08:45,%2022%20Feb%202024
Here is code using to save to local docs folder.
func saveDataToFile(data: String) {
//file will be datetimedialog
let formatter = DateFormatter()
formatter.dateFormat = "HH:mm, d MMM y"
var dateTime = Date.getCurrentDate()
dateTime = formatter.string(from: Date.now)
var saveFilename = "Dialog"
saveFilename.append(dateTime)
let path = getDocumentsDirectory().appendingPathComponent(saveFilename)
print("path: \(path)")
// let fileURL = URL(fileURLWithPath: data, relativeTo: path)
do {
try data.write(to: path, atomically: true, encoding: String.Encoding.utf8)
} catch {
print(error.localizedDescription)
}
}
func getDocumentsDirectory() -> URL {
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
return paths[0]
}
Post not yet marked as solved
Hi, so I want to have a set of config files and data files which need to be accessible for say 3 of the apps I am building. And these files should be accessible to all 3 regardless of who makes them. The config file can have details like theme etc or sign in details etc.
How do I go about doing this? Some of the things I thought of were,
Using the app group storage folder, where if I understand correctly, if my apps belong to the same app group and have the required entitlement I can create files, they can be accessed by all 3 apps and they will exist until the last of the applications is uninstalled. Is this right?
Letting the user pick a location/folder in "On my iPhone" in each of the apps and store the folder in bookmarks for each of the app. In this way the data will remain even after it is uninstalled.
Is there any other way this can be done. Is there a recommended way of doing this?
I can't anymore check SMB credentials on macOS. Sonoma stops checking them after first successful validation. No matter which way to go, it could be smbutil, mount_smbfs, or even the NetFSMountURLSync function from the NetFS framework.
Below is a script that works fine on Ventura, but would fail on Sonoma. There are three smbutil calls. The first call includes the correct username and password, the second omits the password, the third goes with an incorrect password. On Ventura and earlier the second and third calls fail, but Sonoma feels okay.
The same could be seen with mount_smb.
Is it a normal behavior?
Is there a way to check credentials on Sonoma?
#!/bin/bash
# SMB server or its ip address
SERVER="127.0.0.1"
RESOURCE="Test"
# username and password to authenticate on the server
USER_NAME="username"
USER_PASSWORD="password"
# path to mount server resource
MOUNT_POINT="/tmp/1"
function Raise
{
echo "!!! ERROR: $1"
exit 1
}
/usr/bin/smbutil view -ANf "//${USER_NAME}:${USER_PASSWORD}@${SERVER}" || Raise "Unable to browse shares with credentials"
/usr/bin/smbutil view -ANf "//${USER_NAME}:@${SERVER}" && Raise "Successfully browsed shares without password"
/usr/bin/smbutil view -ANf "//${USER_NAME}:foobar@${SERVER}" && Raise "Successfully browsed shares with incorrect password"
mkdir -p "/tmp/1"
mount_smbfs -s "//${USER_NAME}:${USER_PASSWORD}@${SERVER}/${RESOURCE}" "/tmp/1" || Raise "Unable to mount share with credentials"
diskutil unmount "/tmp/1"
mkdir -p "/tmp/1"
mount_smbfs -s "//${USER_NAME}:foobar@${SERVER}/${RESOURCE}" "/tmp/1" && Raise "Successfully mounted with incorrect password"
diskutil unmount "/tmp/1"
Post not yet marked as solved
Hi there,
i have an macOS app, sandboxed, compatibility 10.13 up to Sonoma, objective-C.
I have a dropzone (or alternatively selection with NSOpenPanel) where users can drop files which results in an array of NSURLs. I create bookmarks to securely access them. This worked for years.
Now i want to add iCloud support. Everything works good so far. I have methods to check the file status and download the file from icloud if NSURLUbiquitousItemDownloadingStatusKey == NSURLUbiquitousItemDownloadingStatusNotDownloaded
Then i listen for the file, once the status key changes to NSURLUbiquitousItemDownloadingStatusCurrent i continue with processing the NSURL and i want to create bookmarkData:
[filePathUrl bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope
includingResourceValuesForKeys:nil
relativeToURL:nil
error:&error]];
But this returns the error "Could not open() the item: [1: Operation not permitted]"
So i was wondering if downloading the file from iCloud now changed the NSURL itself so the given permissions by dropping do not match the downloaded file?
Adding [filePathUrl startAccessingSecurityScopedResource]; didn't change anything.
Any help appreciated
I want to check if a given string matches a file pattern.
Does Swift have builtin support for filename globbing? Or is there any 3rd party packages for this?
Post not yet marked as solved
Hi everyone,
I am unable to load contents of my manually created JSON file to a table view. I am not sure what might be wrong with my code and that is why I am requesting for assistance. Here is the link to my GitHub repository: https://github.com/leonardsangoroh/AfricanCountriesInfo/tree/main
Any form of help will be highly appreciated.
Thank you in advance :)
For example I created a project aaa.
aaa source folder is called aaa.
that is
aaa
aaa/aaa
then I put a data file in
aaa/aaa/some.data
now i want to test data in
aaa/aaaTests/aaaTests.swift
How can i access aaa/aaa/some.data in aaaTests.swift?
If I want to access some.data inside aaa/aaa/ContentView.swift, how to write the code?
I have been searching google and bing for days, but find no example answering my questions.
Can anyone help me out?
Thanks in advance.
Post not yet marked as solved
So ever since I restarted my M1 Mac, I have encountered a peculiar issue where files on the desktop or in Finder are not visible, despite their existence being confirmed via Terminal and other applications like VS Code. This can be quite frustrating, especially when it disrupts workflow and access to crucial files. That problem could also happen after updating the Mac too.
Resolve 1:
You toggle the iCloud settings on and off by going to Settings > Profile > iCloud > iCloud drive > Desktop and Dokuments Folders. after that restart the Mac and it's fixed. this worked for the most people but it did not for me.
Resolve 2:
open the Terminal and Navigate the the Desktop Directory by typing in:
cd ~/Desktop
To enshure your in the directory you can see the ..desktop % behind the cursor, and after that, set the visibility to True, by typing in:
chflags nohidden *
This should fix the issue.
Post not yet marked as solved
It appears the app is sandboxed. I need to be able to access the broader file-system and pick a folder/file. Is this possible?
Is it possible to invoke the app with a command-line argument? If so, how is it accessed (in code)?
Post not yet marked as solved
Hi Everyone,
We are facing distribution of external disk which is attached as /Volume/Untitled in the MAC machine. Ideally, this external disk shouldn't be part of the root. We're facing one issue when we add anything in the external disk, it first add in the root because this external disk is like an extension of the root one.
That's why we're not able to get the benefit of the external disk, facing full storage crunch in all the machine.
Can anyone please suggest a work around.
Our requirement is we are looking to mount external disk as aseperate mount point
(i.e /externaldisk instead of default /volumes/Untitled).
Thank you