Xcode: Is it possible to have files available to all projects within a workspace?

250 views Asked by At

I have added a JSON file to the workspace, outside of any projects. I would like this file to be available to all projects that I add to the workspace.

When I try to do the following, I get a Cocoa Error 258:

NSString *path = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"json"];


NSError *error;
NSString *json = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];

if (!error) {
    NSLog(@"%@", json);
} else {
    NSLog(@"%@", [error localizedDescription]);
}

What's the proper way of sharing a single file in a workspace across many projects?

1

There are 1 answers

2
I make my mark On

At the target in your project there are 6 tabs. Go to build phases and check at Copy Bundle Resource whether or not that file is added to your new targets bundle.