iOS file path differences between device and simulator - ios

This is similar to this question: iOS Objective-C Image file name/path different behavior betwewen simulator and device
I have the following path in Xcode, where Landscape is a Folder, not a Group:
Resources/Landscape/clouds_high.png
Both these load the image in the Simulator:
// Version A. Should only work for Groups, where image is in root
[CCSprite spriteWithFile:#"clouds_high.png"];
// Version B. Should work for my case (with a Landscape Folder)
[CCSprite spriteWithFile:#"Landscape/clouds_high.png"];
However, as expected, only the second works on the iOS device. I'm aware of differences in case causing things like this, but why does the first version with an invalid path still work in the Simulator?
For the record, if I make a duplicate of clouds_high.png just in the Resources directory, then the Simulator picks this version over the original in Landscape for Version A. Using Version B causes the simulator to choose the one in Landscape as expected. But as I mentioned before, the iOS device only works with the path specified relative to Resources. Why is this?

Try using this to get your paths. It will never fail, neither in the simulator nor on the device unless the file name you provide is invalid.
[[NSBundle mainBundle] pathForResource:#"clouds_high" ofType:#"png"];
For your case:
[CCSprite spriteWithFile:[[NSBundle mainBundle] pathForResource:#"clouds_high" ofType:#"png"]];

Related

App behaves differently on iOS device vs iOS simulator

forgive me if asking the wrong question - I'm new to coding.
I have my app running correctly on iPad Air 2 simulator, however when deployed to my actual iPad Air 2, one line of code (as far as I can tell) doesn't work.
The line in question -
starArray[streakCounter-1].image = UIImage(named: "22.png")
The line is part of an if statement in which all other lines work just fine on the device and simulator.
Any ideas what I can do?
There are a number of cases where the simulator behaves differently than an actual device.
The file system is one of those cases. The Mac OS file system is not case-sensitive by default (unless you take extra steps in setting up a drive). The iOS file system is case-sensitive. The simulator runs on the Mac file system.
If your file is really called "22.PNG" or "22.Png" then your code would work on the sim but not on a device.
I don't know for sure if that's the cause of your problem, but it's at least worth checking.
(There are other differences as well, but I focused on the one that seems most likely to cause the problem you describe.)

Local resources not loading on iOS 9.3.1 physical devices

As the title says, none of my local resources are loading on iOS 9.3.1 physical devices (neither images in an ImageView, neither translations, neither other files via Ti.Filesystem.getFile()). The following code results in a blank, white image (even though the image definitely exists on the filesystem):
Ti.UI.createImageView({
width : Ti.UI.FILL,
height : Ti.UI.FILL,
image : '/images/bg01.jpg'
});
The above code runs and displays correctly on all combinations of the iOS simulator, and on a physical 7.1 iOS device (as well as all Android devices and emulators). Unfortunately I don't have access to a physical 9.3.1 device so I cannot see the logs.
This is using Titanium SDK 5.2.2GA.
Can you try using png files in case you are using only jpg files and share a snapshot of your directory layout so that we can confirm nothing wrong with the directory or file names ?
But as you have also said that it is working on all simulators, so I assume that it is working on iOS 9.x versions as well, in this case you really need to test your app on physical device.
Apart from this, I can test your code on my iPhone 9.3.1 as I usually work on 9.3.1 and never faced such odd issue, so either provide us full/some code which is having issues or test it on real device.
It might be an issue with the device itself.
First make sure the case is right. If I recall correctly the simulators are not case-sensitive but the physical devices are?
I have ran into this issue using xCode. For some reason images are left our as well as the Localizable.strings files. I have yet to figure out a way around this and I have to manually add them to the xCode project.
See this for help TIMOB-19818. Christopher.fox comment is the one that lead me to solving my issue.

Building with iOS7 produces iOS6 looking widgets

After moving to XCode 5 and the iOS7 base SDK, some of the UI widgets in my app still look like iOS6-style (gradients, frames) on iOS7 devices. This doesn't happen on the equivalent emulator for iOS7. This also doesn't happen for all widgets, UIDocumentInteractionController's popup looks like iOS7 on device, but UIPopoverController doesn't. The keyboard for renaming a file also shows this discrepancy between emulator and device.
How does iOS determine the visual style of UI elements? Is it based on a statically linked library or something determined at runtime? I've tried purging the app from the device completely, but no change.
Emulator for retina iPad: UIPopoverController
iPad 3rd gen with iOS 7: UIPopoverController
The code in this case is fairly straightforward, no customization of the rendering or layout.
self.poController = [[UIPopoverController alloc] initWithContentViewController:audioCopyController];
[audioCopyController showDoneButton:NO];
audioCopyController.view.frame = CGRectMake(0,0,350,250);
_poController.popoverContentSize = audioCopyController.view.bounds.size;
_poController.delegate = self;
[_poController presentPopoverFromRect:view.audiocopyButton.frame
inView:view
permittedArrowDirections:UIPopoverArrowDirectionDown
animated:YES];
Thanks for the help in advance.
Check you Project config file and Target config file.
It is probably set with an iOS 6.X base SDK.
For this:
Go to your project config file in Xcode 5
Click the Build Settings tab
Edit the base SDK field to switch it to iOS 7.
Sometimes, we've experienced issues with Xcode not taking the current setting into account.
Changing it and compiling helps it understand that it needs to be changed.
Make sure you configure this correctly for your Project config and each and every target config file you run this from.
You might well have 2 different targets for simulator and for your devices.
Hope this helps
Regards
David
Ok, I found out what the problem was. David's suggestion got me thinking.
I am maintaining multiple apps at the same time, and one of them is quite old. The new Interface Builder in XCode5 breaks the transparency for a lot of the fields in the old app so I was keeping XCode4 in a separate installation folder alongside of XCode5. It seems that somehow my XCode5 project was still pointing at the SDK folders of XCode4 (not sure how this was possible, looking at the actual linker command line would probably shed some light), so after deleting XCode4's 6.1 SDK folder from my machine, a clean build with XCode 5 produced the correct iOS 7-looking widgets in my iOS-supported app.
The moral of the story is, be very careful with multiple XCode/SDK installations on the same machine. Hopefully this can help other folks who may be trying something similar to provide support for legacy apps.

Wrong button image on iPad device but not in the simulator

I am updating my universal app and naming my image files as follows:
buttonHelp.png
buttonHelp#2x.png
buttonHelp~iPad.png
buttonHelp#2x~iPad.png
This works fine on the simulator, but on my device (classic iPad running iOS 5.1) only buttonHelp.png shows up! (I have also tried "ipad" instead of "iPad").
Any suggestions?
The filenames are case sensitive, and must use lowercase ~ipad and #2x~ipad
buttonHelp.png
buttonHelp#2x.png
buttonHelp~ipad.png
buttonHelp#2x~ipad.png
Double check that XCode is actually transferring the files by removing the installed version from your device, doing a clean build, and reinstalling.
Also check each of the files are in listed in the 'Copy Bundle Resources' section of your 'Build Phases' in your project settings.
Reference:
Standard: <ImageName><device_modifier>.<filename_extension>
High resolution: <ImageName>#2x<device_modifier>.<filename_extension>
http://developer.apple.com/library/ios/#documentation/2DDrawing/Conceptual/DrawingPrintingiOS/SupportingHiResScreens/SupportingHiResScreens.html
It could be that buttonHelp#2x~iPad.png should be buttonHelp~iPad#2x.png.
The compiler does the trick where it sources all images with the #2x at the end of the file name for the retina display. If that image isn't found, though, it should default to the non-retina version, though.
Have you tried getting rid of the tilde in the filename?

iPad App name & splashscreen is different on the simulator as the iPad device

I couldn't find any results in google, so i hope someone has a solution for my problem:
I changed the name, App icon, "splashscreen image" of an existing app in xcode and all of them are shown correctly on the ipad simulator 4.3
If I start the app on my ipad iOS 4.3.5 the App icon is changed but the text under the App icon and the splashscreen is the old one. How is this possible?
There aren't any images of the old splashscreen in the project folder.
I deleted the old App from the iPad. Restarted the iPad several times with no luck.
Delete that app from your device. (long hold of icon and then hit the X)
Connect to Xcode
Clean
The build and run on your device.
The resources on the device are probably lingering and not being replaced when you rebuild it.
This link gives detailed information about launch images
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BuildTimeConfiguration/BuildTimeConfiguration.html%23//apple_ref/doc/uid/TP40007072-CH7-SW11
For your situation you'll need is a file called Default-Landscape~ipad.png in your bundle if your app universal.
Was your app iPhone/iPod specific before?
To change the name of your app, try adding a key to your Info.plist called CFBundleDisplayName~iPad with the name you want. I'm not certain this will work mind.
Normally, images that work fine in the simulator but not on the device are caused by capitalization problems. The simulator won't be case sensitive, but the device will be. Check the filename against how you refer to it in code (and/or the standard names that you need to use, e.g. "Default.png" with an uppercase D) and make sure both match.
A Clean and rebuild might also help.

Resources