如何判断您的应用是否正在使用iCloud架构开发或生产

时间:2017-12-21 19:13:09

标签: ios macos cocoa-touch cloudkit

如果我的iCloud容器连接到开发或生产架构,我如何在运行时检查?

1 个答案:

答案 0 :(得分:1)

当通过模拟器运行时,这对我有用:

    let path = "<pathToProjectDirectory>/<projectName>.entitlements"

    guard let data = FileManager.default.contents(atPath: path) else { return }

    do {
        let dict = try PropertyListSerialization.propertyList(from: data, options: .mutableContainersAndLeaves, format: nil) as! [String : Any]
        print( "container-environment: \(dict["com.apple.developer.icloud-container-environment"] ?? "no key")" )
    }
    catch {
        // error
    }