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?
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.