Two file with the same name by cocosbuilder - xcode

I would like to use cocosbuilder and cocos2d-x to develop my game for old and new iPhones. I would like to create one file for two resolutions. I created one ccb file and then I published it to retina and normal resolution. Everything works great but now I have two png files with the same name:
Published-iOS/resources-iphone/star.png
Published-iOS/resources-iphonehd/star.png
There is an issue. I am using Xcode and it doesn't like 2 files with the same name in the project. I can add these files to projects in separated groups but in final application bundle there could be only one star.png file. It is selected randomly. When I launch my app on iphone 4s I have picture from old iphone display. How to use cocosbuilder for multiple resolutions ?

You should import the resources-iphone, and resources-iphonehd directories in your XCode project as folder references instead of groups. You can do that by drag and dropping the folders onto your XCode project. When you do that you will see the directories appearing in your applications bundle. You can check that by selecting your application's target and going to Build Phases->Copy Bundle Resources.
After that, on you ApplicationDelegate.cpp file you should add those folders in the search paths list of CCFileUtils.
std::vector<std::string> resDirOrders;
if (resolution is iphone)
{
resDirOrders.push_back("resources-iphone");
}
else if (resolution is iphone retina)
{
resDirOrders.push_back("resources-iphonehd");
resDirOrders.push_back("resources-iphone");
}
CCFileUtils::sharedFileUtils()->setSearchResolutionsOrder(resDirOrders);
This is the recommended way of handling multiple resolutions according to the cocos2d-x devs (check out this article). You can use the window size from the CCDirector to determine the current resolution. In the iphonehd case I'm including the non-retina folders as well as a fallback.

Xcode and iOS app bundles aren't organized in folders, but rather flat bundles. You'll need to rename your files for it to work. I suggest something like this:
// iOS Standard
Published-iOS/resources-iphonehd/star#2x.png
or this
// cocos-2d Standard
Published-iOS/resources-iphonehd/star-hd.png

Related

XCode project missing files on other Mac

I have multiple Xcode Projects in my Dropbox so I can use them on my iMac and MacBook. But when I open the projects on another Mac most of the imported Images, Videos etc... are red (missing). the files are all in the Project Root Folder. What can I do?
This error is because when you added the files (images, documents, etc) you did not tick copy if needed option.
That means if you deag/drop items from your desktop to the project, Xcode will reference the documents from your desktop. When opening the project on another computer, the Xcode is not finding your documents in the desktop of the other computer, thus the error.
Solution:
1- Delete all the red marked items (take note of them)
2- move them again to the project and make sure to check copy items if needed checkbox.
3- re upload the project to wherever you need and it will run.
Happy coding!

Submit FireMonkey Project to Mac App Store, Icon Issue

From the Doc, it mentioned the package needs to include two .icns files, one for Retina, another one for non-Retina, but it didn't explain what will be the Filenames for these two .icns files, I checked other apps, it seems they include one .icns file only, so what should I do?
http://docwiki.embarcadero.com/RADStudio/XE3/en/Mac_OS_X_Application_Development#Icons_for_Your_OS_X_Apps

fonts and xmls not found in Xcode's open framework built product

I want to move my open frameworks project to other machines for testing. but when I try to open a build product (exported via the organizer) the app starts up without the text I set (via ofTrueTypeFont). It also won't load any data from the xmls I use. This also happens if I open the exported product on the same machine.
fonts are loaded like:
in .h
ofTrueTypeFont fontLarge;
in .cpp
fontLarge.loadFont("font.ttf", 35);
fontLarge.drawString("Display that String", 30,30);
I have tried various build phases. copied the .ttfs and .xmls to various directories but the app won't find it.
tried a (/bin)data folder within /App/Contents, /Frameworks, /usr/... every folder that i could imagine in the final product. What am I missing here?
Xcode 4.6 / OS X 10.8.2 / OpenFrameworks 0073
Not sure if it's the best approach but this is how I solved it:
Add to your application setup:
ofSetDataPathRoot("../Resources/data/");
Then add a Copy Files Build Phase to your Target and set the Destination to "Resources" and Subpath to "data". From now on you may drag and drop the files you need into the Build Phase and they will be included.

How do I add an icon to my Xcode project?

I have an Xcode project for Mac OSX, and I'd like to add an icon file (.icns) to my project and set it as the App Icon. How would I do this?
The key here is that you need an ICNS (icon set) file.
The right way to create this is described in the Human Interface Guidelines, and the details are covered in various user's guides and reference guides in Apple's maze of twisty little documentation, but I'll summarize it here.
There are third-party tools that can do this, as well as plugins for Photoshop, GIMP, Illustrator, etc., that can output a correct .icns file. But make sure, if you use such a thing, it's up to date, because Apple changes the rules all the time.
If you need to do it manually, here's what you do:
First, create a set of PNG files at different sizes. The exact list of what you need changes over time. See Provide the Correct Resources and Let OS X Do the Work if that link lasts longer than the current list; otherwise, search for it at http://developer.apple.com yourself. But, as of early 2013, it's 512x512, 256x256, 128x128, 32x32, 16x16, and #2x versions of each. All of them should have the sRGB color profile embedded in them. They should be named either icon_512x512#2x.png, icon_512x512.png, etc., or MyApp_512x512#2x.png, MyApp_512x512.png, etc. Put them all in a directory together named, e.g., MyApp.iconset.
"But wait! I just want an icon, I don't want all those sizes!" Well, you really do want all those sizes. Your 512x512 icon will look horrible when scaled down to 32x32. And on a Retina Mac, when your icon gets scaled up to double resolution, instead of getting sharper it'll just get jagged. Also, if you want to get into the App Store, Apple will reject you if you don't have them. But, if you insist, you can get away with just putting icon-512x512.png in the folder, and follow the rest of the steps, and it will work.
From the Terminal, cd into the parent directory, and type iconutil -c icns MyApp.iconset. You will get a file called MyApp.icns.
Now you can do the steps suggested by Douglas, and it will actually work. In Xcode, select your project in the Project Navigator, select your app target in the project sidebar, select the Summary tab, and drag MyApp.icns from Finder to the App Icon box.
This may not have any visible effect in the GUI, except to add MyApp.icns to the Project Navigator. In other words, you may still see the "?" icon. This seems to be a bug in Xcode 4.5. If you follow the out-of-date recommendations from the HIG two versions ago, Xcode always shows the icon, but if you follow the current HIG, it doesn't. Go figure. Hopefully Apple will fix that some day.
But for now, it doesn't matter. Build the project, and then look at MyApp.app, and it will have your icon in the Finder, on the Dock, etc.
Now, I know you don't want to draw the same picture in 10 different variations, you just want something simple. As long as you don't want to get into the App Store, you can get away with cheating, in two ways:
Scale the 512x512 (1024x1024 pixel "512x512#2x" if supporting hi res) image to all of the other sizes, using your favorite tool.
Create a .icns with nothing but the 512x512 image in the iconset.
The second one is simpler, and less cheat-y, and ultimately Finder is probably going to scale your 512x512 image as well as you would have anyway.
Finally, if you've manually edited your Info.plist or changed build settings (or you're using a project imported from a much easier version of Xcode), just dragging the image may not be enough. If you need to do the same steps manually, here they are:
MyApp.icns has to be in the Project Navigator as a file in your project. (You can drag it here from Finder.)
In Build Phases, the Copy Bundle Resources should include MyApp.icns. (You can drag it here from the Project Navigator.) (If you're not using the normal Build Phases for some reason, you need some other way to get it copied to Contents/Resources/MyApp.icns at build time.)
Your Info.plist should have an Icon file (raw name CFBundleIconFile) named MyApp, with no extension.
That's all there is to it.
In the project navigator, select an asset catalog.
Choose Editor > Add Assets > App Icons & Launch Images > New OS X Icon.
An empty OS X icon set is created, with an image well for each image representation in the set.
Drag icon file from the Finder to the appropriate image well in the set viewer.
Alternatively, you can add images by selecting an asset catalog, and choosing Editor > Add Assets > Import.
I am pretty sure you will have to put your icons into the project and then recompile. Let us know how it goes.

Where to store custom icons in Xcode 4?

I am creating my own icons for buttons. I did some snooping around, and it looks like application icons usually go under:
ApplicationName/Contents/Resources/some.png
What do I do to recreate my own structure like this for icons? I don't see any "Content/Resources" in Project navigator.
Xcode will move the icons to the Resources folder in your app package automatically during a build.
Just add the icon files to your Xcode project and it will detect that they are image resource files and add them to the Copy Bundle Resources build phase for you. Any files that are included in the Copy Bundle Resources build phase will be copied to the Resources folder in the built app's bundle.
It doesn't matter which group you put the images into in the Xcode files list because the file group organisation is ignored in the built product, so feel free to put them where you like. I often create a Media group with subgroups such as Images and Audio but it's completely up to you.

Resources