Reputation: 2717
I am creating an iOS - framework (swift) I have this function - which I am using for retrieving a dictionary that should hold all of the lib properties (strings)
func getPropertyList() -> [String: Any]?{
let path = Bundle.main.path(forResource: "properties", ofType: "plist")!
let dict = NSDictionary(contentsOfFile: path) as? [String: Any]
return dict
}
from test this line keep returning nil
Bundle.main.path(forResource: "properties", ofType: "plist")!
even though the properties.plist file is inside the 'copy Bundle Resources' and the target membership is selected
Upvotes: 1
Views: 405
Reputation: 100503
Use
let path = Bundle(identifier:"com.example.frameworkID")!.path(forResource: "properties", ofType: "plist")!
Upvotes: 3