After upgrading to macOS sierra 10.12.2 and Xcode 8.2 from OS X 10.10.2 and Xcode 6.2 [[NSFileManager defaultManager] currentDirectoryPath]
returns /private/tmp
instead of project directory. In Xcode 6.2 it returns project directory. Are there any settings which need to be set manually?
Problem is only with test target, I created a sample project and output of
NSLog(@"currentDirectoryPath is %@",[[NSFileManager defaultManager] currentDirectoryPath]);
is working directory for actual target but for test target it is always /private/tmp
.
Working with currentDirectoryPath() is not your best option here (with Xcode8). Inside your test class you should use:
or
This will return a NSString / NSURL pointing to the install location of the bundle. For simulator builds the paths will be as follows:
Knowing this you can load resources from your test bundle e.g. via