dimanche 24 janvier 2016

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

So I have added the file testJson1.json to my project.

Within the unit test I have tried to get the filepath without any luck:

NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *filepath = [bundle pathForResource:@"testJson1.json" ofType:@"json"];

When I look at the project file, I can oddly enough see that the file is added to the resources, I thought unit test files would not be added to the resource to keep the app size down.

8AA238811C5565E80031648E /* testJson1.json in Resources */ = {isa = PBXBuildFile; fileRef = 8AA2387F1C5565E80031648E /* testJson1.json */; };

What am I missing please?

enter image description here

Aucun commentaire:

Enregistrer un commentaire