Ios 为什么我的应用程序未显示在iCloud驱动器文件夹中
iCloud Drive文件夹不显示我的应用程序文件夹 这是我将文件发送到iCloud驱动器的方式:Ios 为什么我的应用程序未显示在iCloud驱动器文件夹中,ios,icloud,icloud-drive,Ios,Icloud,Icloud Drive,iCloud Drive文件夹不显示我的应用程序文件夹 这是我将文件发送到iCloud驱动器的方式: - (IBAction)btnStoreTapped:(id)sender { // Let's get the root directory for storing the file on iCloud Drive [self rootDirectoryForICloud:^(NSURL *ubiquityURL) { NSLog(@"1. ubiquityUR
- (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. ubiquityURL = %@", ubiquityURL);
// And finish up the 'store' action
NSError *error;
if (![[NSFileManager defaultManager] setUbiquitous:YES itemAtURL:localURL destinationURL:ubiquityURL error:&error]) {
NSLog(@"Error occurred: %@", error);
}else{
NSLog(@"Succeed");
}
}
else {
NSLog(@"Could not retrieve a ubiquityURL");
}
}];
}
- (void)rootDirectoryForICloud:(void (^)(NSURL *))completionHandler {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSURL *rootDirectory = [[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]URLByAppendingPathComponent:@"Documents"];
if (rootDirectory) {
if (![[NSFileManager defaultManager] fileExistsAtPath:rootDirectory.path isDirectory:nil]) {
NSLog(@"Create directory");
[[NSFileManager defaultManager] createDirectoryAtURL:rootDirectory withIntermediateDirectories:YES attributes:nil error:nil];
}
}
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(rootDirectory);
});
});
}
- (NSURL *)localPathForResource:(NSString *)resource ofType:(NSString *)type {
NSString *documentsDirectory = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
NSString *resourcePath = [[documentsDirectory stringByAppendingPathComponent:resource] stringByAppendingPathExtension:type];
return [NSURL fileURLWithPath:resourcePath];
}
事实上,我做了所有解释
一切看起来都很好。我可以成功上传文件,并通过终端在我的电脑上显示它们
我可以看到我刚从iphone上传的文件
但我的mac或iCloud.com中的iCloud驱动器文件夹中没有显示任何内容。为什么他们不显示我的应用程序的文件夹,即使一切看起来都很好,没有错误
但我的mac或iCloud.com中的iCloud驱动器文件夹中没有显示任何内容。
为什么他们不显示我的应用程序文件夹,即使一切看起来都像
好的,没有错误吗
这是新的应用程序还是新创建的iCloud容器?
那么原因是:NSUbiquitousContainerIsDocumentScopePublic=true仅在应用程序(以及有权使用的iCloud容器)通过审查和批准后生效
我不记得我在哪里读到了“丢失的信息”(至少我没有从苹果的文档中得到它)
我的经验中的另一个例子似乎证明了这一点:在现有的应用程序中(使用“old style-TeamIdentifierPrefix”iCloud容器),我可以使该容器在iCloud drive上可见。但在iCloud Drive中,“公众”看不到一个新的容器(即使很难,我也可以在Mac上使用Terminal.app看到)。一旦应用程序(带有新容器)获得批准并在AppStore上可用,您就可以再次使用Info.plist(并使新容器可见/隐藏,…)这是现有应用程序中唯一对我有效的东西(我有完全相同的问题)(因此我无法更改捆绑ID)是在
URLForUbiquityContainerIdentifier
文件夹下创建一个Documents
子文件夹,并在那里写入我的所有文件
一旦我这么做了,它们就出现在我的Mac上的Finder中。但是,它们没有出现在iCloud Drive中我的应用程序文件夹的
文档
子文件夹中,它们直接出现在应用程序文件夹中。我在swift中尝试了相同的代码,但遇到了相同的问题
这就是我的工作原理:
1) 在info.plist源代码中找到以下行
<key>CFBundleVersion</key>
<string>1</string>
CFBundleVersion
1.
2) 增加版本号。如果是1,则将其增加到2。无论版本号是什么,都要这样做
3) 如果需要,请从您的设备卸载应用程序,并在执行上述两个步骤后重新运行
对我来说,它忘记了在应用程序的
info.plist
中为新容器添加上述条目。我似乎反驳了你的说法,即“NSUbiquitousContainerIsDocumentScopePublic=true只在应用程序(以及标题为iCloud的容器)通过审查和批准后生效”。对于现有的应用商店应用程序,plist中没有NSUbiquitousContainers键。我添加了NSUbiquitousContainerIsDocumentScopePublic=true,并在未提交应用商店的情况下升级了CbundLeverVersion,ubiquity容器在iCloud Drive iOS应用程序中可见,并且在登录到同一iCloud帐户的OS X系统上可见(我甚至没有同步文件)。我同意@Michael Rourke。它与应用商店没有任何关系。对我来说,解决这个问题的方法是根据获得一个新的应用程序ID。我的应用尚未在应用商店中。在首次运行应用程序之前,您需要在Info.plist中设置NSUbiquitousContainerIsDocumentScopePublic=true。我也遇到过同样的问题。我的应用已经在应用商店中运行,因此我无法让应用文件夹在iCloud驱动器中可见。我甚至卸载并重新安装了应用程序,但它没有显示。您是一位学者:)。如果创建非默认容器,则需要在其中创建Documents文件夹。该文档文件夹不会向最终用户显示,但该文件夹内的内容会显示。:)这昨晚奏效了。但现在,应用文件夹不再显示在iCloud Drive中…:(