Missing ViewController.xib in Xcode 5 - ios

I'm new to iOS programming and is currently following the tutorial at http://codewithchris.com/demo-app-with-xcode-and-interface-builder/
We first create a new project using the Single View Application library.
Question: About half way into the tutorial, it says Once you have ViewController.xib opened on the left pane and ViewController.m opened on the right pane... However there is no .xib file anywhere in the Project Navigator, and this is the first mention of an .xib file in the tutorial.
Am I supposed to get a .xib file somewhere along the way? If so, which step will create the .xib?

XIB is an older format of Interface Builder. In newer versions of Xcode, by default, the project is created with a storyboard (Main.storyboard in your project). The difference is that in storyboards, you can see all the views of your app at once (and transitions between them), and with XIBs you have to keep them separately.
I'm not sure about this (can't check it right now), but if you insist on using XIBs, there should be a checkbox somewhere during creating a project. Anyway, I recommend you getting familiar with the storyboards, they are supposed to be a successor to XIBs.
As I can see in the tutorial, the author says 'XIB' even if he has a storyboard in his project, probably because he got used to XIBs. All in all, they are very similar in usage.

Actually storyboards contain .xibs (in your project one .xib as you created single view app.) The xib is just the user interface file shown in your second screenshot.
You just have to click the "Show assintant editor" on top right (the button with the suit) to split the xcode window and see the xib alongside the viewcontroller header/or implementation files.

Related

Dragging and dropping not working in Xcode

I'm working on my first Swift project in Xcode and am running into trouble with dragging and dropping elements from the storyboard into the code.
Nothing happens when I try dragging and dropping. I'm running the newest version of Xcode and using Swift.
The class is ViewController and the file is ViewController.swift
I'm trying to drag and drop a textfield into the class.
I have a question and possible solution for you, Sam.
What system are you using to do this? When I first started I wanted to use a mac over a remote connection and I found that holding control and dragging yielded me no blue line to associate the Interface Builder items with the assistant editor's code. I tried Chrome remote desktop, splash top, and VNC viewer. Nothing yielded the results I was looking for. Only when I got my own mac and was working with the machine itself was I able to control-click-and-drag to associate Interface Builder items with code.
Also, are you using the assistant editor or dragging into the file in the navigator on the left? I haven't tried the latter... only ever used the assistant editor.
Hope that helps!
You need to first change the class of the ViewController in the Storyboard to match the class of file that you are dropping into. Click the dropdown menu and choose your own viewcontroller class.
I'd suggest to rename your own viewcontroller class to differentiate it from iOS build-in class. Otherwise you might get confused while selecting the class.
May be you already solve. but it may help some one else. for Xcode-10 you will go
editor -> Localization Locking -> Reset Locking Controls
it help me to enable dragging and dropping the element.
You drag and drop into the Storyboard (Main.storyboard is the default name).
You cannot drag and drop inside a .swift file.
When your UI is complete, you need to "bind" the storyboard scene with the UIViewController (or any subclass) in the Identity Inspector (check this)

How to rename storyboard and have links from other storyboards preserved

I have two storyboards in Xcode project.
First named Main and second Settings. Main storyboard has storyboard reference to Settings.
I want to rename Settings storyboard to AppSettings. But when I rename it through Xcode Project Navigator, Main storyboard reference to Settings is not automatically updated and project fails to compile.
Of course, I can manually update broken reference, but I wonder is there another way of renaming storyboard in Xcode that would automatically update existing storyboard references?
Yes, Xcode's Find navigator can perform a find & replace operation that includes references inside storyboards. Search for "Settings" and replace it with "AppSettings". Then click "Preview" so you can choose only the relevant instances of "Settings" to replace (I'm assuming that word will appear in unrelated places, since it's rather common.) Afterwards, you will still have to rename the file itself as usual.

Where is Objects tab in Xcode 6?

I am following a hello world tutorial for xcode. I opened my LaunchScreen.xib file in Xcode6, here is how it looks like:
But according to the tutorial, there needs to be an Objects tab. Can anyone tell me where i can find it?
Thanks
Edit: Here is how it looks like in the tutorial:
I want to find my AppDelegate.h file but i cannot find it.
The Objects section of the document outline has been removed. Everything that was formerly under it is now a top-level item in the document outline. So everything that you now see in the outline that isn't under the “Placeholders” section would formerly have been under “Objects”.
Xcode's project templates have changed since your tutorial was written. When your tutorial was written, the template used a xib file that contained the app delegate and the window. Now, the template uses a storyboard. The system instantiates the app delegate and the window automatically and loads the initial view controller and its view from the storyboard.
The xib you are looking at (LaunchScreen.xib) is a new feature for iOS 8 that replaces the launch image PNGs you must use in older versions of iOS. It is not the xib you are looking for to work through your tutorial.
It would be possible to modify your project to match what the tutorial assumes you have, but doing so is probably not worth the effort. Look for a tutorial written for Xcode 5.1 or later that assumes you are starting with a storyboard.

xcode 4.2 ios 5 copying contents of a storyboard

Original Question:
This is my first post ever. I'm trying to learn ios programming by following cs193p (online). I got stuck on assignment 3 with a very (seemingly) simple thing. I did a few google searches on it already.
I don't know how to copy my view from assignment 2 (which is a storyboard) to my new xcode project.
I created a new master detail application (called it Calculator3), copied the storyboard from assignment 2 (Calculator2) in there as well. However, it's not possible for me to get the contents of that storyboard and put them in the new generated storyboard.
So is it possible to copy the contents of one storyboard into another? If not, then how do I do this?
Thanks to LU RD I post my answer here, instead of using an edit in my first post.
Answer:
A friend of mine solved it.
The reason why I got this wrong the whole time was because I did cmd/apple A + cmd/apple C. Instead of clicking at the top of the view I wanted to copy and then do cmd/apple C. After that, paste it with cmd/apple V in the storyboard you want to.
I noticed it only really works in the following situation (I thought it worked in more situations).
The two files should be in the same project, so copy the old storyboard file to your new project.
Then display the two storyboards next to each other via the "show the assistant editor" button.
Click in the top middle of your view and copy via cmd/apple C.
Click on your other storyboard and paste it via cmd/Apple V.
Bringing the old storyboard from source project into your new target project as a temp storyboard works. :)
(I've found it in en.lproj folder from source project) Also you can copy & paste all view controller component by selecting gray bar under your view.
Then remove temp storyboard and continue with pasted one.
You can copy a storyboard to another project by drag and dropping the story board. Make sure to tick the box "Copy items into destination groups folder".
Of course all of your references will break and have to be rebuild, but the layout and segues will all be there.

Go back from Storyboards to XIB

Not knowing that Storyboards are iOS5 only I created project that could be run even on iOS 2.0, but now I can't compile it with target lower than iOS5. Is there an easy way to go back to simple XIB file?
I don't think there's an automatic way to downgrade. Create new xib files for each view controller that needs them and link their view with the appropriate .h file. You should be able to copy and paste your whole UIView container view from storyboard to an xib though so it's really not that bad.
EDIT:
Also, I recently had to do this myself and a few things that weren't immediately obvious to me were that I also had to create a MainWindow.xib file, change your application plist, main.m, and my app delegate. Was definitely more complex than I expected but can confirm it can be done.

Resources