File Access

Hello,

My App Playground uses a text file to work properly. I've had no issues running the app on Simulator, but it fails to find the file when being run on my physical iPhone. Has anyone had the same issue? Any idea what the problem is?

Thanks for the help!

Answered by DTS Engineer in 777924022

I've had no issues running the app on Simulator, but it fails to find the file when being run on my physical iPhone.

That’s a common problem for folks starting out. Your app running in the simulator has access to the macOS file system. That’s not the case when your app is running on the phone.

How you fix this depends on what you’re using this text file for. Is it:

  • Something you only read?

  • Something that maintains state, so it starts out blank but then you read and write it?

  • Something that maintains state, but it needs to start out with some default value?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

I've had no issues running the app on Simulator, but it fails to find the file when being run on my physical iPhone.

That’s a common problem for folks starting out. Your app running in the simulator has access to the macOS file system. That’s not the case when your app is running on the phone.

How you fix this depends on what you’re using this text file for. Is it:

  • Something you only read?

  • Something that maintains state, so it starts out blank but then you read and write it?

  • Something that maintains state, but it needs to start out with some default value?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

It's a text file which I only need to read.

File Access
 
 
Q