CCFileUtils naming convention not working so images can't be found - ios

I'm pretty new to xcode and apps so got some source code and am learning by 'playing'. I've been changing some file names and now my images won't load.
I have:
[CCFileUtils setiPadSuffix:#"-ipad"];
[CCFileUtils setRetinaDisplaySuffix:#"-hd"];
which works for all the other images in the source code but the ones I have changed are not being searched for with '-ipad' appended to the file name. When I create the files and add them without the suffix i.e. image.png rather than image-ipad.png they are loaded normally. I want to have the suffix naming convention though.
I have checked the files are named correctly (no rogue capital letters etc)
I have loaded them into the project (copy items into destination group folder, and create groups for any added folders)
I have checked that the files are there in copy bundle resources in the targets build phases.
I've also cleaned/build/relaunched etc many times including deleting the app from the sim and also full computer restart!! Any ideas?

OK folks I've managed to solve this one after two days of painful brain wracking! Whereas most of the images are used interchangeably across the app, some are used for specific levels. The files are named the same i.e background.png but level1/background.png might be different to level2/background.png
There are sections of code that specify specific folders by using a custom getFullPath method written in.
Due to this, instead of images being loaded into the project in groups they needed to be loaded in with the folders being references (Blue folders not yellow).
I finally figured it out by looking into the Library/Application Support/iPhone Simulator files that were being generated.
Also its worth noting that I had to have both sd folders with no file appendices available as well as the -hd.png, -ipad.png and -ipad-hd.png files that were being used as well. So even though I was running on the ipad sim I had to have the iphone sd files available too.
Hope this helps someone in the future!

Related

Organize code in xcode where same code used for multiple apps

Suppose I have a complete "app framework" I use for different customers. What is different for each is a config file (e.g. where to download new data files), data files and style files (e.g. background image and launch images)
I could of course
Copy code files around to different app folders replacing old ones.
Copy data/config/style files in/out of a single directory.
Use targets (just read up on these, new to xcode) - but does that work well with different asset folders, launch images etc?
Is there a better way? Somehow make a skeleton app / library that each specific customer app then inherits from? How about storyboards etc?
Only thing each customer specific file would change would be all the plist info, ID, launch images, data files etc. The code would be completely unchanged (I expect the skeleton app can handle whatever small nuances each customer will need, but far most is handled by config files. However, should the need arise, it would of course be nice if I could have cusomer specific code and visuals in each customer app, but this is not a requirement from my POV)
From what you're describing using targets is your best bet. So for example you'll have 5 targets in one worksapce, each target is a different app, all are using the same global.framework, each target got her own config.h \ config.m files

Bundle a LOT of images/icons

What would be the best way to include a lot of images in the bundle? I have an index of (game) items thus about 4000-5000 image files (total 27mb so not that big). Just include the whole map in the bundle or maybe first write a script that converts them to NSData? I could imagine there would be a smart way to do this so the app wouldn't have to look through all images individually to find a single one. Would love to hear your thoughts.
27mb isn't a huge amount to download so the easiest option would be to put them in an asset catalog, as Ryan Heitner mentioned in his comment this will allow App Thinning to take place in iOS 9.
I'm not sure what you mean by this:
I could imagine there would be a smart way to do this so the app wouldn't have to look through all images individually to find a single one
Each image will need to have a unique name (this is true regardless of the number of assets you have) and your code references the images by that name so it won't have to "look through all images individually to find a single one".
Alternatively if you really want to reduce the initial download size you could use On Demand Resources (another upcoming iOS 9 feature) to store them on Apple servers and loaded on demand in your code. Presumably you won't be targeting only iOS 9 though so in this case you would need to host the resources yourself and load them using standard techniques (see here, here, here, or use a library.
You should pack them in a texture atlas.
Then, the texture atlas files should be imported in your bundled via a folder reference (blue folder icon) and not a group (yellow folder icon).
Images imported in bundle in folder reference won't be optimized be Xcode on packaging. So you can make your own file optimization using imageOptim. It can compress a lot more than what Xcode can do on JPEG and PNG images.

iPhone App Building Setup - same code different assets

I have a number of apps (about 16 at the moment and growing) which have pretty much identical code. That is the code that drives them is the same.
There are a few things that change between apps, they are:
A PDF file (inside the bundle)
The icon
The name
4 Storyboard screens
As you can imagine it would be a nightmare to maintain 16 independent projects, my main concerns is that Features/Bug fixes in the main code will have to be applied 16+ times. The other thing is actually building and pushing 16 different binaries to the app store.
At the present time (Jan 2014) I want to know if there is a way to do this easily so that I only have to make a code change in one place and the 16+ other projects are updated and pushed to the store.
I have thought about git, or just having 16 projects and writing a bash script to do it for me but that seems dodgy. What is the most elegant solution to this problem that will reduce my overhead?
p.s. I don't want one app with 16 different icons/pdf due to size reasons
p.s.s. Please don't make as a duplicated, I want to know what solutions are there today, not a link to a slashdot question from 2010 :P
You could create a project for each app (so you won't have to change the project settings, e.g. name, icons, bundle identifier, ...) where you add the different PDF files and setup the storyboard screens.
Then you would create the classes in one project and drag & drop the files to the other project but uncheck the Copy items into destination group's folder option. That way you can change the code in any of the projects and it will be updated in all of them. You still have to build and submit each project on its own.
You can create one Xcode project file, with multiple targets. Each target in the project can have its own plist, icon, PDF and etc. Everything else will be shared and in one place.

Can I use iphoneSetDoNotBackupFile on a folder of files rather than individual files?

Do you know if I can use this on a folder and all the files within that folder will not be backed up? (in other words a folder rather than a file) I have a lot of code written accessing PDF files within several folders located in the special path documents folder. It would be pretty easy for me to set the do not back up of each one of those 7 folders but would rather not set the do not back up on each one of the 300 files within those 7 folders.
The same PDF`s folders also exist on my web server and so they can be updated or replaced if needed from there in the event they get deleted. Do you think Apple would be OK with me leaving them in the Documents/PDFDIR folders and setting the do not back up of those (7) folders?
This question was asked in a private support context, however, I felt it was valuable to answer here for others.
Yes it is. This property is recursive. While it's not really a duplicate answer because it's about a different language there is this answer here that backs up my answer in objective-c.

Where to save downloaded data that can't be recreated?

I created magazine reader app that uses png images as pages. When user downloads magazine, all png images are downloaded and stored in Caches folder.
Problem with Caches is that files in there can be apparently deleted anytime. Since app is designed to be used in offline mode as well, re-downloading of missing pages is impossible.
I tried to save it into Documents folder but my app got rejected, this apparently is not proper place for them.
So my question is, where can I put them to make that iOS won't delete them? I don't need them to be backed up to itunes or synced or anything like that, I just need them to stay there until I remove them.
I tried looking into the documentation but I could not find a category that would fit my needs, am I missing something trivial?
EDIT: I need to support iOS 4 as well
http://developer.apple.com/library/mac/#documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/FileSystemOverview/FileSystemOverview.html
Put it in the Libary Folder
Handle support files
—files your application downloads or generates and can recreate as needed—in one of two ways:
In iOS 5.0 and earlier, put support files in the /Library/Caches directory to prevent them from being backed up
In iOS 5.0.1 and later, put support files in the /Library/Application Support directory and apply the com.apple.MobileBackup extended attribute to them. This attribute prevents the files from being backed up to iTunes or iCloud. If you have a large number of support files, you may store them in a custom subdirectory and apply the extended attribute to just the directory.
Apple has a tech note that addresses this at http://developer.apple.com/library/ios/#qa/qa1719/_index.html
It shows sample code for setting a no-backup attribute on files.

Resources