Wojtek Wojtek - 6 months ago 49
Objective-C Question

Could not build module 'Cocoa' in OS X

When I am running my app made for OS X everything works as it should. But when I am trying to archive it I got an error Could not build module 'Cocoa' in the line

#import <Cocoa/Cocoa.h>
. What could be a possible problem here?

I've checked and Cocoa.framework is included in my application. I also created a new project and tried to archive it and I have the same issue.

Answer

Short answer

Try reinstalling Xcode. The version of Cocoa.framework you're compiling against is screwed up somehow. This will give you a pristine copy, since the version you compile against is inside the Xcode app bundle.

Long answer

For me, anyways, I managed to mangle the contents of NSTableCellView.h.

This was giving me errors like this:

<unknown>:0: error: /Applications/Xcode6-Beta5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSTableCellView.h:21: prefix attribute must be followed by an interface or protocol
<unknown>:0: error: /Applications/Xcode6-Beta5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSTableCellView.h:29: extraneous closing brace ('}')
<unknown>:0: error: /Applications/Xcode6-Beta5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSTableCellView.h:33: unexpected '@' in program
<unknown>:0: error: /Applications/Xcode6-Beta5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSTableCellView.h:37: unexpected '@' in program
<unknown>:0: error: /Applications/Xcode6-Beta5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSTableCellView.h:38: unexpected '@' in program
<unknown>:0: error: /Applications/Xcode6-Beta5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSTableCellView.h:42: unexpected '@' in program
<unknown>:0: error: /Applications/Xcode6-Beta5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSTableCellView.h:46: unexpected '@' in program
<unknown>:0: error: /Applications/Xcode6-Beta5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSTableCellView.h:50: unexpected '@' in program
<unknown>:0: error: /Applications/Xcode6-Beta5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSTableCellView.h:52: '@end' must appear in an Objective-C context
<unknown>:0: error: /Applications/Xcode6-Beta5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:13: could not build module 'AppKit'
<unknown>:0: error: could not build Objective-C module 'Cocoa'
<unknown>:0: error: could not build Objective-C module 'Cocoa'
<unknown>:0: error: could not build Objective-C module 'Cocoa'
<unknown>:0: error: could not build Objective-C module 'Cocoa'
<unknown>:0: error: could not build Objective-C module 'Cocoa'
<unknown>:0: error: could not build Objective-C module 'Cocoa'
<unknown>:0: error: could not build Objective-C module 'Cocoa'
<unknown>:0: error: could not build Objective-C module 'Cocoa'

The actual error messages led me to the line in question, where I had overwritten an entire @interface declaration with just the letter x. I just fixed that error, and it compiled again.

If you're not sure what exactly you need to fix, just reinstall Xcode.