ios - How to load a local json file in Xcode for unit test purposes? -


so have added file testjson1.json project.

within unit test have tried filepath without luck:

nsbundle *bundle = [nsbundle bundleforclass:[self class]]; nsstring *filepath = [bundle pathforresource:@"testjson1.json" oftype:@"json"]; 

when @ project file, can oddly enough see file added resources, thought unit test files not added resource keep app size down.

8aa238811c5565e80031648e /* testjson1.json in resources */ = {isa = pbxbuildfile; fileref = 8aa2387f1c5565e80031648e /* testjson1.json */; }; 

what missing please?

enter image description here

you need remove .json resource name not needed :)

nsstring *filepath = [bundle pathforresource:@"testjson1" oftype:@"json"];


Comments