Search code examples
iosswiftnsdatasimulator

NSData.writeToURL does not work at iPhone


I'm testing my app on iPhone 5s, in this app I'm saving audio file using NSData.writeToURL(destinationUrl, atomically: true), but this line does not work.

How destinationUrl is beeing generated:

let documentsUrl =  NSURL(fileURLWithPath: NSBundle.mainBundle().resourcePath!)

let fileName = remoteFileUrl.lastPathComponent

let destinationUrl = documentsUrl.URLByAppendingPathComponent(fileName)

While tested in iOS simulator - everythins was OK

How can I fix it?


Solution

  • You must not write anything at runtime into the application bundle.
    That will break the code signature of the application.