url(forUbiquityContainerIdentifier) 返回 nil

MEn*_*bah 5 objective-c ios icloud swift swift3

我正在尝试获取我的容器 ID 的 url,但该方法不断返回nil

我做了以下事情:

  • 在 Xcode 功能中启用 iCloud 键值存储。
  • 在物理设备上进行测试。
  • iCloud 和 iCloud Drive 在物理设备中打开。
  • 确保将其iCloud Key-Value Store添加到权利文件中。

我的代码是:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    //Override point for customization after application launch.

    let cloudURL = FileManager.default.url(forUbiquityContainerIdentifier: nil)
    print(cloudURL as Any)

    return false
}
Run Code Online (Sandbox Code Playgroud)

我已经查找了几乎所有与此问题相关的问题并尝试了答案,但它不起作用。

War*_*ger 6

对于 Xcode 9.2,检查此选项有效:在此输入图像描述