0

I'm not quite sure where to begin with this one since there are just so many things that seem broken with Xcode (version 6.3.1) and/or the simulator.

I have this line of code:

UIImage* img = [UIImage imageNamed:@"my_btn.png"];

I also have the required images (my_btn.png and my_btn@2x.png) that I'm trying to import.

From this point on, 'doesn't work' will mean img receiving nil and 'works' will mean img getting the right value.

Background (skip down to 'Current problem' if you wish)

1) I created an asset catalog as per the Apple guidelines here: https://developer.apple.com/library/mac/recipes/xcode_help-image_catalog-1.0/chapters/CreatinganImageCatalog.html#//apple_ref/doc/uid/TP40013303-CH2-SW1 ... and added the images above to an image set in the catalog. Target membership is greyed out (checkboxes to select which target an image should belong to is disabled) and it doesn't work

2) I tried importing the images to the project directly by:

2a) Dragging and dropping the two image files under the project title in the navigator. Target membership greyed out and it doesn't work.

2b) Selecting File>Add Files to "[project name]". Target membership greyed out and it doesn't work.

Then I came across this thread: Can't change target membership visibility in Xcode 4.5

The answer by Mazen Kasser helped. After I added the Copy Bundle Resources build phase, (1) works but (2) doesn't. Furthermore...

Current problem

3) When I right click on the image files in the project navigator and select delete->move to trash, it still works!? That's a problem. How do I remove the reference? I tried doing a Product > Clean, but it still works.

Community
  • 1
  • 1
Ash
  • 2,021
  • 2
  • 26
  • 59
  • (3) turned out to be a caching issue with the simulator. I fixed it by deleting the directory /Users//Library/Developer/CoreSimulator/Devices//data/Containers/Bundle/Application/ – Ash May 20 '15 at 01:51
  • You don't need to specify the `.png` extension in the image name. – i_am_jorf May 20 '15 at 01:56
  • does it make any difference if I do? – Ash May 20 '15 at 01:58

0 Answers0