write to file in bundle

In an iOS project, I use the following code to write to a file called "test.txt" in my project, but the contents of test.txt remains empty. What is going on?

Replies

In an iOS project, I use the following code …

There’s no code here.

Also, your app’s bundle is read-only when installed on the device. You cannot modify a file inside your bundle. Most folks in your situation copy the template file to a known location (either the Documents directory or somewhere within Application Support) and then modify that copy.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"