4

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.

Wojtek
  • 1,006
  • 11
  • 30
  • Have you tried the steps from here: http://stackoverflow.com/questions/22349557/could-not-build-module-uikit-in-cocoapods-since-xcode-5-1 ? – Lord Zsolt May 31 '14 at 18:51
  • Yes, I've seen this post but my application is not for iOS it's for OS X. – Wojtek Jun 01 '14 at 10:11

3 Answers3

3

Deactivate the "Enables modules (C and objective C) in build settings.

Antzi
  • 12,831
  • 7
  • 48
  • 74
  • Deactivating and reactivating, the error went away with a fresh build – P i Oct 01 '19 at 19:35
  • This saved my bacon after wasting hours on this fragile Xcode shyte and nearly punting it into low orbit. Kudos! – pete Oct 24 '20 at 16:02
2

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.

ejdyksen
  • 1,489
  • 1
  • 12
  • 15
0

You say that you've checked and Cocoa.framework is included in your application, but just make sure that Cocoa.framework is included in "Link Binary With Libraries" section under Build Phases.

Bijoy Thangaraj
  • 5,434
  • 4
  • 43
  • 70