Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8855441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:08:08+00:00 2026-06-14T14:08:08+00:00

I have a .json file that I want to be bundled with my application

  • 0

I have a .json file that I want to be bundled with my application as a resource. I’ve read the File System Programming Guide which says that you should put support files in the <Application_Home>/Library/Application Support. So how do I put my .json file in this directory before building my application?

And how would I reference the file during runtime?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:08:09+00:00Added an answer on June 14, 2026 at 2:08 pm

    If your file will always be read-only (only updated as part of an app update), then add the file to your app’s resources in your project. Then you simply read the file from the app’s bundle:

    // assume a filename of file.txt. Update as needed
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"txt"];
    

    If you need to provide an initial file with your app but make updates during runtime then you need to package the file like above, but the first time your app is run you need to copy the file to another, writable location in your app’s sandbox.

    // Get the Application Support directory
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
    NSString *appSupportDirectory = [paths objectAtIndex:0];
    
    // Create this path in the app sandbox (it doesn't exist by default)
    NSFileManager *fileManager = [NSFileManager defaultManager];
    [fileManager createDirectoryAtPath:appSupportDirectory withIntermediateDirectories:YES attributes:nil error:nil];
    
    // Copy the file from the app bundle to the application support directory
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"txt"];
    NSString *newPath = [appSupportDirectory stringByAppendingPathComponent:[filePath lastPathComponent]];
    [fileManager copyItemAtPath:filePath toPath:newPath error:nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's something I want to learn and do. I have a JSON file that
I have a JSON file that I want to parse. For each entry in
I have a json file that I'm trying to get values out of. One
I have a JSON file that has more name value pairs than I care
I have a generated JSON file that I would like to transform. Is there
I have a json file ( ~3Gb ) that I need to load into
I have a large JSON file that contains A LOT of similar code. It's
I have a json file and I assume that I do not know anyting
I have a PHP file that returns a JSON array. I need to extract
I have a text file that contains cached data in JSON format. I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.