Xcode 6 GM won't compile for iOS device, but i

2019-07-20 20:51发布

问题:

I have a project that compiled just fine in XCode 6 beta, but now, in the GM, it won't compile for an iOS device, giving the error:

myController.m:393:9: No visible @interface for 'UIDevice' declares the selector 'initialize:'

at this line:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

It still compiles absolutely fine for the simulators; I've also tried these fixes:

  • Cleaned the whole project and re-built.
  • Deleted all Derived Data from ~/Library/Developer/XCode
  • Re-installed XCode
  • Checked XCode preferences and pointed Command Line Tools location to XCode 6 (XCode 5 is still installed on the machine and it was pointing there)

...but with no luck. Same error on compilation.

Help! We're on a tight timescale with iOS8 now approaching, and this is a real headache.

PS: We're also using Cocoapods in the workspace, for what it's worth.

回答1:

OK, I solved this one after rather a lot of hair-pulling. The app in question is an iOS 8 app, with an embedded Today Extension.

It turned out that, when adding the Today Extension, XCode had added a build setting:

'Enable Modules (C and Objective-C': YES

Neither my project nor my containing app targets used this build setting, but setting it to YES caused issues to do with trying to link Frameworks automatically (and failing) and all sorts of related odd error messages that ultimately related to header files.

The problem was further compounded because there are source files that are members of both the containing app's target and also the Today Extension's target.

Hope this info helps somebody else.

Carl