New to Xcode here -- Is there a way to get more detail out of Xcode when it runs into a compile time error? The only message I get when I try to build my application is "Interface Builder Storyboard Compilation Failed". I have no idea what file it's having a problem with.
Nothing additional turns up under the "Build" item in the Log Navigator either.
Thanks to wufoo I figured mine out.
I have a tableview that has five static cells. The cells have an assortment of UIImageViews, UITextFields, etc. I had created IBOutlets in the main UITableViewController .h file and connected directly to the static cells UITextfields in the storyboard. You can't do that.
Once I removed those connections it compiled fine for me.
It appears you have to connect UIWidgets (textfields, labels, imageviews, etc) in a statically created cell directly to IBOutlets in that cells .h file (NOT, as I did, to IBOutlets in the tableview .h file).
---- UPDATE ----
Ok, so my initial post was not entirely accurate. It appears you CAN connect IBOutlets from subclasses of UITableViewCell directly to the main UITableViewController .h file. You just have to make sure that you set the Table View Content field to "Static Cells". I missed that step.
Here is an image to illustrate:
Select your storyboard, in the detail pane on the left, ensure that your "Table View" is selected. In the pane on the right select your attributes inspector panel and change from "Dynamic Prototypes" to "Static Cells". Setup your static cells by dragging and dropping your components onto the storyboard, then if you want to link from your components directly to IBOutlet properties on your main ViewController .h file you can.
I discovered the issue I was having was that I set up static cells in storyboard, and then tried to recreate them again dynamically in the delegate method cellForRowAtIndexPath:. That does not work very well. If you use static cells you do not need to use any of the cell setup delegate methods.
Here is some excellent reading that also helped me out:
Apple TableView Programming Guide
For what it's worth, the problem seems to be related to two IBOutlet objects declared in my .m file. One was referencing a UISlider and the other a UILabel. I removed the references and then declared them as class variables instead. In viewDidLoad I hooked them up using [self.view viewWithTag:TAG_FROM_STORYBOARD_WIDGET]. Looks like the same solution as mentioned by
f.perdition in the link above.
For me, it was two identical storyboards in the project that lead to this error popping up frequently.
I created a storyboard X, added a view controller Y in it. Then I refactored a view controller Z to storyboard X. Xcode asked if I want to replace the existing storyboard X and I selected Yes.
Its only after a few hrs I noticed that there are two references for the storyboard in file / project navigator (left pane). Removed one of the referneces and the issue hasn't shown up after that.
In my use case I have added a new target that runs the build script that is using xcodebuild. I was receiving the same failures but the reason was Mac Catalyst support being YES by default in Build Settings. (My main target doesn't support Mac Catalyst.) Changing those to NO in Builds Settings fixed the issue for me.
Related
I have some constraints that a shuffle around during an animation. After upgrading to XCode9 I tried to make some tweaks, and the editor seems to no longer allow me to add constraints to an constraint collection IBOutlet. I even created a new project and tried to make a simple outlet collection and ran into the same issue. Here's a short video of what I'm talking about:
I've tried the usual things of deleting derived data, restarting xcode, creating new xibs, praying to the xcode gods...etc. As you can see in the gif, it even happens to me in a brand new project. Anybody else seeing this? Any work-around I'm missing?
I think this is a legit bug, I submitted it to apple.
I'm surprised I don't see anybody else running into this.
I had the same issue. This is the only workaround I could find to get it working is to create the Outlet Collection in code (or create the first one by dragging from the storyboard as you're doing). Then drag from the 'add' icon in the ViewController's line margin back to the objects on the storyboard rather than the usual way around.
This also seems to be an alternative way:
https://stackoverflow.com/a/45597939/1320134
In summary, you need create the first outlet collection as you are currently doing, then drag from the newly created 'referencing outlet collection' in the Connections Inspector to the other objects you want to add to the collection in the storyboard.
I tried the same and got the following result. I guess it's working the other way. Check this link out.
Steps:
Drag the required outlet to the view controller file.
Select the outlet collection, name it and add it to view controller class file.
Select the outlet collection created in view controller file from the circle button showing the connection.
Drag from outlet connection to your desired outlet of the same type and it will be automatically added to the same outlet collection.
Or you can do it by going to connection inspector on the utility box on the right-hand side.
Find the desired outlet.
Click on connection circle and drag to the outlet you want to connect and it will be added directly to the outlet collection.
Hope this helps you.
Thanks!
I am creating a quiz app and for the buttons I need an outlet collection. So far in the array, I only have one button but I want to add the other three. On the other tutorial I've watched, it says to click the button on the side and drag to the thing you want to add (image link below). This doesn't work for me, is there a certain way you need to click? I've done this before, but this time its not working. The difference this time is that I've created a new class. I am not very familiar with Xcode or swift, sorry. Thank you.
Xcode is really buggy as far as outlet connections are concerned. Emptying the Derived Data folder as well as clean / rebuild help. But results could still be problematic. However, the old way to connect things which has been around since before the existence of an Assistant editor still works reliably. Select the ViewController and drag from ITS outlets in the Connection editor to the storyboard items (i.e. buttons).
Use Interface Builder alone. Use the Identity inspector to make sure your view controller has the correct class, the class where you put your outlet collection property. Now use the Connections inspector for your view controller. You'll see the outlet collection listed there; drag from it to your buttons, one by one.
I am experiencing a weird bug in Storyboards.
I set up a UITableViewController with prototype cells and set some autolayout constraints. Everything fine until here.
Then, I had to move the whole project directory into another folder. This is a normal action I believe that shouldn't lead to any problems since the app and all the files are pretty much self-contained.
However, since I moved the project, the prototype cells in the UITableView are shown empty within my Storyboard, but the subviews are still showing up in the left pane where all the scenes and views are shown... Only that they are greyed out (see the screenshot)... Does anyone know what this means? I also looked into the XML of the Storyboard file, but everything seemed normal to me in there...
Any ideas?
EDIT: Strange thing also is that the IBOutlets from the custom classes still are set and link to the views in the storyboard... but only in the left pane, not in the storyboard itself.
Just found an answer myself, it was because Size Classes were reset after I moved the project...
Greying out views is Xcode's standard behaviour when the views are only set for a specific size class which is currently not selected!
I had set the size classes for my UIViewController to Compact - Any, this is what it looks like in proper state:
The problem occurs when I change the size classes to another one (e.g. Any - Any):
This happened to me because I copy and pasted some of my views from nib into storybaord. Turning size classes off, and turning it back on fixed the issue. This can be done in File inspector, using a checkbox named Use Size Classes
I'm revising my app so that the first scene is a Standard ViewController containing a UITableView and a UIButton. This replaces the original UITableViewController.
Problem is, I can't (Control or Right-Click) drag from these elements to set outlets or actions in the associated ViewController class file.
I've checked and rechecked to be sure the identity of the VC is correctly set to the appropriate VC custom class file, but still no success.
I wonder if it may have to do with the fact that I deleted (trashed) the original UITableViewController and class files, although the .h file continued to show up in the Custom Class list under the Identity section for a while. It appears to be gone now.
I've cleaned and rebuilt several times, and quit and restarted Xcode, but without success.
Can anyone lend a hand?
Thanks!
Edit: Pursuant to a response to a similar question on SO, I checked the name of the ViewController class file by looking at the Storyboard as Source Code. The ViewController is in fact named correctly.
I accidently set event for command button as "outlet" than "action". Due to auto-drag feature, xcode generated references in applicationDelegate and .h and .m files. I removed the entry from .h and .m files but simulator wont run because it is still looking for that missing reference. I could not find that outlet referred anywhere. I am fairly new to iOS programming. Can anyone suggest a solution for this?
You have to unlink the outlet from the item in interface builder. Select the UI element that you linked the outlet to and then remove it in the "Connections Inspector".
Click the little "x" ^^^
I think there are two different reasons that people may come here wondering how to get rid of an unwanted Outlet reference.
Created an unwanted outlet while using the Interface Builder.
Copied some Outlet code from another projects View Controller.
Both reasons are fairly easy to solve.
Unwanted Outlet in IB
Method One
Right click the view in the storyboard and then click the little x by the referencing outlet.
Method Two
Right click the view name in the Document Outline. Then click the little x by the referencing outlet.
Method Three
Select the view on the storyboard and then click the Connections Inspector. Then you can click the little x to remove an outlet reference.
Unwanted Reference in Code
If you copy the view controller code from one project into another project you will notice a strange thing happening with the outlet. It is referencing the view from the first project without you ever connecting any outlets!
If you left click the little circle and click the reference link you will even be taken to the storyboard view in the other project. Trying to figure out how to get rid of this reference can drive you crazy.
Well, the good news is that there is really nothing for you to fix. You didn't copy over some deep, hard to find referencing link. Xcode is just getting confused because the View Controller and the outlet name are the same in both projects. Basically just ignore what that little circle says. You can close the first project and Xcode will figure things out eventually. Use the methods in part one of this answer to see if a view in your current project has a referencing outlet or not.
No need to delete Derived Data. That doesn't solve the problem anyway. Just try opening both projects at the same time again and you will get the same strange behavior. The way I figured this out was to separately create two new projects that had view controllers with the same name and a referencing outlet with the same name. I never copied anything but Xcode showed one was referencing the other. Like I said, ignore it.
It will be listed in the storyboard/xib as well, on the command button outlets.
Delete it from there as well, and you should be good.