Could not load nib in bundle base internationalization - xcode

I have a project that I created in xcode 4.5 with a target ios of 5.0 and I used Base Internationalization. Base Internationalization moves the nib files to Base.lproj.
The project runs on my iPhone 4 running ios 6 and on my iPad 3 running ios 6. But this error shows when I try to run it on my iPad 1 running ios 5.1.1. In the Build Phase section of the target, the nib files are shown in red.
When I try to add the nib files to the Build Phases bundle resources, they add but they are still red (not found). I have tried every way I know to add the nib files to the bundle resources. How can I accomplish this?

Base Internationalization is only supported in iOS 6. It will cause a crash in iOS 5 or below when it tries to load a Xib.
Note: Strangely, running on Simulator with iOS 5 will work. That should to be a bug.
I have detailed my experience after releasing my app with this dumb startup crash: http://samwize.com/2012/11/22/warning-do-not-use-base-internationalization-in-ios-5/

I did not know that English (en) also must be localized. When I localized English, I was able to load the nib files into the bundle.
I'm still getting 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'MainViewController_iPad''
but at least now it's not because the nib files aren't in the bundle.

Related

LaunchScreen.storyboard is not showing

I started a single view app project on Xcode 12.5 and failed to locate the LaunchScreen.storyboard on the nevigation section. Where am I suppose to find it? Thanks.
Most likely you have chosen wrong Life Cycle while creating the project: SwiftUI App instead of UiKit App Delegate, so there is no LaunchScreen.storyboard File.

iOS 8 - Swift - Xcode 6 Beta - working without interface builder (no nibs and no storyboard)

I have been searching a lot in the inter webs and Stackoverflow. Unfortunately there doesn't seem to be much info around the new Xcode version, iOS 8 specifically with Swift and working without the Interface Builder.
The Templates to choose from as a starting point now does not have the option to start with an empty application. The least setup you have is to take the single view application, which already gives you the ViewController and a basic Storyboard.
I hate storyboards and I hate nibs. I want to do everything in code. I tried to delete the storyboard file, instantiate the window, set the rootViewController and make it visible just like in the good old days. the ViewController initializes without nib and bundle.
The result is this a SIGABRT with this error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Main' in bundle NSBundle </Users/[username]/Library/Developer/CoreSimulator/Devices/BC38B690-D30E-44FB-93B1-AB861D03B414/data/Containers/Bundle/Application/B6C160C8-67E1-4A74-9F81-55D097262050/blabla.app> (loaded)'
I sure hope that I will still be able to do UI without Interface Builder. Anyone has an idea on how to progress? I remember I was able to use an empty application with the previous Beta versions of Xcode 6.
In my opinion storyBoards are awesome. They make the development cycle easy and quick. But if you do not want them you can create a Single View Application template.
Delete the storyBoard and Follow these steps
1) Go to Your Target
2) Deployment Info
3) Main Interface -> Delete Main and keep field empty
It will not load a storyboard or any view. Now it's your responsibility to load Window and create rootViewControllers and views programmatically
The method outlined by codester is a good solution, but (in Xcode 6.0.1) the final step - deleting "Main" from the Main Interface section - would not work for me; I would delete the string, but as soon as I navigated away from that page or tried to run the app, the field would be repopulated with "Main". I ended up having to manually delete the "UIMainStoryboardFile" key/value entry in the applications Info.plist.

Nib file Main-iPad~ipad.nib' was not found

I'm trying to validate an iPhone app, which is ready to be released after validation. Xcode insists that there must be an ipad file for it though, any suggestions? I would upload a photo, but I don't have enough rep, due to me just starting Stack Overflow.
Likely there is a Main nib file designated in your info.plist file, but you have this resource not included in your application.
If you delete this entry in the info.plist file, it will be fixed.
Could it be, that you have choosen in your Project Settings, that it should be an "Universal" App, if so. Xcode wants two storyboards, one for the iPhone, one for iPad.
If this is the problem, just open your project settings and remove the "Universal" and change it to "iPhone".

Images not showing in iOS 7.1 with XCode 6 / Swift

I have this ObjC code:
[self.myButton setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:#"%#-button", self.myObject.name]]
forState:UIControlStateNormal];
This works great with these combinations:
XCode 5, iOS 7.1
XCode 6, iOS 7.1
XCode 6, iOS 8
But when I port one single class of the project to Swift -- a class which is unrelated to anything that is happening in this code -- the images do not display in XCode 6 for iOS 7.1. It does work with XCode 6 and iOS 8.
I finished porting the entire project to Swift, so now the code looks like:
self.myButton.setBackgroundImage(
UIImage(named:self.myObject.name + "-button"),
forState: UIControlState.Normal
)
And it's still unhappy on iOS 7.1. Still no images. (The custom icon works, though.) Yes, I know this is just beta software, and it's probably just a bug ... ? But I'm just wondering if anyone has a solution or insight.
I only started using XCode and ObjC about a week ago (surprise! ObjC is now deprecated!), so it could be that I am missing something, but since it works in ObjC, and in Swift+iOS8, it seems like it's probably a bug.
I've managed to overcome this by not using Asset Libraries to store my images.
Add your images to the project using the "old style naming", like Image.png and Image#2x.png, then load them without any extensions in the filename, as such:
let myImage = UIImage(named:"Image")
Fixed in XCode 6 beta 2
Images from asset catalogs in projects with a minimum deployment target of iOS 7 or OS X
10.9 will be available when running on iOS 8 and OS X 10.10, and now also iOS 7 and OS X
10.9. (17029658)
release xcode 6 beta 2 notes
For me it was because I suddenly add jpg image to Image Assets. Just resaved it as png and all work well
I guess you are testing it on simulator. Make sure the desired image is copied to 7.1 bundle. To do it check copy resources bundle build stage or check manually app bundles for different simulators at ~/Library/Application Support/iPhone Simulator/.
#o KB o points out here that the Xcode6 Beta release notes mention that xcassets bundles aren't supported for iOS7. Additionally, I've found it surprisingly hard to get rid of asset bundles in your project. This can cause naming collisions if your images have the same name as images that were previously in the bundle (you probably want the same names, so you don't have to rename your images everywhere in code / IB).
Here's a workaround:
Copy each image out of your .xcassets image bundle to a new directory (let's call it Images/). See below for a script to make this easier.
Delete your .xcassets bundle. (surprisingly, removing it from the project isn't enough. In my testing, if the .xcassets bundle was anywhere in the same directory as the Xcode project or related sources, it would get copied in. Alternately, you can remove the .xcassets extension)
Add all your image files to your Xcode project
Clean (cmd + shift + k)
Delete the app from the target device or simulator
Install and run
To make step #1 less tedious, I wrote a script to copy images out of the .xcassets bundle and into a directory of your choice: https://github.com/johnboiles/xcasset_exporter
mkdir Images
./xcasset_exporter.py MyProject/Images.xcassets Images
I had a problem where some images in xcassets worked and others didn't (only for iOS 7.1).
I solved it by deleting the problematic image sets and creating new ones with different names.
If you are attempting to use an external bundle with proper PNG images stored in either an "old style" folder or inside xcassets then apps running on iOS 7 will not be able to access these images.
I tried a suggestion from another answer here to add the "old style" folder path of the images in the external bundle but that didn't work for me. My solution, which fit my scenario, was to expose an outlet for the resource in the nib inside the external bundle. This allowed the main app to set with an accessible image to it. Whether this is a bug or simply a constraint in using nibs contained in external bundles with iOS 7 will matter less as it rides on to the usage sunset...
PS: Apps running on iOS 8 where able to access images in the external bundle xcassets just fine so choose your poison for supporting iOS 7.

After localization, application loads XIB that does not exist

I have an application with localized XIB files for English and French. When running in the iPad simulator on my development machine the French XIB is loaded when the language of the simulator is set to French and English otherwise, as expected.
It appeared that when running on the iPad it was loading the English language regardless.
I tried editing the English language XIB to verify it was loading the wrong version but this change didn't show up.
In fact the same XIB, which appears to be the pre-localization XIB or a copy of the English language version, loads even though I have:
Deleted the XIB.
Cleaned all targets.
Deleted the app from the device.
Turned the device off and on again.
Verified the XIB is not in the Copy Bundle Resources phase of the target.
Regardless of language or existence of XIB it still loads the XIB as it appeared pre-localization. This file no longer exists in my project.
The simulator, throughout, works as expected. Loading localized resources when present and throwing errors when it can't find the XIBs because they have been deleted.
How do I get the application to use a localized XIB that exists rather than a memory of a XIB that doesn't?
Try delete Derived Data.
Xcode -> Organizer -> Projects -> Derived Data -> Delete...
Everything will be fine.
This is a common issue. Quitting Xcode and reopening the project will usually fix it.
Also, be sure the newly created localized .xib has all the required "Target Memberships"

Resources