iCloud Drive Folder不显示我的应用程序的文件夹.
这是我将文件发送到iCloud Drive的方式:
- (IBAction)btnStoreTapped:(id)sender {
// Let's get the root directory for storing the file on iCloud Drive
[self rootDirectoryForICloud:^(NSURL *ubiquityURL) {
NSLog(@"1. ubiquityURL = %@", ubiquityURL);
if (ubiquityURL) {
// We also need the 'local' URL to the file we want to store
//NSURL *localURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Photo" ofType:@"pdf"]];
NSURL *localURL = [self localPathForResource:@"document" ofType:@"doc"];
NSLog(@"2. localURL = %@", localURL);
// Now, append the local filename to the ubiquityURL
ubiquityURL = [ubiquityURL URLByAppendingPathComponent:localURL.lastPathComponent];
NSLog(@"3. …Run Code Online (Sandbox Code Playgroud) 有没有办法从iCloud Drive中选择类似的文件UIImagePickerController()?
我正在研究iOS App上的文件共享,我是新手UIDocumentPickerViewController.我不知道为什么我的应用程序崩溃了.
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.image"] inMode:UIDocumentPickerModeImport];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
应用程序在突出显示的行上崩溃.
有没有人以前做过这个?我想像下面的附件一样做
我正在尝试将文件保存到 icloud 驱动器。我要使用简单版本,不让用户选择保存文件的位置,我只是将其保存在 icloud 驱动器的根目录中。这是我正在使用的代码:
func exportToFiles() {
for page in pages {
let filename = getDocumentsDirectory().appendingPathComponent((page.title ?? "Untitled") + ".png")
if let image = exportImage(page: page, dpi: 300) {
if let data = image.pngData() {
try? data.write(to: filename)
}
}
}
}
func getDocumentsDirectory() -> URL {
let driveURL = FileManager.default.url(forUbiquityContainerIdentifier: nil)?.appendingPathComponent("Documents")
return driveURL!
}
Run Code Online (Sandbox Code Playgroud)
我的文件中有这个Info.plist:
<key>NSUbiquitousContainers</key>
<dict>
<key>iCloud.com.mysite.myapp</key>
<dict>
<key>NSUbiquitousContainerIsDocumentScopePublic</key>
<true/>
<key>NSUbiquitousContainerName</key>
<string>myapp</string>
<key>NSUbiquitousContainerSupportedFolderLevels</key>
<string>Any</string>
</dict>
</dict>
Run Code Online (Sandbox Code Playgroud)
在用户界面中,它看起来像是有效的,因为在我点击按钮后有轻微的停顿。但当我查看我的文件时,什么也没有。我究竟做错了什么?
我已经尝试了两天多来写一个文件到iCloud驱动器.我尝试直接编写一个简单的文本文件,然后在本地移动它,使用UIDocumentMenuViewController等.我没有得到任何错误的代码和单步执行调试器,它看起来很成功,但当我检查文件是否存在或至少iCloud目录,那里什么都没有.我尝试了模拟器和我的iPhone,触发了iCloud同步,以及我能想到的其他一切.
我的主要目标是简单地将文本文件写入iCloud驱动器,后来将成为"数字"文件
我已经设置了我的plist文件和我的权利:
<key>NSUbiquitousContainers</key>
<dict>
<key>iCloud.com.paul.c.$(PRODUCT_NAME:rfc1034identifier)</key>
<dict>
<key>NSUbiquitousContainerIsDocumentScopePublic</key>
<true/>
<key>NSUbiquitousContainerName</key>
<string>myCloudTest</string>
<key>NSUbiquitousContainerSupportedFolderLevels</key>
<string>Any</string>
</dict>
</dict>
Run Code Online (Sandbox Code Playgroud)
我还提到了捆绑版本,如下所述:将iOS 8文档保存到iCloud Drive
我已经尝试了几十个没有运气的教程.我的最新代码基于此示例:https://medium.com/ios-os-x-development/icloud-drive-documents-1a46b5706fe1
这是我的代码:
@IBAction func ExportFile(sender: AnyObject) {
var error:NSError?
let iCloudDocumentsURL = NSFileManager.defaultManager().URLForUbiquityContainerIdentifier(nil)?.URLByAppendingPathComponent("myCloudTest")
//is iCloud working?
if iCloudDocumentsURL != nil {
//Create the Directory if it doesn't exist
if (!NSFileManager.defaultManager().fileExistsAtPath(iCloudDocumentsURL!.path!, isDirectory: nil)) {
//This gets skipped after initial run saying directory exists, but still don't see it on iCloud
NSFileManager.defaultManager().createDirectoryAtURL(iCloudDocumentsURL!, withIntermediateDirectories: true, attributes: nil, error: nil)
}
} …Run Code Online (Sandbox Code Playgroud) 我UIDocumentPickerViewController用来让用户从iCloud Drive中选择一个文件上传到后端.
大多数时候,它工作正常.但是,有时(特别是当互联网连接不稳定时)documentPicker:didPickDocumentAtURL:会给出一个文件系统上实际不存在的URL,并且任何使用它的尝试都会返回NSError"No such file or directory".
处理这个问题的正确方法是什么?我正在考虑使用NSFileManager fileExistsAtPath:并告诉用户如果不存在则再试一次.但这听起来不是非常用户友好.有没有办法从iCloud Drive获得真正的错误原因,也许告诉iCloud Drive再试一次?
代码的相关部分:
@IBAction func add(sender: UIBarButtonItem) {
let documentMenu = UIDocumentMenuViewController(
documentTypes: [kUTTypeImage as String],
inMode: .Import)
documentMenu.delegate = self
documentMenu.popoverPresentationController?.barButtonItem = sender
presentViewController(documentMenu, animated: true, completion: nil)
}
func documentMenu(documentMenu: UIDocumentMenuViewController, didPickDocumentPicker documentPicker: UIDocumentPickerViewController) {
documentPicker.delegate = self
documentPicker.popoverPresentationController?.sourceView = self.view
presentViewController(documentPicker, animated: true, completion: nil)
}
func documentPicker(controller: UIDocumentPickerViewController, didPickDocumentAtURL url: NSURL) {
print("original URL", url)
url.startAccessingSecurityScopedResource()
var error: NSError?
NSFileCoordinator().coordinateReadingItemAtURL(
url, …Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序中选择文档(pdf,doc,docx).我想为此整合iCloud.我想做的就是从我的应用程序打开iCloud驱动器,用户可以选择该文件并返回原始应用程序.类似whatsapp的东西已经在iOS应用程序中进行了文档选择.
对此有何想法?
关于我的设置的一些话:
MacOs Catalina 10.15.2
谈论git我桌面上的项目文件夹,它与 iCloud Drive 同步桌面和文档文件夹选项已启用
我注意到以下情况时不时发生一段时间。昨天,我将 MacBook Pro 备份到了MacOs Catalina 10.15.2,这似乎加剧了我在git初始化的项目文件夹中注意到的以下特性:
很多时候,当我deleted files从我local worktree那里开始时,它们随机开始重新出现在工作树中(有时甚至一天或更长时间后)作为untracked files.
其次,很经常地,我现有的文件似乎突然出现duplicated- 它们的副本带有数字后缀,例如文件 foo 突然出现foo 2,而文件 bar 出现bar 6. 然后它们也出现在git statusas 中untracked files。
工作树索引中出现重复项的示例
我还在.git文件夹内观察到了这种行为。
.git 文件夹中出现重复项的示例
* 编辑:值得注意的是,<filename> 2重复似乎源于上一次,有时甚至是一个月前(参见上面 .git 文件夹截图中的“配置 2”)。我还注意到(但我提供的图片上没有显示)有时数字后缀是一个随机的“6”,例如没有数字后缀序列(例如 1-5)导致重复的文件名与数字 6 .
我时不时地观察到这种情况发生,但今天它无处不在。可能是这个问题特别出现在我做一些git诸如此类的操作时git commit git reset。
我的假设是,这一定与.git不能很好地使用 …
我为我的iOS应用程序开发了一个iCloud Drive Export功能,它可以工作.我可以在Mac OS X 10.11上的iCloud Drive文件夹中的公共AppContainerFolder中看到导出的文档.
但在iOS上,我只能在iCloud Drive应用程序中看到AppContainerFolder.它被禁用,我无法打开该文件夹,或看到里面的文件.
从iCloud Drive设置中,我可以看到我导出的文件位于iCloud Drive中的AppContainerFolder中.
iCloud设置中的AppContainerFolder图像
iCloud Drive有没有人遇到过这样的问题?
我在我的应用程序中使用了两个app容器,一个用于导出的"iCloud.com ..."标识符,另一个用于Ensembles-CoreData同步的"TeamIdentifier.com ..."标识符.我使用以下方法明确使用容器的URL:
[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:@"iCloud.com..."]
Run Code Online (Sandbox Code Playgroud)
我已经尝试过只使用TeamIdentifier-Container,但AppContainerFolder的可见性没有变化.
我试图碰到BundleVersion,我玩了Info.plist NSUbiquitousContainers设置.我还通过TestFlight向外部测试人员提供Build,以查看它是否与开发设备有关.
我还没有做过唯一的事情,就是用一个新的BundleVersion向AppStore发布一个新版本,看它是否与高效的应用程序和开发中的应用程序有关.
任何提示和提示欢迎.
我有几台 Mac,我在上面克隆了相当数量的 git(主要是 GitHub)存储库。每个 Mac 都有许多 iCloud 驱动器同步目录(实际上我已经全力以赴,正在同步Desktop和Documents)。
我试图克隆到 iCloud 同步目录。但是,我在这方面遇到了很多问题。似乎很容易陷入 iCloud(而不是 git)变得如此困惑以至于一台机器有效停止同步的情况,即使是与克隆目录无关的文件,即使我小心地重新同步两个克隆中的每一个到完全相同的状态。我不知道问题是.git/在实际 repo 文件的版本之间存在竞争条件还是类似竞争条件的问题。
我尝试在 brctl 下使用 Apple 的各种 iCloud 日志记录工具,但这通常没有帮助。
有没有其他人看过这个或类似的东西?
(这与这个问题有些不同,这个问题似乎主要关心带有 iCloud 驱动器的单个 Mac,我认为在这种情况下的用户不会看到与我相同的问题。)
icloud-drive ×10
icloud ×7
ios ×7
swift ×3
git ×2
objective-c ×2
iphone ×1
macos ×1
uidocument ×1
uti ×1
xcode ×1