plist couldn’t be copied

Hi


When I try to copy my Plist on the Apple TV ( real device) I get:- plist” couldn’t be copied because you don’t have permission to access “Documents”


Works on the Apple TV emulator

Works on the other target i.e iPhone/iPad air etc


Has something changed ?




Any advice would be great

Replies

it's really strange... i'm running into the same problem... 😟


did you figure it out?

Hi Choo


I had to use standardUserDefaults instead:-


func loadMenuSettings()

{

pListDictionary = loadPlistFile("datalist.plist")

print(pListDictionary.description)

tickHelp = pListDictionary.objectForKey("help") as! Bool

tickMute = pListDictionary.objectForKey("mute") as! Bool

tickMusic = pListDictionary.objectForKey("music") as! Bool

hiScore = pListDictionary.objectForKey("hiscore") as! Int

firstEntry = pListDictionary.objectForKey("firstentry") as! Bool

helpcount = pListDictionary.objectForKey("helpcount") as! Int

#if os(tvOS)

if let isValid = NSUserDefaults.standardUserDefaults().objectForKey("help")

{

tickHelp = NSUserDefaults.standardUserDefaults().objectForKey("help") as! Bool

tickMute = NSUserDefaults.standardUserDefaults().objectForKey("mute") as! Bool

tickMusic = NSUserDefaults.standardUserDefaults().objectForKey("music") as! Bool

hiScore = NSUserDefaults.standardUserDefaults().objectForKey("hiscore") as! Int

firstEntry = NSUserDefaults.standardUserDefaults().objectForKey("firstentry") as! Bool

helpcount = NSUserDefaults.standardUserDefaults().objectForKey("helpcount") as! Int

print("user defaults iOSTV",(NSUserDefaults.standardUserDefaults().description))

}

else

{

NSUserDefaults.standardUserDefaults().setBool(tickHelp, forKey: "help")

NSUserDefaults.standardUserDefaults().setBool(tickMute, forKey: "mute")

NSUserDefaults.standardUserDefaults().setBool(tickMusic, forKey: "music")

NSUserDefaults.standardUserDefaults().setBool(firstEntry, forKey: "firstentry")

NSUserDefaults.standardUserDefaults().setInteger(hiScore, forKey: "hiscore")

NSUserDefaults.standardUserDefaults().setInteger(helpcount, forKey: "helpcount")

NSUserDefaults.standardUserDefaults().synchronize()

print("Setting up user defaults for iOSTV")

}



to save


#if os(tvOS)

if let isValid = NSUserDefaults.standardUserDefaults().objectForKey("help")

{

NSUserDefaults.standardUserDefaults().setBool(tickHelp, forKey: "help")

NSUserDefaults.standardUserDefaults().setBool(tickMute, forKey: "mute")

NSUserDefaults.standardUserDefaults().setBool(tickMusic, forKey: "music")

NSUserDefaults.standardUserDefaults().setBool(firstEntry, forKey: "firstentry")

NSUserDefaults.standardUserDefaults().setInteger(hiScore, forKey: "hiscore")

NSUserDefaults.standardUserDefaults().setInteger(helpcount, forKey: "helpcount")

NSUserDefaults.standardUserDefaults().synchronize()

print("Saving user defaults for iOSTV")

}

#else

/

pListDictionary["help"] = tickHelp

pListDictionary["music"] = tickMusic

pListDictionary["mute"] = tickMute

pListDictionary["firstentry"] = firstEntry

pListDictionary["hiscore"] = hiScore

pListDictionary["helpcount"] = helpcount

/

pListDictionary.writeToFile(pathToSave, atomically: false)

print(pListDictionary.description)

/

#endif

tvOS doesn't have persistent local storage using the file system. If you're writing a file you can only write to the caches or temp directories.