I wanted to implement the in-app version for my app, but I don't understand why is not working? The output showing i was added successfully, but when i open the pList file from my Xcode, its not changing? Why is it? Here is my code:
func version(){
let urlString = jocomAPIKey + "/feed/version"
let CFBundleShortVersionKey = "CFBundleVersion"
//First get the nsObject by defining as an optional anyObject
let nsObject: AnyObject? = NSBundle.mainBundle().infoDictionary!["CFBundleVersion"]
let version = nsObject as! String
print("app version: \(version)")
Alamofire.request(.POST, urlString , parameters: ["os" : "iphone"])
.responseData { response in
let versionXML = SWXMLHash.parse(response.data!)
let versionString = (versionXML["rss"]["channel"]["item"]["version"].element?.text)
print("version string: \(versionString)")
if let plist = Plist(name: "Info") {
let dict = plist.getMutablePlistFile()!
dict[CFBundleShortVersionKey] = versionString
//3
do {
try plist.addValuesToPlistFile(dict)
print("added")
} catch {
print(error)
}
//4
print(plist.getValuesInPlistFile())
} else {
print("Unable to get Plist")
}
}
}