IBOutlets not showing on XCode 6.1 (6A1052d)

2019-08-04 10:09发布

This is quite a major problem: the Outlets are not appearing in IB.

To reproduce:

1) I declare a variable to be IBOutlet, for example in my view controller's .h file

@property (nonatomic, strong) IBOutlet UILabel* testlabel;

2) I open the storyboard, click on the viewcontroller. - If this is a new project, there is no "Outlets" list. - If this is an old project with outlets already defined, the "Outlets" list contains the previous outlets, but not the one I've added.

Has anyone had the same problem. This is really important, as I can't basically proceed unless I stop using Outlets. I can't find any info about it on the release notes.

EDIT I'm adding a video on youtube showing the problem, in case I haven't explained it properly. If I'm forgetting something obvious, I'm happy to be laughed at :) That said, I've always been following these same actions and Outlets have always been in the list.

EDIT 2 For clarity, I've removed the ivar declaration as it seemed to get most of the attention.

Outlets on Youtube

EDIT 3 Ok I seem to be hitting a problem seen previously on this question and this other question. Basically, if I open the custom class drop-down, I see only some "standard" classes, such as UIViewController. If I select any of these, I get the Outlets. For example, for UIViewController I always have that view->View. However, my project's classes are not in the drop-down. Entering the name manually seems to work, but in fact it's not. There must be some indexing issue (except I've already deleted everything from

~/Library/Developer/Xcode/DerivedData/

without success. If you wish to try, I've put my code on GitHub. This doesn't show the Outlets for me, but it does for a number of other people - so it's not a "bug" with the code strictly speaking. It's more an XCode issue. Any help would be welcome!

EDIT 4 I think here's the problem, pretty much: look on the right. The drop-down menu doesn't show the "ViewController.h" class. If I enter it manually, it seems to recognise it but in fact I suspect it doesn't. In previous times, I was always seeing the full list of my project's classes in the drop-down menu. Class list is just generic

4条回答
ら.Afraid
2楼-- · 2019-08-04 10:17

Maybe a very dumb one, but have you tried Clean Project Folder, then deleting DerivedData (while Storyboard is not open), immediately quit Xcode, and opening up Xcode again, then building your project?

查看更多
做个烂人
3楼-- · 2019-08-04 10:23

I ran into a similar problem, but it was due to a bug in Xcode (8.2) where Interface Builder doesn't show outlets in the Connection Inspector if those outlets have been declared with a _Nullable type annotation for Swift compatibility.

Using nullable inside @property's parentheses appears to work around the problem.

(I know the original poster's problem did not use type annotations or Xcode 8 so was slightly different, but the question summary matched my internet search so I mention this for future searchers.)

查看更多
Bombasti
4楼-- · 2019-08-04 10:31

just declare the IBOutlet like this:

@property (nonatomic, strong) IBOutlet UILabel* testlabel
查看更多
beautiful°
5楼-- · 2019-08-04 10:40

I've found a "solution", or workaround. Deleting the XCode data is not enough, and it's not enough to just restart it. The following sequence makes the Outlets magically re-appear and work properly:

  1. Clean project
  2. Close XCode
  3. Delete all contents of ~/Library/Developer/Xcode/DerivedData/
  4. Restart MacOs

By doing this, when you re-open XCode and it reindexes, it will show the outlets as expected.

查看更多
登录 后发表回答