1

This is really strange, and it seems to be happening to some xib files randomly. I am currently porting an iPad app to iPhone, and for this I am creating new xib files and adding the ~iphone suffix to them. This works great and I never had a problem before. But for this specific project some of the generated nib files (when you build your app, the xib are compiled into nib files) don't have the correct suffix, or don't compile the correct xib file. I tried several settings, and this is the result:

Case A

First try, I just created the ported xib file as usual:

  • Original File: QuestionViewController-NoOptions.xib
  • Ported File: QuestionViewController-NoOptions~iphone.xib

And Xcode will generate this two files:

  • QuestionViewController-NoOptions~ipad.nib
  • QuestionViewController-NoOptions~iphone.nib

Which is the correct name, but the ~iphone one is just a copy of the ~ipad one.

Case B

I tried renaming both files like this:

  • Original File: QuestionViewController-NoOptions~ipad.xib
  • Ported File: QuestionViewController-NoOptions~iphone.xib

Xcode will generate:

  • QuestionViewController-NoOptions~ipad~ipad.nib
  • QuestionViewController-NoOptions~iphone.nib

For this case the both files are correctly built, but of course the ~ipad~ipad one won't work on ipad (App crashes complaining that couldn't find QuestionViewController-NoOptions~ipad).

Case C

Even worse:

  • Original File: QuestionViewController-NoOptions~ipad.xib
  • Ported File: QuestionViewController-NoOptions.xib

Xcode will generate:

  • QuestionViewController-NoOptions~ipad~ipad.nib
  • QuestionViewController-NoOptions~iphone.nib

in which the ~ipad~ipad is correct, but the ~iphone is just of copy of the ~ipad~ipad one.

Some random facts:

  • Some xib are using auto layout, some other's no, if I enable or disable this, the behavior change (I got an ~iphone~iphone and an ~iphone together once).
  • I manually played with this line on the xib source code (removing or adding the iPad part), but no useful result:

     <document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="7531" systemVersion="14D131" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
    

Has anybody experienced this problem before? Any clue will help... Thanks!

JP Illanes
  • 3,665
  • 39
  • 56

1 Answers1

6

The problem was that in some xib files I was using Size Classes (The Use Size Classes option was activated on the File Inspector). It seems that Size Classes was made to replace the old ~iphone and ~ipad suffixes, and if you use it, it will automatically create the suffixed nib files for you. Disabling Size Classes did the trick, now everything work as supposed.

JP Illanes
  • 3,665
  • 39
  • 56