0

According to other threads on this subject, when you select 'Universal' from the Target Devices drop down menu, it should create a Resource-iPad folder. Alternately, I read that you can duplicate an existing target with an option to transition to iPad or to transition to Universal.

However, neither of these behaviors occurs for me. I can set it as Universal, but since there is still only one target, how do you separate which resources are for the iPhone version and which are for iPad?

Additionally, how do you separate where the launch images and app icons go for each version?

To make matters worse, I decided to delete and re-add the target, and then try the transition over. But now none of my resources or classes allow me to attach to this new target at all, so I can't even run the project.

UPDATE: I created a new project and moved all my classes and resources into it, made the target universal and at least it is running on both. However, it is not clear to me how to have the app load one image file resource for iphone and a different one for iPad. The Apple documentation says to append "-iphone" to a file name for resources that are for iphone runtime, but this is not proving to be successful.

johnbakers
  • 22,776
  • 20
  • 106
  • 230
  • Isn't it just @"file.png" for the iPhone and then @"file~ipad.png" for the iPad? (notice the tilde and not a hyphen!) – Luke Nov 23 '11 at 17:11
  • thanks, i was really hoping my problem was that I was using a hyphen not a tilde. unfortunately, even with nothing named "file.png" and having "file~iphone.png" and "file~ipad.png" somehow the iphone run in simulator still uses a file that is equivalent to "file~ipad.png". bizarre. – johnbakers Nov 23 '11 at 17:46
  • wow there is something really funky going on here. maybe a bug in Xcode. i renamed my "files" so they are no longer called "file" at all, thus there is no resource in the project with the name, yet it is still compiling and running with the image! even after restarting Xcode. must be a cache somewhere? – johnbakers Nov 23 '11 at 17:50
  • 1
    Yep there is. Go to (in Xcode) Window -> Organizer and then Projects at the top of the window that opens. To the left you'll see your Xcode project list - click the delete button for the derived data for your current project. Also do a Product -> Clean, then restart Xcode and rebuild your project and deploy to device again. – Luke Nov 23 '11 at 18:33
  • thanks for this very useful information. unfortunately, i still cannot get a separation of files for the universal app. tildes are not working, neither are hyphens. it acts like the images are simply not there. the Apple docs suggest this is simple stuff, but apparently not :( – johnbakers Nov 23 '11 at 18:52
  • Typically, I write a quick if statement to set a string which is a filename for iPhone or iPad. You may already be familiar with this, but here's the link to the code. http://stackoverflow.com/questions/2576356/how-does-one-get-ui-user-interface-idiom-to-work-with-iphone-os-sdk-3-2 – Luke Nov 23 '11 at 18:58
  • It is simple, you're complicating matters by using Cocos2D. – David Dunham Nov 24 '11 at 01:19

1 Answers1

0

I'm in the process of Universal-izing an app, and since you mention the Simulator:

iPads (and iPhones) file systems are case-sensitive. So you need to use "MyImage~ipad.png" and not "MyImage~iPad.png" (which was my first inclination).

Other than that, it's all nicely automatic. Most if not all resources (.xibs, .pngs, etc.) load iPad specific versions with no code changes.

David Dunham
  • 7,837
  • 3
  • 29
  • 41
  • so i'm only having success by placing the tilde at the end of the entire filename including suffix, like "file.png~ipad" - does this make sense? it is working in the simulator and so far on an ipad. about to test on an iphone to see if it grabs the right images. it is odd that there is so much discrepancy in the information you see online about this. some say use a hyphen (such as Apple's own docs), others suggest to use a tilde, while others say to just separate them into different Resources groups and folders. none of these seem to consistently work. – johnbakers Nov 23 '11 at 19:03
  • That doesn't make sense, and it doesn't seem like a good idea, in that the PNG becomes hard to work with. How are you loading these images? – David Dunham Nov 23 '11 at 19:42
  • I am using `[CCSprite spriteWithFile:@"picture.png"]` i leave the code like that but i have two files, "picture.png~ipad" and "picture.png" and it is working on both devices. – johnbakers Nov 23 '11 at 19:56
  • 1
    Cocos2D uses its own file suffix system for -HD assets. I wouldn't be surprised to find that this messes with the standard Apple suffixes like ~ipad etc. After all, you can't use @2x for Cocos2D image files either. – LearnCocos2D Nov 23 '11 at 20:56
  • Yeah, I'm using things like `[UIImage imageNamed: @"picture.png"]` which works great. So now you're saying the naming scheme does work for you? – David Dunham Nov 23 '11 at 22:34
  • the "-ipad.png" (Apple's recommendation) or "~ipad.png" suffixed (everyone else's recommendation) both have no effect in my project when running on ipad. the ".png~ipad" however does in fact work, which is extremely bizarre. – johnbakers Nov 23 '11 at 23:50
  • Where are you seeing a recommendation for a hyphen? – David Dunham Nov 24 '11 at 01:21
  • My mistake, I revisited the document to discover that my eyes couldn't see the difference between a hyphen and tilde on my small notebook. So looks like my problems are related to Cocos, which I shall need to investigate that framework's way of handling this stuff. thanks. – johnbakers Nov 24 '11 at 02:13