Closed crutchcorn closed 3 years ago
I'm literally getting stuck on the first part of this 😅
When trying to run the following:
@objc(createFolder:folderName:)
public func createFolder(_ path: String, folderName: String) {
let url = URL(fileURLWithPath: path);
guard url.startAccessingSecurityScopedResource() else {
print("THERE WAS A FAILURE HERE")
return
}
defer { url.stopAccessingSecurityScopedResource() }
let fileManager = FileManager.default
let filePath = url.appendingPathComponent("\(folderName)")
do {
try fileManager.createDirectory(atPath: filePath.path, withIntermediateDirectories: true, attributes: nil)
} catch {
print(error.localizedDescription)
}
}
From JS:
NativeModules.DirectoryPicker.pickFolder().then((val: string[]) => {
NativeModules.DirectoryPicker.createFolder(val[0], 'test2');
});
I'm hitting the THERE WAS A FAILURE HERE
message, indicating that my read/write permission to use this folder has been denied
Fixed via 18543d87339269997ff4d663d6a96028a27c0a4f
Currently, even on the
ios-directory-picker
branch, I'm unable to clone due to FS access issues.This is because we're trying to export our files to a new directory:
However, Apple Docs make it clear that you must "request access" every time you want to read or write a file.
Further, we'd like to see if we're able to use
SwiftGit2
bindings in order to do theclone
action on iOS. So, we're going to be doing the following steps, in order, and returning the results here:[ ] Try to get native code to write a file to an external directory (following the guide and calling that native code in JS
[ ] Test to see if we can use an "unlock" directory native code, then use the existing FS code, then "locking" the FS again once done
[ ] Testing
SwiftGit2
onappDirectory
(so we can initially avoid permissions)[ ] If the second idea of "lock, then unlock" with JS FS works, then let's test if that will work for
SwiftGit2
My suspicion warns me that the "lock/unlock" pattern won't actually work, but boy it would be grand if it did