[UIImage imageWithContentsOfFile: does not find png file in .xcassets (i.e. Assets.car in bundle) during use of XCTest but does during app execution

Originator:kbeitz
Number:rdar://18347389 Date Originated:2014.09.15
Status:Behaves Correctly Resolved:
Product:iOS SDK Product Version:8.0
Classification:Bug Reproducible:Yes
 
Summary:
a class in my app has a method that uses [UIImage imageWithContentsOfFile:[[NSBundle bundleWithClass:[self class]] pathForResource:@"x" ofType:@"png"], where x.png (and x@2x.png, et al) are proper members of an .xcassets file in my app .

when the app is run separately, the assets are found and used normally.

when the app is run as part of an XCTest, the asset is not found, and nil is returned.

i've checked the copy bundle phase of the build phases, and includes the .xcassets file referred to above.

after building, i've noticed that in both the package contents for the app, and in the debug folder for the .xctest package contents, an Assets.car is created, and the binary contents seem to contain pretty much the same thing (the name of the asset is found in both, and the files are almost exactly the same size)

Steps to Reproduce:
1. include an x.png in a app.xcassets file
2. include have code that retrieves the asset as described in the Description
3. run the app (code is found)
4. create an XCTest that invokes the method that makes the call described in 2

Expected Results:
both the app and XCTest should be able to access the resource

Actual Results:
only the app can access the resource

Version:
iOS 8 SDK

Notes:


Configuration:
Xcode 6

Attachments:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!