Why does app crash on Cocos2d after sprite name is changed? - ios

I'm taking over an app for a friend who had a developer stop working for him. We want to change the icons of the characters in cocos2d. It's a small running game like temple run. We had a graphic designer create another image with the same size and same file name.
We then simply drag and dropped the image to replace the old ones. At first it was running fine, then when we switched a few more, the game crashed.

just posting as an answer so it may help others too.
What it may be :
hitting the logs would let you know that "failed to load data from xyz.png" which means the file you are referring is not present in the project which in your case may be due to excessive refactoring.
Also, check the extensions ".png" vs ".PNG".

Related

Safari iOS Favorite/Bookmark icon not updating apple-touch-icon.png

So based on my searches this has been a long-standing bug on iOS/Apple’s end. As of yet I haven’t been able to confirm a workaround so would like to see if I’m up to speed on this.
I incorporated a new favicon on my site with the help of realfavicongenerator, and it’s showing up everywhere except Safari iOS where a faulty cache seems to force the old image to show when the site is favorited or bookmarked. Adding to homescreen works fine, MacOS favoriting/bookmarking works fine, Safari iOS doesn’t.
I remember having a similar issue when incorporating the first apple-touch-icon a few years ago, also using realfavicongenerator: when favoriting/bookmarking in Safari iOS the icon was empty instead of showing the image. Eventually it showed up but I don’t recall how or exacty when, but it definitely took a lot longer than it should have.
I’ve obviously tried clearing cache and website data/history through Safari settings, restarting my phone, appending a variable to the apple-touch-icon URL, using both absolute and relative paths, and tinkering with different image size specifications, none of which worked.
I saw a suggestion somewhere that resetting the phone may work, but my question in that scenario is what exactly to reset and whether this would compromise other data.
Are there any workarounds/fixes I’m not aware of?
I’m using an iPhone 7 with iOS 12.2. The code being used is straight from what realfavicongenerator provides.
RealFaviconGenerator's author speaking.
As you noticed, iOS Safari is quite lazy regarding favicon reloading. It is not the only one.
The trick is to force it to reload the icon by providing a URL it never encountered before. A simple way of doing this is to suffix the existing icon URL with a dummy parameter. For example, change /the_icon.png to /the_icon.png?v=2.
To do so with RealFaviconGenerator, generate your icons again. This time, make sure to open the Version/Refresh tab in the Favicon Generator Options panel, and select the second option, as below:
Note: You might want to edit manually the code already created by RealFaviconGenerator and append the version yourself. This might be a bad idea. For example, if you put your icons in your root folder, some HTML lines were not generated (because of conventions RFG is taking advantage of). But suddenly, these lines must be added to specify a version. This is definitely not something you can guess at first sight.
New favicon showed up today, with no intervention on my part (versioning had also been removed). Not sure why. Guess it may be due to a time interval.

How to embed images and sounds in an iPhone app?

I am having a real hard time understanding how to embed many images and sounds in an iPhone app. When I say embed, I mean I want the images and sounds to be downloaded with the app, and some of those images will appear when the app is run. Other images are just saved in the app's disk space, so that when a user presses a button, the image or sound will be accessed and displayed or played.
I have read tutorials on using 'core data' and such, but that only seems like a way to create objects that can be used to reference such data items, or for storing small files as binary data. Can someone please tell me how in xcode I can specify a directory of images and .mp3s to be loaded onto a phone with my app, and how I can then call those media with code?
Some example code for the following would completely solve my problem:
An app is loaded onto a phone, and it contains 3 buttons. If the user presses button #1, a sound is heard. Button #2 plays a different sound, and button #3 changes a UIImageView to a different picture. (this isn't a homework assignment or something, but if I could code this example, I could do everything I need to in my app and understand the process)
Thanks!
I mean I want the images and sounds to be downloaded with the app
Simply add the images and sounds to your project. Make sure you specify (in the Add Files to Project dialog) that they are to copied into the project and that they are to be part of the target. The result will be that the images and sounds will be built into your app (in what is called its bundle, in particular the main bundle - see the NSBundle docs). You can then fetch them out, as needed, in code. For example, to fetch an image, use imageNamed:. To refer to a sound, refer to the file as a resource within the main bundle.
Other images are just saved in the app's disk space
That is a completely different matter. You will have to get the images from somewhere while the app runs. There is no way to have the user download the app and the image end up in the app's disk space: the app must populate its disk space, in real time, as the app runs. At the time the user downloads the app, the associated disk space, outside the app bundle itself, will be empty.
For images, see the responses to this question.
Sound is similar to images, but is loaded differently, this tutorial show how to load and play sounds.
For files that are saved after the app is installed, you will need to download and save those files in your code. For starters, see Apple's guide to the iOS file system

iOS CoreData image problems when working from a backup

We have an app that allows users to create their own content, it includes "groups" of text and images which are then used in a game. They are written to the db, but also "restored" back to documents when they are "synced" or "backed up" to an existing or "clean" device.
A user is able to backup (.fgz) to a dropbox, which is meant to make it easy to share the game data between a number of devices. This works without any problems. The game content (db driven) and images can be shared to any number of devices without any problems.
Every time we update the App, we have a problem where the text entries are retrieved and are completely viewable (both from the local file system / sqlite) but for some reason the images in the same location will not display as they have previously (the path to the image seems to be deprecated during the update). This includes doing a "backup" to a newer version of the app, to a device which has not previously had the application installed, which is also really strange.
During testing, using Xcode and local copies (replicating "install in place", we can not replicate this problem using the exact same code, and databases. There are no errors or warnings. Is this a core data problem? Any other suggestions about what we might be doing wrong?
What is going on here? We are at our ends trying to find a solution. Is there a better way to do this? We have thought about keeping our files as part of the local file system only, but if we do this, they won't be as "shareable" via the dropbox.
Any thoughts about managing image data in iOS would be very much appreciated.

UIDocumentInteractionController - Error while reading the document

I preview docs in my app using a UIDocumentInteractionController. However, sometimes documents show fine, other times the interactioncontroller displays a message "Error while reading the document". I know it is not an issue with the document, because the same document sometimes shows and sometimes doesn't.
Restarting the device solves this problem temporarily - so it would appear to be a memory issue, but strangely I am not getting any memory warnings. Any ideas on how to get this to work reliably please?
Notes:
The documentinteractioncontroller preview is dismissed and the
controller released when finished to ensure prior previews do not
remain in memory
I had the same issue using the quicklook controller
After much testing it appears this issue is limited to iPad 1. The only workaround is a restart.
Since you believe that the document in question is correct, and you believe your code is correct, you have to start looking for other factors. Two that come to mind are:
The state of the application. Is there something about the current state of the app that could be preventing the preview from working? You mentioned that you don't get any memory warnings, but have you looked at how much memory the app is using when the preview succeeds and when it fails?
The state of the document. Is it possible that the file can't be opened for some reason, such as the file already being open? Can you open the file by any other means?
It's possible that your app is trying to display the doc before the os has finished writing it to the sandbox dir. The speed of this operation will be somewhat dependent on what else is going on the the background (other apps, email downloading, iOS checking for updates, etc.). This would also explain why restarting the device can seem to fix the problem temporarily.
To check this, you could check for this error and then try again to open the doc after a few seconds.
Without specific code or or logs, it's tough to say much more.

Storing custom images in iPad application for use in App

I am making an iPad application (iOS 5.0/5.1 with ARC and storyboard) for which I need to download an image or sound file from my server and then use it as background for all the screens of my application. I was thinking of keeping a placeholder image/audio file bundled within my application which I will refer to within the storyboard. Then when I get the file from the server, I can replace that image with the one coming from the server. However, I'm not sure if this can be done based on the directories that the app has access to.
Pls let me know if you can direct me whether it's possible to go down this road? and if yes, then which directory should I be downloading the image files to?
Thanks in advance for your help

Resources