2

Is there a way to have Xcode refuse to build an app due to there being a dead outlet or action in my Xib, Nib or Storyboards ? I quite often build an app only to find it crashes due to a interface builder file is pointing to a key on my class which no longer exists.

I am slowly coming to the conclusion it is better to construct these pieces of UI programatically but I was wondering if there is a way at least for my older projects of Xcode warning me against these things ?

Shaik Riyaz
  • 11,204
  • 7
  • 53
  • 70
James Campbell
  • 3,511
  • 4
  • 33
  • 50
  • which version of Xcode do you use..? – bachman Dec 18 '13 at 11:12
  • It has nothing to do with building the app. of course it might show a warning if its deluge hasn't been set or something. Maybe we can help you if you could brief on the error you are getting. – bachman Dec 18 '13 at 15:39
  • No its runtime issue. But say I have a class with an outlet called "label" with a UILabel hooked up tp it in IB. But then I rename that outlet in the code but forget to update IB. then my app would crash but I may not know why, I was wondering if there was a way of xcode telling me. – James Campbell Dec 18 '13 at 15:49
  • I just asked myself the same question and was wondering why this doesn't show up together with other IB warnings like *ambiguous content size* or *Unsupported Configuration*. Xcode even shows a little exclamation mark in the `Connections inspector`. Why not escalate that as a full warning? – Lukas Spieß Jul 25 '14 at 19:57
  • Yeah, the compiler is smart enough that it could just do a basic traversal of the AST to work out the outlet is no longer connected properly. Maybe a good request for apple at developer.apple.com – James Campbell Jul 25 '14 at 22:53

1 Answers1

1

Well, it can't. The nature of Objective-C is dynamic so the connection between xib and code can not be sure in the compile/link stage.

You may implement

-(void)setValue:(id)value forUndefinedKey:(NSString *)key{ NSLog(@"Key:%@", key);}

To find out what is missing. (Missing outlets will finally reach here.)

Jay Zhao
  • 946
  • 10
  • 24