Could not find a storyboard named 'MainStoryboard_iPad' - iphone

I cannot run my project in simulator because i get this error:
Could not find a storyboard named 'MainStoryboard_iPad'
But the storyboard is there.
Thank you

I managed to solve this problem in my iPad App through the following steps:
Checking the Build Phases
Editing the Info.plist file to add the option "Main storyboard file base name (iPad)"
Just like in this picture:

In my case, the iPad storyboard file was already in the project, and testing the app worked until I introduced what seems to be an unrelated bug... I fixed this by changing the filename in xCode for the MainStoryBoard_iPad to MainStoryBoard_iPad1 and changing the TARGETS > Summary > iPad deployment Info > Main Storyboard entry. For good measure also verifying the same in -Info.plist file and Build Phases accordingly... similar to #daniel-lima.
Hopefully, this may help others that did not fix based on above notes. This started after I fixed a CoreData related bug in a category-file. The issue was reproducible on another machine... and this fixed it on both machines.

My issue was only on iOS 5. The resolution was found at http://need-bee.com/b/2013/08/could-not-find-a-storyboard-in-xcode-5-for-ios-5-0/
To summarize:
In Xcode, open each story board file and uncheck "Base" under localization on the right hand side. It will prompt you to move to English. Select ok. Once rebuilt my issue was resolved.

Click target and there is Mainstoryboard with textfield. Click and select your storyboard named "Mainstoryboard_iPad" and clean your project and then run it.

Remove from the project all the StoryBoards and add all of them again, for me worked.

I got this problem today as well, for me, a Product > Clean solved the problem. After that, I can rebuild the app and run it inside the Simulator without any issue.

I was encountering the same problem as in the original question but for me there wasn't really a bug - rather, the storyboard which appeared in the project navigator as "Main.Storyboard" actually had a base name of "Main" in info.plist. So my attempts to use "MainStoryboard" and "Main.Storyboard" in my code were generating a crash, but once I changed it to "Main" it worked just fine - didn't need any of the elaborate workarounds above.

If the failure occurs after launch, check to make sure any references to a storyboard via storyboardWithName: refers to the correct name. You may have an incorrect name hardcoded in your binary.
In my case, I renamed the storyboard (based on a suggested workaround on stack overflow), but forgot to rename references to the storyboard in code. The symptoms were that changes to the storyboard weren't visible in the running application, but once I reset the simulator, the app stopped working completely. In that case, the old, stale copy of the storyboard was around at first and was used; once the simulator was reset, the stale copy disappeared and the "could not find a storyboard" message started appearing.

Related

How to fix "Thread 1: Exception: "Could not find a storyboard named 'Main' in bundle NSBundle" error in Xcode 11.4 when I do not have Main storyboard?

I know there are many questions here relating to this error but none of them. quite fit my situation. I have made an Xcode project trying to create a Star rating UIView with CocaoPods and Cosmos. I am following a tutorial. I was told in the beginning to delete the main storyboard and delete "main" as the main interface. So far I have installed two Cocao Pods on my project through the terminal and I am now using a new workspace that the Cacoa pods created. Every time I run the simulator, my app crashes and I get the error mentioned above but I can't do anything because I have deleted the main storyboard. I have tried making a new one and re-coding and more but nothing works. In the tutorial, the guy ran the exact same code that I have and he just magically has a storyboard with stars on it that you can tap and change. I've done everything he has, how do I fix this?
Here is my info.plist
To delete Main.storyboard as the main interface you have to delete it from the Info.plist file too. Look for the property "Main storyboard file base name".

Could not insert new action connection Error

I get this error, when try to create new action for UIButton by dragging blue arrow from UIButton to my header file (you know, this new feature of XCode 4...)
When I create action in code by myself and connect it in old way, simply by dragging from button to File's Owner, it's works well
Here's screenshot:
Make sure your .m file exists in the project and on disk. Make sure it is correct with an #implementaiton-#end block. Open it in Xcode, close it, if the error persist, restart Xcode.
Xcode is trying to write to EditPUViewController.m (in the dealloc method etc.) but could not find it.
Also, it always helps to hard-clean the project with ⌘+⌥+⇧+K.
Try this:
Open Organizer then Project Tab.
Clear the "Derived Data". Xcode should re-index your project then and code sense should work. At least worked for me.
I had a comparable problem when trying to connect an action. To solve it I manually added the IBAction and then XCode allowed me to connect from the button to the code.
Go to Xcode -> preferences -> location tab -> derived data -> clear derived dat.
I ran into this issue myself but none of the methods presented here worked for me. The error described in the question above occurred when I tried to create an IBAction in my view's header file (.h), whereas to my implementation file (.m) I couldn't even drag a line. (Xcode wouldn't even show this little popup where you can name your action.)
After trying for hours I figured that the reason why I couldn't create the IBAction was because I had removed the very last line from my .m file. Xcode automatically adds an extra empty line after the #end delimiter when you create a new Objective-C file.
Don't ask me why - but if you remove that line Xcode doesn't let you create any actions or outlets. (This is obviously an Xcode bug.)
I noticed that .m file was moved inside en.lproj folder.
Just delete (reference only) the .m file from the Xcode and moved .m out of the en.lproj. Add it again.Don't worry, you will get all your connections back.
It will fix the issue.
I recently came across this problem. I soon realized that the cause had been my own doing.
I had previously disabled XCode indexing (which used to take forever & eat up my RAM), using the below code in a terminal window:
defaults write com.apple.dt.XCode IDEIndexDisable 1
To revert XCode to its default state, i used the following line in a terminal window:
defaults write com.apple.dt.XCode IDEIndexDisable 0
Voila! All's well again..
I got the same error. Restarting Xcode did not fix it for me (I didn't want to reboot). The file was also not in the en.lproj folder (nor in the usual project folder after I deleted it from within Xcode). The fix for me was to re-create the file with a different name (Using different case in the filename alone was not enough to fix it... must be a different name entirely).
I ran into this problem when I created a class, deleted it and then created a new one with the same name. The workaround was not to reuse the name of the deleted class, but use a new one. Thus, I'd say it's a bug on the XCode side.
Remove the newly created class (don’t delete it, just remove link and then re-add it);
Save Xib file;
Restart Xcode;
You may want to delete Derived Data as well if it does still not work.
This seems because of XCode is missing reference or need to refresh manually.
In my case, removing the reference of the nib(.xib) and adding it again solved the problem.
In my case I had by accident selected the arm64 build. When compiling I got an error but I did not notice that since I was working with the UI trying to connect an action.
The error however was exactly the same. After changing to another architecture so the project compiled I could connect the action by holding the ctrl button as usual.
user2175983 and AstroCB answer's worked well for me:
Just delete all Derived data by running this command line in a terminal:
rm -frd ~/Library/Developer/Xcode/DerivedData/*
Restart Xcode
I just deleted the reference to the file in the Xcode project and then re-added the file back to project from the finder...
In Xcode 9 I had the same error after moving .m files in project from one directory to another. Deleting references to .m files and add them again did solve the issue.
I found the ANSWER. When you create a new file (Objective C files) for each view controller, you must check by clicking the box, next to your project name. So that your project includes this file. Otherwise, this error will persist, because your project hasn't connected to the file even though it created it.

iPhone app opens to black screen after refactor proj name in xCode 4

Guys, i wonder if any one can help - My project was fully working in both the simulator and on a device, however, i renamed the project in xcode 4 (double clicking at the root of the project navigation pane, it was happy to rename any references - but now when i launch the app it only opens to the main window (yes it has outlets, all have outlets etc etc),
no code in the app delegate stops at a break point (even in didFinishLaunchingWithOptions)
so unsure what i could have missed, i have looked at other answers and everyone writes and says "missing outlet" etc.
I have dragged some backed up version of the app delegate that used to work and no difference, what could i be missing.
I do have source control, however currently in the process of merging from VSS to GIT.
thanks
lee
Check your Info.plist for what it uses as it's Main Nib File. Perhaps something changed there? Also, within the nib file itself you might have problematic connections to classes that are still named with the old name.

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.

Xcode's Refactor menu is always disabled

For some reason Xcode's Refactor is always disabled. I used to be able to activate it via selecting a class name and right clicking in the editor to select it. But now no matter what I do, it remains disabled. Any idea what's going on?
Working with Xcode 5, I kept getting "Can't refactor during indexing" when trying to refactor. Rebuilding the index seemed to hang at "Indexing - Waiting for make" forever.
I then noticed that make was already used by another process on my machine (not by Xcode). Shutting this process down enabled Xcode to finally finish indexing
Your project's index might be out of date/corrupt. In the General tab of the Project Settings window, click Rebuild Code Index and wait until it's done.
You can check the progress of the rebuild in the Activity window (Window > Activity).
I just ran into a similar problem in Xcode. I could not refactor anything in the class's .m (implementation file). The only explanation I could come up with is that it was not indexing the file for some reason, and I could not force it to reindex. The only hack that I found that worked was to copy the file to temporary location, remove it from my Xcode project, copy the file from the temp location back to my project's location, and then re-add the file via Xcode.
None of these suggestions work for Xcode 3.2 - the ONLY way is to select the file you want to rename in the left Groups & Files column. THEN highlight the name of the .m or .h in the right code view, then you can right click and select Refactor!
For instance if you're changing the DetailViewController name, highlight the actual DetailViewController.h word in code.
Note, you should also always make sure you've selected the .h file, not the .m
I faced the same thing in Xcode 11. and this worked for me:
I changed iPhone 8 simulator to generic iOS Device and it worked when it is on Generic
I'm new in iOS development,I have met this similar problem.
Xcode:Version 7.1 (7B91b),it looks like Refactor not working:
But when I put my mouse on the red circle point in the following picture,and then the Refactor working.
I think this is a low level mistake,but may be a reference for someone.