I have a file paylines.txt
added inside the folder named TextFiles
which resides inside the Resources
folder of my iOS project in Xcod
All you need to do is make sure that the checkbox shown below is checked.
well i found out the mistake i was committing i was adding a group to the project instead of adding real directory for more instructions
Try this, it's working for me.
NSString *str = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"paylines.txt"];
For simulator
NSURL *rtfUrl = [[NSBundle mainBundle] URLForResource:@"paylines" withExtension:@".txt"];
Are you attempting to do this inside of an XCTest and on the verge of smashing your laptop? This is the thread for you: Why can't code inside unit tests find bundle resources?
In case of Mac OSX,
Go to Targets -> Build Phases click + to Copy new files build phases Select product directory and drop the file there.
Clean and run the project.
Select Project / Specific Folder --> Right Click --> Add Files to Project -- > Select the File you want to add.
This worked for me.