File Provider

RSS for tag

Allow other apps to access the documents and directories stored and managed by your containing app using File Provider.

Posts under File Provider tag

200 Posts

Post

Replies

Boosts

Views

Activity

file provider does not get loaded on addDomain
I have created working fileprovider, that works perfectly on my local machine. Codesigned in xcode, with our company sign certificate as Developer ID Application. No provisioning profile. Also notarized result dmg. Works as expected on my local machine. But won't load on any other machine. Calling [NSFileProviderManager addDomain: ...], ends up with error: Error Domain=NSFileProviderErrorDomain Code=-2001 "The application cannot be used right now." UserInfo={NSLocalizedDescription=The application cannot be used right now.} Code=-2001 should mean, that no file provider manager extension was found in an app bundle. I have made a TestFileProvider application that is totally simplified File Provider example. This too does work only on my own machine. Relevant code from app: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSFileProviderDomain* fileProviderDomain = [[NSFileProviderDomain alloc] initWithIdentifier:@"com.xxxxx.dwc.FileProvider" displayName:@"TestDomain"]; [NSFileProviderManager addDomain:fileProviderDomain completionHandler:^(NSError * _Nullable error) { if (error) NSLog(@"add domain: %@", error); else NSLog(@"add domain SUCCESS"); }]; } There are also these errors, that are related, but I do not understand what are they implying neither how to fix: kernel Sandbox: fileproviderd(448) deny(1) file-read-data /Applications/TestFileProvider.app fileproviderd [ERROR] PluginRecord doesn't have container url for fileproviderd [WARNING] No provider found with identifier (null) for calling bundle (null) on second attempt. I'm clueless on how to fix this. Is this related to codesign ? Or is it necessary to start fileprovider with different method call ?
4
1
4.1k
Sep ’23
How to inform the file provider about new changes in the remote storage properly
Currently, we are doing it by: Calling the function 'signalEnumerator' with the identifier as workingset Returning the metas of the new changes to the function enumerateChanges called by the file provider Sometimes, it would take more time to get the enumerateChanges function call from the file provider after invoking the signalEnumerator function. So, Kindly let us know if is there any other alternative to pass the new updated items information to the file provider properly and quickly.
1
0
691
Sep ’23
Unable to load FileProvider Extension
We are developing File Provider for macOS. We followed apple sample app, and are able to create a File Provider with Container app and an extension. We are able to get this working while building from Xcode. But the distributable build does not load the extension and fails with error "Application can not be loaded". We need help with understanding root cause of the issue, and exact entitlement that we can use for creating distributable builds.
0
0
561
Sep ’23
Feasibility and Privacy Concerns for App Monitoring and Blocking 3rd Party Apps on iOS
Hello, I am interested in developing an iOS app that can monitor the names of third-party applications running in parallel without collecting any user-specific data. I would like to inquire about the feasibility of implementing such functionality within the iOS ecosystem and if there are any privacy terms or restrictions that I need to be aware of to ensure compliance with Apple's policies. Additionally, I want to emphasize that the app will not collect any user-specific data but only the names of third-party apps for operational purposes. Thank you for your guidance.
0
1
576
Sep ’23
Can we able to have context menu activation logic in main app
We are implementing a file system extension using the file provider replicated extension for an application on Mac OS. On part of it, we need to show context menus for items(files/folders) inside the file provider's mounted folder. But we don't want to show the context menu based on the 'activation rule' key's value declared on each NSExtensionFileProviderActions item in the info.plist file but with the main app's code logic. Because if we use the info.plist activation rule, we need to use each item's instance variables as part of predicate query(which decides on showing the context menu item), and after performing the action, we need to change the value of that instance variable so that we can show opposite context menu of the previous one (for example if previously 'set offline' is clicked, now 'set online' have to be shown) but doing this is tedious process. Also, we already implemented the code logic in our main app(that is not written in swift) to choose what are the context menu items to be shown and so we want to use it. So, Instead, we are hoping to do it either: By handling the get-menu function call or By handling the predicate checking function call. Kindly let us know if is there any function we can override or inform the system to do at least any one of the above things. Thanks in advance.
0
0
721
Sep ’23
Is it possible to get the context menu functionality of Finder Sync Extension in File Provider?
Previously, we are using the Finder Sync extension for showing the context menu on the finder items. But now we are planning to use the File Provider extension on Mac OS. So, as of our learning, we found that the context menu items to be shown on the finder items have to be informed using the 'NSExtensionFileProviderActions' key in the info.plist file and the activation rule also have to be informed there under key 'NSExtensionFileProviderActionActivationRule'. But in the Finder Sync, we can get both the right-click(to list menu) and menu item clicked(on the context menu shown) calls from the Finder Sync extension. Like Finder Sync Extension, can we able to get both the calls from the file provider extension?​
0
0
686
Sep ’23
How to delete data in the stock iOS "Files" app from an external app?
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.
0
0
540
Aug ’23
Error using file importer in SwiftUI app in combination with Firebase Storage
Trying to use file importer in a swift app to upload documents into firebase Storage and getting error when running on live device but works perfectly fine on emulator. error: BackgroundSession <***...> Failed to issue sandbox extension for file file:///private/var/mobile/Library/Mobile%20Documents/comappleCloudDocs/Sample.pdf, errno = [1: Operation not permitted] UNKNOWN ERROR Error Domain=FIRStorageErrorDomain Code=-13000 "An unknown error occurred, please check the server response." UserInfo={object=Repository/Sample.pdf, ResponseBody=Can not finalize upload. Current size is 0. Expected final size is 2665098., bucket=bucket, data={length = 77, bytes = 0x43616e20 6e6f7420 66696e61 6c697a65 ... 32363635 3039382e }, data_content_type=text/plain; charset=utf-8, NSLocalizedDescription=An unknown error occurred, please check the server response., ResponseErrorDomain=com.google.HTTPStatus, ResponseErrorCode=400} I tried separating all the logic from selectedFile.startAccessingSecurityScopedResource() all the way through the end into a function of its own using @MainActor based on another post I found around here and issue persisted.. Below is the implementation: .fileImporter( isPresented: $fileImporterIsPresented, allowedContentTypes: [.pdf], allowsMultipleSelection: false ) { result in switch result { case .success(let url): print(url) guard let selectedFile:URL = url.first else { return } guard selectedFile.startAccessingSecurityScopedResource() else { return } let firebaseRepository = Storage.storage().reference().child("Repository/Sample.pdf") let uploadTask = firebaseRepository.putFile(from: selectedFile) uploadTask.observe(.progress) { snapshot in // Upload reported progress percentComplete = 100.0 * Double(snapshot.progress!.completedUnitCount) / Double(snapshot.progress!.totalUnitCount) } uploadTask.observe(.success) { snapshot in selectedFile.stopAccessingSecurityScopedResource() uploadTask.removeAllObservers() print("SUCCESS") // Upload completed successfully } uploadTask.observe(.failure) { snapshot in if let error = snapshot.error as? NSError { switch (StorageErrorCode(rawValue: error.code)!) { case .objectNotFound: print("NOT FOUND") // File doesn't exist break case .unauthorized: print("UNAUTHORIZED") // User doesn't have permission to access file break case .cancelled: print("CANCELLED") // User canceled the upload break /* ... */ case .unknown: print("UNKNOWN ERROR \(error.description)") print("UNKNOWN ERROR \(error.localizedDescription)") print("UNKNOWN ERROR \(error.underlyingErrors)") // Unknown error occurred, inspect the server response break default: print("UNSPECIFIED ERROR") // A separate error occurred. This is a good place to retry the upload. break } } } case .failure(let error): print(error) } }
1
0
2.1k
Aug ’23
File Provider UI extension on macOS
I'm asking this because the documentation is totally contradicting to itself on multiple occasions: Extensions overview page (https://developer.apple.com/app-extensions/) claims it's not supported. At the same time, on FileProviderUI docs page (https://developer.apple.com/documentation/fileproviderui) macOS is listed among another platforms and docs kinda generally suggest it is supported. At the same time, "add new target" dialog in xcode is missing "File Provider UI Extension" template under macOS. At the same time, it's can be easily be done by creating an iOS extension, then swapping SDK to macOS and UIKit APIs to their AppKit counterparts. This way, FileProviderUI actions DO appear in Finder. Problem is, after clicking the action, UI never appears and here's what i see in Console: default pkd Waiting on thread <private> until Launch Services database seeding is complete. default Finder [d <private>] <PKHost:0x600000c38cc0> Beginning discovery for flags: 1024, point: (null) default Finder [d <private>] <PKHost:0x600000c38cc0> Completed discovery. Final # of matches: 0 error Finder nil extension for provider ID (<private>), error: (null) error Finder Action with identifier (<private>) did finish with error (Error Domain=FPUIActionViewControllerErrorDomain Code=1000). error Finder FP Custom action sheet finished with error Error Domain=FPUIActionViewControllerErrorDomain Code=1000 "(null)" default pkd [d <private>] Final plugin count: 0 This is totally confusing, please elaborate.
1
0
1.2k
Aug ’23
-com.apple.CoreData.ConcurrencyDebug 1 not working in FileProvider extensions
I discovered a multithreading mistake in my use of NSManagedObjects recently and was surprised that I wasn't alerted to this during development, since I had -com.apple.CoreData.ConcurrencyDebug 1 set under "arguments passed on launch" for my macOS and iOS FileProvider extensions. I confirmed that the expected log stating CoreData: annotation: Core Data multi-threading assertions enabled. is NOT present when running these targets (but does appear as expected on my main macOS and iOS applications). Can anyone advise me on how to get this concurrency debugging functionality to work on my FileProvider extension(s)? Thanks
1
1
997
Aug ’23
Unable to Add Default badges to File Icons in File Provider
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.
0
0
710
Aug ’23
Can we have Finder Sync Extension on File Provider (Cloud Storage) Path macOS
The existing project of Finder Extension is doing an amazing job in other paths but when I point it to the CloudStorage path the context menu doesn't show up. And no trace of what is going wrong any where (Xcode Logs, Console log, crash log, etc.) Path Used: /Users/<User>/Library/CloudStorage/FP-SomeDomains Yes, even my first though was, it must be because of dataless file and folders. But unfortunately it not. There was no context menu presented from my Finder Extension even on real physical files and folders.
3
1
2.3k
Aug ’23
FileProviderReplicatedExtension’s modifyItem called immediately following fetchContents’ completion for updates from remote
Hi there, The first time an item is materialized (via fetchContents), the contents are downloaded and we set the contentVersion (to a hash of the content) - no problems here. Once a content change is made remotely, we enumerateChanges and change the contentVersion to ”empty” (Data()). This triggers fetchContents to be called (where we fetch the new content). As soon as we call the completion handler for fetchContents though (now with a new contentVersion (a hash of the new content), we get a call immediately after to modifyContents, with the same contents that we just fetched. This call to modifyContent seems like a bug. how can I prevent it from being called by the system? Thanks for the help!
6
0
853
Jul ’23
How do we partially load files in chunks from a remote server.
I've been building a finder extension for managing a bunch of videos in a remote server. When I try to click on a video file that is dataless it seems to always trigger fetchContents(for:version:request:completionHandler:). I have implemented fetchPartialContents(for:version:request:minimalRange:aligningTo:options:completionHandler:) but i haven't been able to trigger this method no matter how large the size of the file is. What are the conditions that i have to meet to trigger this function so i could stream the video data in chunks ?
1
0
1.2k
Jul ’23
How to add new NSFileProviderDecorations to FileProviderExtensions
I'm having an issue where adding new decorations to NSFileProviderDecorations doesn't make those decorations visible in the app. Here is my NSFileProviderDecorations array in plist file: <key>NSFileProviderDecorations</key> <array> <dict> <key>BadgeImageType</key> <string>com.apple.icon-decoration.badge.checkmark</string> <key>Category</key> <string>Badge</string> <key>Identifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER).iconSynced</string> <key>Label</key> <string>Synced</string> </dict> <dict> <key>BadgeImageType</key> <string>com.apple.icon-decoration.badge.warning</string> <key>Category</key> <string>Badge</string> <key>Identifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER).iconConflict</string> <key>Label</key> <string>In Conflict</string> </dict> <dict> <key>BadgeImageType</key> <string>com.apple.icon-decoration.badge.locked</string> <key>Category</key> <string>Badge</string> <key>Identifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER).iconLocked</string> <key>Label</key> <string>Locked</string> </dict> <dict> <key>BadgeImageType</key> <string>com.apple.icon-decoration.badge.warning</string> <key>Category</key> <string>Badge</string> <key>Identifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER).iconUploadFailed</string> <key>Label</key> <string>Upload failed</string> </dict> </array> The first two decorations: iconSynced and iconConflict work just fine as expected, but then I added the other two decorations: iconLocked and iconUploadFailed and I just can't get them to work. Here is an example of my decorations implementation: var decorations: [NSFileProviderItemDecorationIdentifier]? { [ entry.synced ? "iconSynced" : "", entry.inConflict ? "iconConflict" : "", entry.locked && !entry.uploadFailed ? "iconLocked" : "", entry.uploadFailed ? "iconUploadFailed" : "" ].filter { !$0.isEmpty }.map { NSFileProviderItemDecorationIdentifier(rawValue: "\(Bundle.main.bundleIdentifier!).\($0)") } } What I tried: Clear cache project and/or manually deleting Derived Data folder Various combination changes and log prints to try to figure out what's wrong Increasing Xcode project version Computer restart macOS: 12.6.5 (21G531) Does anyone have the same issue or does anyone have an idea on how to resolve this? So, my problem is that I can't get the new badge decorations added to plist file to work (to be shown in Finder when reported from decorations callback).
1
0
1.1k
Jul ’23
"Failed to connect to domain socket: Connection refused" Error
Hi, I maintain a cloud drive app which transitioned from SMB based mounting of cloud storage to File Provider. Our users on fresh installs of the app are fine, but users who updated from the SMB app are getting an error. I can see in the File Provider logs that the error is: "Failed to connect to domain socket: Connection refused". I can see in fileproviderctl listproviders that the provider does not load. Can anyone help me understand this error or what parts of the system to flush to reproduce the environment of a fresh install?
0
0
909
Jul ’23
How to open macOS FileProvider CloudStorage folder programmatically
I have an app with two targets: MainApp FileProvider Extension I would like to be able to open the FileProvider CloudStorage folder in Finder from within the MainApp. So far, I've only be able to achieve that by asking user to select his Home folder via NSOpenPanel, and then persisting security-scoped bookmark data, create symbolicLink in user's home folder and then later in the app: let aliasLocationURL = try URL(resolvingBookmarkData: aliasLocationBookmarkData,                             options: .withSecurityScope,                             relativeTo: nil, bookmarkDataIsStale: &isStale) aliasLocationURL.startAccessingSecurityScopedResource() NSWorkspace.shared.open(aliasURL) aliasLocationURL.stopAccessingSecurityScopedResource() The problem is that if user does not select his Home folder via NSOpenPanel then my app gets an error message: The application “MyApp” does not have permission to open “MyApp-FileProvider.” I can get the path to CloudStorage folder via: let fileProviderFolderURL = try await NSFileProviderManager(for: domain)?.getUserVisibleURL(for: .rootContainer) and it properly states that fileProviderFolderURL is /Users/me/Library/CloudStorage/MyApp-FileProvider but whenever I try to open that path, it results in error.
1
1
1.4k
Jul ’23
How to determine mimetype of .key and.numbers file ?
I need to correctly determine the mime type of keynote file and numbers file without relying on the extension. For this purpose, I am hoping to use the magic number concept and match it with the first four bytes of a file. Link for magic number understanding -> [https://www.outsystems.com/forge/component-overview/10108/validate-file-extension#:~:text=A%20magic%20number%20is%20a,types%20which%20is%20hexadecimal%20format.] Though after extensive searching online I am unable to find a unique magic number for the above files moreover first four bytes of the file is matching with the magic number of the zip file due to which I am getting the wrong extension as zip. This is the first four bytes 0x50, 0x4B, 0x3, 0x4. Is there any reliable way to find the mime type of these files without relying on an extension?
0
0
881
Jun ’23
How to prevent writing to file in macOS FileProviderExtension
I'm implementing FileProviderExtension on macOS (NSFileProviderReplicatedExtension) and one requirement I have to support is the support for locked files. My requirement is that writing to locked files should be forbidden. Is there a way to support that in FileProviderExtension? My approach was to report capabilities in FileProviderItem like: var capabilities: NSFileProviderItemCapabilities { if locked { return [.allowsReading, .allowsReparenting, .allowsDeleting] } return [.allowsReading, .allowsWriting, .allowsRenaming, .allowsReparenting, .allowsDeleting] } and indeed rename is forbidden (in Finder you cannot enter rename-state) but writing to file is allowed. Is there a way to prevent writing to file in macOS FileProviderExtension?
1
0
802
Jun ’23
file provider does not get loaded on addDomain
I have created working fileprovider, that works perfectly on my local machine. Codesigned in xcode, with our company sign certificate as Developer ID Application. No provisioning profile. Also notarized result dmg. Works as expected on my local machine. But won't load on any other machine. Calling [NSFileProviderManager addDomain: ...], ends up with error: Error Domain=NSFileProviderErrorDomain Code=-2001 "The application cannot be used right now." UserInfo={NSLocalizedDescription=The application cannot be used right now.} Code=-2001 should mean, that no file provider manager extension was found in an app bundle. I have made a TestFileProvider application that is totally simplified File Provider example. This too does work only on my own machine. Relevant code from app: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSFileProviderDomain* fileProviderDomain = [[NSFileProviderDomain alloc] initWithIdentifier:@"com.xxxxx.dwc.FileProvider" displayName:@"TestDomain"]; [NSFileProviderManager addDomain:fileProviderDomain completionHandler:^(NSError * _Nullable error) { if (error) NSLog(@"add domain: %@", error); else NSLog(@"add domain SUCCESS"); }]; } There are also these errors, that are related, but I do not understand what are they implying neither how to fix: kernel Sandbox: fileproviderd(448) deny(1) file-read-data /Applications/TestFileProvider.app fileproviderd [ERROR] PluginRecord doesn't have container url for fileproviderd [WARNING] No provider found with identifier (null) for calling bundle (null) on second attempt. I'm clueless on how to fix this. Is this related to codesign ? Or is it necessary to start fileprovider with different method call ?
Replies
4
Boosts
1
Views
4.1k
Activity
Sep ’23
How to inform the file provider about new changes in the remote storage properly
Currently, we are doing it by: Calling the function 'signalEnumerator' with the identifier as workingset Returning the metas of the new changes to the function enumerateChanges called by the file provider Sometimes, it would take more time to get the enumerateChanges function call from the file provider after invoking the signalEnumerator function. So, Kindly let us know if is there any other alternative to pass the new updated items information to the file provider properly and quickly.
Replies
1
Boosts
0
Views
691
Activity
Sep ’23
Unable to load FileProvider Extension
We are developing File Provider for macOS. We followed apple sample app, and are able to create a File Provider with Container app and an extension. We are able to get this working while building from Xcode. But the distributable build does not load the extension and fails with error "Application can not be loaded". We need help with understanding root cause of the issue, and exact entitlement that we can use for creating distributable builds.
Replies
0
Boosts
0
Views
561
Activity
Sep ’23
Feasibility and Privacy Concerns for App Monitoring and Blocking 3rd Party Apps on iOS
Hello, I am interested in developing an iOS app that can monitor the names of third-party applications running in parallel without collecting any user-specific data. I would like to inquire about the feasibility of implementing such functionality within the iOS ecosystem and if there are any privacy terms or restrictions that I need to be aware of to ensure compliance with Apple's policies. Additionally, I want to emphasize that the app will not collect any user-specific data but only the names of third-party apps for operational purposes. Thank you for your guidance.
Replies
0
Boosts
1
Views
576
Activity
Sep ’23
Can we able to have context menu activation logic in main app
We are implementing a file system extension using the file provider replicated extension for an application on Mac OS. On part of it, we need to show context menus for items(files/folders) inside the file provider's mounted folder. But we don't want to show the context menu based on the 'activation rule' key's value declared on each NSExtensionFileProviderActions item in the info.plist file but with the main app's code logic. Because if we use the info.plist activation rule, we need to use each item's instance variables as part of predicate query(which decides on showing the context menu item), and after performing the action, we need to change the value of that instance variable so that we can show opposite context menu of the previous one (for example if previously 'set offline' is clicked, now 'set online' have to be shown) but doing this is tedious process. Also, we already implemented the code logic in our main app(that is not written in swift) to choose what are the context menu items to be shown and so we want to use it. So, Instead, we are hoping to do it either: By handling the get-menu function call or By handling the predicate checking function call. Kindly let us know if is there any function we can override or inform the system to do at least any one of the above things. Thanks in advance.
Replies
0
Boosts
0
Views
721
Activity
Sep ’23
Is it possible to get the context menu functionality of Finder Sync Extension in File Provider?
Previously, we are using the Finder Sync extension for showing the context menu on the finder items. But now we are planning to use the File Provider extension on Mac OS. So, as of our learning, we found that the context menu items to be shown on the finder items have to be informed using the 'NSExtensionFileProviderActions' key in the info.plist file and the activation rule also have to be informed there under key 'NSExtensionFileProviderActionActivationRule'. But in the Finder Sync, we can get both the right-click(to list menu) and menu item clicked(on the context menu shown) calls from the Finder Sync extension. Like Finder Sync Extension, can we able to get both the calls from the file provider extension?​
Replies
0
Boosts
0
Views
686
Activity
Sep ’23
How to delete data in the stock iOS "Files" app from an external app?
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.
Replies
0
Boosts
0
Views
540
Activity
Aug ’23
Error using file importer in SwiftUI app in combination with Firebase Storage
Trying to use file importer in a swift app to upload documents into firebase Storage and getting error when running on live device but works perfectly fine on emulator. error: BackgroundSession <***...> Failed to issue sandbox extension for file file:///private/var/mobile/Library/Mobile%20Documents/comappleCloudDocs/Sample.pdf, errno = [1: Operation not permitted] UNKNOWN ERROR Error Domain=FIRStorageErrorDomain Code=-13000 "An unknown error occurred, please check the server response." UserInfo={object=Repository/Sample.pdf, ResponseBody=Can not finalize upload. Current size is 0. Expected final size is 2665098., bucket=bucket, data={length = 77, bytes = 0x43616e20 6e6f7420 66696e61 6c697a65 ... 32363635 3039382e }, data_content_type=text/plain; charset=utf-8, NSLocalizedDescription=An unknown error occurred, please check the server response., ResponseErrorDomain=com.google.HTTPStatus, ResponseErrorCode=400} I tried separating all the logic from selectedFile.startAccessingSecurityScopedResource() all the way through the end into a function of its own using @MainActor based on another post I found around here and issue persisted.. Below is the implementation: .fileImporter( isPresented: $fileImporterIsPresented, allowedContentTypes: [.pdf], allowsMultipleSelection: false ) { result in switch result { case .success(let url): print(url) guard let selectedFile:URL = url.first else { return } guard selectedFile.startAccessingSecurityScopedResource() else { return } let firebaseRepository = Storage.storage().reference().child("Repository/Sample.pdf") let uploadTask = firebaseRepository.putFile(from: selectedFile) uploadTask.observe(.progress) { snapshot in // Upload reported progress percentComplete = 100.0 * Double(snapshot.progress!.completedUnitCount) / Double(snapshot.progress!.totalUnitCount) } uploadTask.observe(.success) { snapshot in selectedFile.stopAccessingSecurityScopedResource() uploadTask.removeAllObservers() print("SUCCESS") // Upload completed successfully } uploadTask.observe(.failure) { snapshot in if let error = snapshot.error as? NSError { switch (StorageErrorCode(rawValue: error.code)!) { case .objectNotFound: print("NOT FOUND") // File doesn't exist break case .unauthorized: print("UNAUTHORIZED") // User doesn't have permission to access file break case .cancelled: print("CANCELLED") // User canceled the upload break /* ... */ case .unknown: print("UNKNOWN ERROR \(error.description)") print("UNKNOWN ERROR \(error.localizedDescription)") print("UNKNOWN ERROR \(error.underlyingErrors)") // Unknown error occurred, inspect the server response break default: print("UNSPECIFIED ERROR") // A separate error occurred. This is a good place to retry the upload. break } } } case .failure(let error): print(error) } }
Replies
1
Boosts
0
Views
2.1k
Activity
Aug ’23
File Provider UI extension on macOS
I'm asking this because the documentation is totally contradicting to itself on multiple occasions: Extensions overview page (https://developer.apple.com/app-extensions/) claims it's not supported. At the same time, on FileProviderUI docs page (https://developer.apple.com/documentation/fileproviderui) macOS is listed among another platforms and docs kinda generally suggest it is supported. At the same time, "add new target" dialog in xcode is missing "File Provider UI Extension" template under macOS. At the same time, it's can be easily be done by creating an iOS extension, then swapping SDK to macOS and UIKit APIs to their AppKit counterparts. This way, FileProviderUI actions DO appear in Finder. Problem is, after clicking the action, UI never appears and here's what i see in Console: default pkd Waiting on thread <private> until Launch Services database seeding is complete. default Finder [d <private>] <PKHost:0x600000c38cc0> Beginning discovery for flags: 1024, point: (null) default Finder [d <private>] <PKHost:0x600000c38cc0> Completed discovery. Final # of matches: 0 error Finder nil extension for provider ID (<private>), error: (null) error Finder Action with identifier (<private>) did finish with error (Error Domain=FPUIActionViewControllerErrorDomain Code=1000). error Finder FP Custom action sheet finished with error Error Domain=FPUIActionViewControllerErrorDomain Code=1000 "(null)" default pkd [d <private>] Final plugin count: 0 This is totally confusing, please elaborate.
Replies
1
Boosts
0
Views
1.2k
Activity
Aug ’23
-com.apple.CoreData.ConcurrencyDebug 1 not working in FileProvider extensions
I discovered a multithreading mistake in my use of NSManagedObjects recently and was surprised that I wasn't alerted to this during development, since I had -com.apple.CoreData.ConcurrencyDebug 1 set under "arguments passed on launch" for my macOS and iOS FileProvider extensions. I confirmed that the expected log stating CoreData: annotation: Core Data multi-threading assertions enabled. is NOT present when running these targets (but does appear as expected on my main macOS and iOS applications). Can anyone advise me on how to get this concurrency debugging functionality to work on my FileProvider extension(s)? Thanks
Replies
1
Boosts
1
Views
997
Activity
Aug ’23
Unable to Add Default badges to File Icons in File Provider
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.
Replies
0
Boosts
0
Views
710
Activity
Aug ’23
Can we have Finder Sync Extension on File Provider (Cloud Storage) Path macOS
The existing project of Finder Extension is doing an amazing job in other paths but when I point it to the CloudStorage path the context menu doesn't show up. And no trace of what is going wrong any where (Xcode Logs, Console log, crash log, etc.) Path Used: /Users/<User>/Library/CloudStorage/FP-SomeDomains Yes, even my first though was, it must be because of dataless file and folders. But unfortunately it not. There was no context menu presented from my Finder Extension even on real physical files and folders.
Replies
3
Boosts
1
Views
2.3k
Activity
Aug ’23
FileProviderReplicatedExtension’s modifyItem called immediately following fetchContents’ completion for updates from remote
Hi there, The first time an item is materialized (via fetchContents), the contents are downloaded and we set the contentVersion (to a hash of the content) - no problems here. Once a content change is made remotely, we enumerateChanges and change the contentVersion to ”empty” (Data()). This triggers fetchContents to be called (where we fetch the new content). As soon as we call the completion handler for fetchContents though (now with a new contentVersion (a hash of the new content), we get a call immediately after to modifyContents, with the same contents that we just fetched. This call to modifyContent seems like a bug. how can I prevent it from being called by the system? Thanks for the help!
Replies
6
Boosts
0
Views
853
Activity
Jul ’23
UISupportsDocumentBrowser - App’s default save location in Settings
Hi. By setting UISupportsDocumentBrowser to true in my app's Info.plist file, I can see this Setting option that allows the user to select the default save location for my app: How can I access the value that the user has set here?
Replies
0
Boosts
0
Views
694
Activity
Jul ’23
How do we partially load files in chunks from a remote server.
I've been building a finder extension for managing a bunch of videos in a remote server. When I try to click on a video file that is dataless it seems to always trigger fetchContents(for:version:request:completionHandler:). I have implemented fetchPartialContents(for:version:request:minimalRange:aligningTo:options:completionHandler:) but i haven't been able to trigger this method no matter how large the size of the file is. What are the conditions that i have to meet to trigger this function so i could stream the video data in chunks ?
Replies
1
Boosts
0
Views
1.2k
Activity
Jul ’23
How to add new NSFileProviderDecorations to FileProviderExtensions
I'm having an issue where adding new decorations to NSFileProviderDecorations doesn't make those decorations visible in the app. Here is my NSFileProviderDecorations array in plist file: <key>NSFileProviderDecorations</key> <array> <dict> <key>BadgeImageType</key> <string>com.apple.icon-decoration.badge.checkmark</string> <key>Category</key> <string>Badge</string> <key>Identifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER).iconSynced</string> <key>Label</key> <string>Synced</string> </dict> <dict> <key>BadgeImageType</key> <string>com.apple.icon-decoration.badge.warning</string> <key>Category</key> <string>Badge</string> <key>Identifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER).iconConflict</string> <key>Label</key> <string>In Conflict</string> </dict> <dict> <key>BadgeImageType</key> <string>com.apple.icon-decoration.badge.locked</string> <key>Category</key> <string>Badge</string> <key>Identifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER).iconLocked</string> <key>Label</key> <string>Locked</string> </dict> <dict> <key>BadgeImageType</key> <string>com.apple.icon-decoration.badge.warning</string> <key>Category</key> <string>Badge</string> <key>Identifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER).iconUploadFailed</string> <key>Label</key> <string>Upload failed</string> </dict> </array> The first two decorations: iconSynced and iconConflict work just fine as expected, but then I added the other two decorations: iconLocked and iconUploadFailed and I just can't get them to work. Here is an example of my decorations implementation: var decorations: [NSFileProviderItemDecorationIdentifier]? { [ entry.synced ? "iconSynced" : "", entry.inConflict ? "iconConflict" : "", entry.locked && !entry.uploadFailed ? "iconLocked" : "", entry.uploadFailed ? "iconUploadFailed" : "" ].filter { !$0.isEmpty }.map { NSFileProviderItemDecorationIdentifier(rawValue: "\(Bundle.main.bundleIdentifier!).\($0)") } } What I tried: Clear cache project and/or manually deleting Derived Data folder Various combination changes and log prints to try to figure out what's wrong Increasing Xcode project version Computer restart macOS: 12.6.5 (21G531) Does anyone have the same issue or does anyone have an idea on how to resolve this? So, my problem is that I can't get the new badge decorations added to plist file to work (to be shown in Finder when reported from decorations callback).
Replies
1
Boosts
0
Views
1.1k
Activity
Jul ’23
"Failed to connect to domain socket: Connection refused" Error
Hi, I maintain a cloud drive app which transitioned from SMB based mounting of cloud storage to File Provider. Our users on fresh installs of the app are fine, but users who updated from the SMB app are getting an error. I can see in the File Provider logs that the error is: "Failed to connect to domain socket: Connection refused". I can see in fileproviderctl listproviders that the provider does not load. Can anyone help me understand this error or what parts of the system to flush to reproduce the environment of a fresh install?
Replies
0
Boosts
0
Views
909
Activity
Jul ’23
How to open macOS FileProvider CloudStorage folder programmatically
I have an app with two targets: MainApp FileProvider Extension I would like to be able to open the FileProvider CloudStorage folder in Finder from within the MainApp. So far, I've only be able to achieve that by asking user to select his Home folder via NSOpenPanel, and then persisting security-scoped bookmark data, create symbolicLink in user's home folder and then later in the app: let aliasLocationURL = try URL(resolvingBookmarkData: aliasLocationBookmarkData,                             options: .withSecurityScope,                             relativeTo: nil, bookmarkDataIsStale: &isStale) aliasLocationURL.startAccessingSecurityScopedResource() NSWorkspace.shared.open(aliasURL) aliasLocationURL.stopAccessingSecurityScopedResource() The problem is that if user does not select his Home folder via NSOpenPanel then my app gets an error message: The application “MyApp” does not have permission to open “MyApp-FileProvider.” I can get the path to CloudStorage folder via: let fileProviderFolderURL = try await NSFileProviderManager(for: domain)?.getUserVisibleURL(for: .rootContainer) and it properly states that fileProviderFolderURL is /Users/me/Library/CloudStorage/MyApp-FileProvider but whenever I try to open that path, it results in error.
Replies
1
Boosts
1
Views
1.4k
Activity
Jul ’23
How to determine mimetype of .key and.numbers file ?
I need to correctly determine the mime type of keynote file and numbers file without relying on the extension. For this purpose, I am hoping to use the magic number concept and match it with the first four bytes of a file. Link for magic number understanding -> [https://www.outsystems.com/forge/component-overview/10108/validate-file-extension#:~:text=A%20magic%20number%20is%20a,types%20which%20is%20hexadecimal%20format.] Though after extensive searching online I am unable to find a unique magic number for the above files moreover first four bytes of the file is matching with the magic number of the zip file due to which I am getting the wrong extension as zip. This is the first four bytes 0x50, 0x4B, 0x3, 0x4. Is there any reliable way to find the mime type of these files without relying on an extension?
Replies
0
Boosts
0
Views
881
Activity
Jun ’23
How to prevent writing to file in macOS FileProviderExtension
I'm implementing FileProviderExtension on macOS (NSFileProviderReplicatedExtension) and one requirement I have to support is the support for locked files. My requirement is that writing to locked files should be forbidden. Is there a way to support that in FileProviderExtension? My approach was to report capabilities in FileProviderItem like: var capabilities: NSFileProviderItemCapabilities { if locked { return [.allowsReading, .allowsReparenting, .allowsDeleting] } return [.allowsReading, .allowsWriting, .allowsRenaming, .allowsReparenting, .allowsDeleting] } and indeed rename is forbidden (in Finder you cannot enter rename-state) but writing to file is allowed. Is there a way to prevent writing to file in macOS FileProviderExtension?
Replies
1
Boosts
0
Views
802
Activity
Jun ’23