XIB not loading on iphone but in Simulator - iphone

When I run my app in the simulator it does load the xib file and all looks perfectly fine. As soon as I run in on my iphone4 I get a white page with "My Universal App on iPhone" but not my xib file.
how comes?

Try this: Clean all targets, delete Build folder and uninstall app from device.

It happened to me once too. Try to clean your project (cmd+maj+K).
Try to use the function InitWithNibName:#"YourNibName" without misspelling in YourNiBName.
Good luck

Check that the .xib file is still part of your project and set as a resource to copy at build time. This sort of thing tends to happen if you've removed a file from the build resources but there's still an old copy in the simulator's build directory.

Related

Finished running on iphone simulator

Since Yesterday when I build and run my app I m getting build Succeeded and Finished running 'appname'on iphone simulator and then it stops running. When I reset the contents of simulator then it shows me the app.This happens to me from yesterday.Before that I used to run as many apps in my simulator.But now when I reset contents then only I can run a new app.
I dont understnd whats wrong with xcode..?
Is there a way that I don't reset content settings everytime for a new app?
Try this..
1.Manually launch the iOS Simulator.
2.From the "iOS Simulator" menu, click "Reset content and settings",
3.Close and rebuild your app.
I fixed it by doing the following..
- clearing the derived data
- resetting the simulator
- shutting down the simulator and having it be launched by xcode after that
I did figure out what it was I was doing to get into the problem. I was trying to copy a folder called Resources to the bundle. Twice doing that got me into the mess. Third time I renamed the folder to just Res and it seemed to work. Seems like "Resources" is a special name for folders in a bundle and you can't use it for your own content.

Resource problem - Localization and iPhone/iPad XIBs all broken

I had a localized universal application. I copied a bunch of resources (XIB) files from an old project into the appropriate locations (English.lprog) directories for both iPhone (Filename~iPhone.xib) and iPad (Filename~iPad.xib). I added them to the project, and they all appear correctly in Xcode, as localizations, etc. I can open the localized files for each device in XCode/IB, and everything appears correct.
Now, when I run the project - everything is completely haywire. In short, when I run in English on the iPad simulator, I get the Chinese version of the iPhone XIBs!!!
I can't figure out what the problem is - any idea how to dig deeper?!
Few things fixed this:
Total clean build of project
Erase old application from device and/or simulator before reinstall.
Just because the icon in XCode looks like an IB icon, and double-clicking opens in IB, it still MUST have an ".xib" extension visible on the file.
Simulator is NOT case sensitive, but iPhone IS. This includes differences like MyClass~iphone.xib (works) vs. MyClass~iPhone.xib (doesn't work).
These steps have worked for me: In Xcode,
Check the location of folders for every language
Build > Clean all targets
Build > Compile
alt-R

Could not load nib in bundle on iPhone device

I'm trying to test an app I'm developing on my iPhone. To do that I changed the target from Simulator to Device on Xcode. The application is correctly uploaded to the device and it works. The main view is shown but if I try to open a secondary view, the application crashes.
On the iPhone log (I installed the iPhone configuration utility to see the console [is the only way to see the log from iPhone?]) I can see this error:
Could not load NIB in bundle
But, on the simulator it works fine. What's wrong? Any ideas?
I had the same problem and fixed it like so:
Open XCode Target
Click the "Build phases" tab
Click the "Copy bundle resources" section
Click the +
Add the missing Nib file
I've found that sometimes the device is case sensitive and the simulator is not.
What's the filename of your xib?
or
Try uninstalling the app from the simulator and installing it again - the simulator might have an old file left over from a previous run of the app - have you renamed / moved the xib at all during development?
I had a similar problem and was getting the same error. Turns out I was using the full name of the xib file in the attributes panel under "NIB Name:"
Don't use "SomeViewController.xib", just use "SomeViewController" without the ".xib" extension.
I had the same problem when invoking initWithNibName:#"MyViewController"
Changing the invocation to initWithNibName:NSStringFromClass([MyViewController class]) worked well
You can try these things:
Make sure case is correct
Use xib filename without the ".xib" extension
Remove any -(dash) or other special chars, use _(underscore)
Remove the xib file from the project and add back to the Xcode project
Check the build settings and make sure deployment is changed to currect SDK
In my case, the xib simply wasn't being copied into the bundle. Once I added the xib into the "Copy Bundle Resources" step for the application target, everything went fine.
I finally managed to solve that issue with these two steps:
In the view controller files inspector, remove any localization
(just for testing)
Ensure that you have checked the correct target membership
I don't know why it works on the simulator :(
For me, the problem was exactly what FreeAsInBeer said: the nib somehow was missing from the bundle, whereas it had been there before and worked properly in previous versions of the app.
To fix the problem, I did the following:
Select the project in the Project Navigator.
In the project settings select Build Phases.
Expand Copy Bundle Resources.
Scroll down (if necessary) and click on the + button.
In the dialog that appears, click on the Add Other... button.
Browse for the missing .XIB file in the file system.
Build and Run... the missing nib should appear when you run it.
This is just what worked for me when I got that message. Your mileage may vary, since circumstances are not always the same for everyone, but I hope this helps someone who runs into this issue.
-Evan
I ran into the same problem. In my case the nib name was "MyViewController.xib" and I renamed it to "MyView.xib". This got rid of the error.
I was also moving a project from XCode 3 to 4.2. Changing the Path type did not matter.
I had the same error message.
My problem, however was that my language settings on my phone were set on "English" and the Region on "United Kingdom". However, the file that could not be loaded was placed in the de.lproj directory.
Moving the file into the root directory solved it.
A simple mistake that might cause this error is trying to initWithNibName on an imported viewController when you are using a storyboard rather than individual Nib files. If this is the case then just init the controller instead of trying to init with a nib that doesn't exist, or init those fields with nil.
If Storyboard and no nib, change initWithNibName: bundle: to just be init OR initWithNibName:nil bundle:nil
For what its worth, I received this error when one of my tab bar buttons had the wrong class assigned to it.
I've got it to run with delete all of the localization from the xib
In the right window.
Maybe the file is in the localization folder.
I've the same problem. And my solution is remove all Localizations for the view.
I had exactly the behavior you described: works on simulator but get the "Could not load NIB in bundle" when running on the device, and the app remain stuck on the launch image.
In my case the problem was about the MainWindow.xib file that Xcode automatically created with English localization. I am supporting English and Italian in my app and realized that I was missing the localized version of MainWindow.xib for the Italian language.
Because I had no need to localize this file (it's Xcode default to create it localized) I fixed the problem by simply removing the English localization, so the same file is used independently of the localization. Another way to fix the problem would be to add the missing localized version, if you need it.
The app was crashing on the device because my device is configured for Italian language. The simulator instead was set to English and this is why the app run correctly. Just to verify, I set the simulator to Italian language and the app crashed confirming the localization problem.
I also had this problem when I loaded a child view controller from initWithCoder, which is a good place to initialise, but keep in mind you have to add it as an actual child AFTER the view has loaded.
So shift something like this:
[self addChildViewController: self.pageViewController];
[self.view addSubview: self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
...out of your init method and into viewDidLoad. Not saying this is your problem in particular but this may be helpful to others.

iphone problem adding splashscreen

i've a little problem, i've add a default.png in my app and it work.
I've modify my file, delete file and reference and upload my new file.
On my iphone the image does not appear, only some second of blackscreen and after my app start. In the simulator the splashscreen appear.
I've try to delete my app on iphone, make a clean all and rebuild & install but nothing...
I've try to make clean all, close xcode, delete default.png to my project directory (sometimes exist, sometimes no), open xcode, add my file and build & install on my iphone but nothing...
Any ideas?
partially resolved, i've delete my file and reference, check if it's delete in my project directory, readd file BUT in other directory and it works, i think there will be some reference to my splashscreen that i cannot found.
Is your Default.png file capitalized? The iPhone uses a case-sensitive filesystem. Not sure if that would cause the problems you're having, but it's worth checking on.

Default.png shows in simulator but not on real device iphone?

i have added a splash screen to my application by adding Default.png.
the splash screen works fine in the simulator but not showing on real device
Check the case of the file name.
Default.png, default.png, Default.PNG and DEFAULT.png are all different files on the device, but not in the simulator.
The file name must be Default.png (with a capital D). Also, do a clean/rebuild of the entire project to ensure the most recent version of the file is being included in the project.
Make a "Default.png" file (with a capital "D"). Then clean all targets and build again.
Sometimes this issue hapens, when .png file was renamed from .jpg file.
So, for example, you had image.jpg, you've renamed in to image.png, and using this image.png. It'll be correctly displayed in simulator, and won't work on device
Make sure the name of the file begins with a capital "D", then clean and rebuild.
Select your Default.png in the groups and files window and make sure in the file listing above the editor window that the checkbox on the far right is checked. Without this the file will not be copied to the application bundle after compilation is finished.