Do you need a backend to store JSON files used by an iOS app?

Viewed 173

I have created an Xcode project which reads data from a JSON file. My app is working fine in the view preview and when simulated. My question is, does the JSON file automatically get stored with my app when I publish to the App Store? Or do I have to host the JSON file elsewhere (cloudKit, Firebase, etc)?

In other words, is my JSON file a part of the app, in the same way that the app Icon and app assets are part of the app?

In the image below, I have stored my JSON files in a folder called "resources". Will this "resources" be part of the app when it is uploaded to the App Store?

FYI ... I am very, VERY new to Swift and Xcode! Sorry for the stupid question.

Where my JSON file is located in Xcode

1 Answers

As long as the file is bound to the app target then it will be part of the application bundle. You do this by opening the file in Xcode and then in the property inspector ticking the app target in the Target Membership section.

Be aware when you do this you will need to access the file as part of the bundle and not via its file system location.

if let filepath = Bundle.main.path(forResource: "myFile", ofType: "ext") {
   // load file
Related