无法在 Swift 2 框架中访问 info.plist

Can't access info.plist in Swift 2 framework

无论我做什么,我似乎都无法访问框架文件夹根目录中的 Info.plist 文件。到目前为止,我的代码如下所示:

    private var Config: NSDictionary {
    get {
        if let config = NSBundle.mainBundle().pathForResource("Info", ofType: "plist") {
            return NSDictionary(contentsOfFile: config)!
        }
        return Dictionary<String, AnyObject>()
    }
}

此 returns 为空 Dictionary,因为 if let config 语句未通过。我也试过:

    private var Config: NSDictionary {
    get {
        if let config = NSBundle.mainBundle().infoDictionary {
            return NSDictionary(contentsOfFile: config as! String)!
        }
        return Dictionary<String, AnyObject>()
    }
}

这次if let语句通过了,但是是空白Dictionary(0key/value对)。

我正在使用 Xcode 7.2.1。帮助 iOS 新手!提前致谢。 :)

已解决!

在做了更多研究之后,我发现访问 plist 或一般的资源对于框架来说是不同的。所以,我尝试了:

            if let config = NSBundle(identifier: "Smoo.Framework")?.infoDictionary {
            return NSDictionary(dictionary: config["Key"] as! NSDictionary)
        }

("Smoo.Framework" 是我需要的 plist 所在的包的名称)

这很有效!结案。 :)