Problems in CCObject headers/source when using installed template

Hi all, I just got Cocos2DX and am trying to go through the Space game tutorial in Xcode but am having severe issues. I’m using the official Cocos2DX Xcode template but am getting the following
CCObject.h:37:1: Unknown type name ‘class’; did you mean ‘Class’?

This happens typically when a file is marked improperly as .m for Objective-C and not .mm for Objective-C**. However this is obviously just straight C** and marking the files manually as C++ headers/source does not appear to resolve this issue at all. Please advise, thanks! :slight_smile:

To give an update, after testing this again I’ve noticed the problem itself isn’t with the template, but rather with the Code included in the Space Game Tutorial here:
http://www.raywenderlich.com/11338/cocos2d-x-for-ios-and-android-space-game

I didn’t notice it right away because the first step was to add the Shared Resources. It appears that inside is a file trying to use an Objectice-C category on a C++ class and that was why it failed. Issue is resolved.

I got into the same problem! Can you elaborate more on how to solve it?
Thx!

Long Wing wrote:

I got into the same problem! Can you elaborate more on how to solve it?
Thx!

The Problem is Objective-C source from Cocos2D (The Objective-C version) is hidden amongst the assets for the tutorial. Look for .m or .mm files and remove those from your project. You’ll have to attempt to add the Parallax Background method by adding a subclass with the method you need.

Thanks a lot Great Solution! :):slight_smile:

Hi, I got the same problem. I have rename all .m file to .mm file but error is show when I build project.
Error is shown here:
—————————>>>>><<<<<<————————
ProcessPCH /Users/tranduc/Library/Developer/Xcode/DerivedData/Dino-exxaxhcxfgcxgyhafemhztmmqdys/Build/Intermediates/PrecompiledHeaders/Prefix-dgalaaouttqoqbhaerdnnbxrmbrm/Prefix.pch.pth Dino/Prefix.pch normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/tranduc/Documents/WorkAIT/SVN_DINO_Code/dino/iosProj/Dino
setenv LANG en_US.US-ASCII
setenv PATH “/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin”
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang x objective-c-headerarch armv7 fmessage-length=0std=gnu99 Wno-trigraphsfpascal-strings O0Wno-missing-field-initializers Wno-missing-prototypesWreturn-type Wno-implicit-atomic-propertiesWno-receiver-is-weak WformatWno-missing-braces WparenthesesWswitch Wno-unused-functionWno-unused-label Wno-unused-parameterWunused-variable Wunused-valueWno-empty-body Wno-uninitializedWno-unknown-pragmas Wno-shadowWno-four-char-constants Wno-conversionWno-shorten-64-to-32 Wpointer-signWno-newline-eof Wno-selectorWno-strict-selector-match Wno-undeclared-selectorWno-deprecated-implementations DDEBUGDCOCOS2D_DEBUG=1 DUSE_FILE32APIDTARGET_OS_IPHONE isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdkWprotocol Wdeprecated-declarationsg ~~Wno-sign-conversion “~~DIBOutlet=attribute)" "~~DIBOutletCollection(ClassName)=attribute((iboutletcollection(ClassName)))” “~~DIBAction=void)attribute((ibaction)” miphoneos-version-min=4.3I/Users/tranduc/Library/Developer/Xcode/DerivedData/Dino-exxaxhcxfgcxgyhafemhztmmqdys/Build/Intermediates/Dino.build/Debug-iphoneos/Dino.build/Dino.hmap IDino/libsI/Users/tranduc/Library/Developer/Xcode/DerivedData/Dino-exxaxhcxfgcxgyhafemhztmmqdys/Build/Products/Debug-iphoneos/include IDino/libs/cocos2dx/kazmath/includeIDino/libs/cocos2dx IDino/libs/CocosDenshion/includeI/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/include/libxml2 IDino/libs/cocos2dx/includeIDino/libs/cocos2dx/platform/third_party/ios IDino/libs/cocos2dx/platform/iosI/Users/tranduc/Library/Developer/Xcode/DerivedData/Dino-exxaxhcxfgcxgyhafemhztmmqdys/Build/Intermediates/Dino.build/Debug-iphoneos/Dino.build/DerivedSources/armv7 I/Users/tranduc/Library/Developer/Xcode/DerivedData/Dino-exxaxhcxfgcxgyhafemhztmmqdys/Build/Intermediates/Dino.build/Debug-iphoneos/Dino.build/DerivedSourcesF/Users/tranduc/Library/Developer/Xcode/DerivedData/Dino-exxaxhcxfgcxgyhafemhztmmqdys/Build/Products/Debug-iphoneos F/Users/tranduc/Documents/WorkAIT/SVN_DINO_Code/dino/iosProj/Dino —serialize-diagnostics /Users/tranduc/Library/Developer/Xcode/DerivedData/Dino-exxaxhcxfgcxgyhafemhztmmqdys/Build/Intermediates/PrecompiledHeaders/Prefix-dgalaaouttqoqbhaerdnnbxrmbrm/Prefix.pch.diac /Users/tranduc/Documents/WorkAIT/SVN_DINO_Code/dino/iosProj/Dino/Dino/Prefix.pch o /Users/tranduc/Library/Developer/Xcode/DerivedData/Dino-exxaxhcxfgcxgyhafemhztmmqdys/Build/Intermediates/PrecompiledHeaders/Prefix-dgalaaouttqoqbhaerdnnbxrmbrm/Prefix.pch.pthMMD MT dependenciesMF /Users/tranduc/Library/Developer/Xcode/DerivedData/Dino-exxaxhcxfgcxgyhafemhztmmqdys/Build/Intermediates/PrecompiledHeaders/Prefix-dgalaaouttqoqbhaerdnnbxrmbrm/Prefix.pch.d

In file included from /Users/tranduc/Documents/WorkAIT/SVN_DINO_Code/dino/iosProj/Dino/Dino/Prefix.pch:6:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:38:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:62:
In file included from /Users/tranduc/Documents/WorkAIT/SVN_DINO_Code/dino/iosProj/Dino/Dino/…/…/…/Classes/Block.h:3:
In file included from /Users/tranduc/Documents/WorkAIT/SVN_DINO_Code/dino/iosProj/Dino/Dino/libs/cocos2dx/include/cocos2d.h:41:
In file included from Dino/libs/cocos2dx/actions/CCAction.h:30:
Dino/libs/cocos2dx/cocoa/CCObject.h:37:1: error: unknown type name ‘class’; did you mean ‘Class’?
class CCZone;
^
note: ‘Class’ declared here
Dino/libs/cocos2dx/cocoa/CCObject.h:38:1: error: unknown type name ‘class’; did you mean ‘Class’?
class CCObject;
^
note: ‘Class’ declared here
Dino/libs/cocos2dx/cocoa/CCObject.h:39:1: error: unknown type name ‘class’; did you mean ‘Class’?
class CCNode;
—————————>>>>><<<<<<————————

Is there any class named Block in your project ?

1 Like

Than you SO much catcheruk. You saved me days of work. I was getting that nasty error and didn’t know what to do until I read your message. I changed the name of my Block class and also an array with that same name and now everything works :smile:

Thanks again

1 Like

You are welcome. :smiley: