Environment
cocos2d for iPhone 2.1Xcode 7.3
What's happened.
Build app with cocos2d 2.1 and then run that. Xcode will show you this below.cocos2d: ERROR: Failed to compile shader cocos2d: ERROR: 0:12: '' : syntax error: #extension must always be before any non-preprocessor tokens
What should I do?
Edit CCGLProgram.m to add some codes (BOOL)compileShader method.
- - (BOOL)compileShader:(GLuint *)shader type:(GLenum)type byteArray:(const GLchar *)source
- {
- GLint status;
- if (!source)
- return NO;
// ADD Start BOOL hasExtension = NO; NSString *sourceStr = [NSString stringWithUTF8String:source]; if([sourceStr rangeOfString:g_extensionStr].location != NSNotFound) { hasExtension = YES; NSArray *strs = [sourceStr componentsSeparatedByString:g_extensionStr]; assert(strs.count == 2); sourceStr = [strs componentsJoinedByString:@"\n"]; source = (GLchar *)[sourceStr UTF8String]; } // ADD End- const GLchar *sources[] = {
// ADD Start (hasExtension ? EXTENSION_STRING "\n" : ""), // ADD End- #ifdef __CC_PLATFORM_IOS