Skip to content

Instantly share code, notes, and snippets.

@jake1256
Created October 26, 2014 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jake1256/9386f26024cc5132b421 to your computer and use it in GitHub Desktop.
Save jake1256/9386f26024cc5132b421 to your computer and use it in GitHub Desktop.
【iOS】Xcodeでビルドした時にNSObjCRuntimeでエラー?【cocos2d-x】 ref: http://qiita.com/kuuki_yomenaio/items/6edc7cb16a81d2bc9ef5
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:397:1: error: expected unqualified-id
@class NSString, Protocol;
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:399:19: error: unknown type name 'NSString'
FOUNDATION_EXPORT NSString *NSStringFromSelector(SEL aSelector);
// NativeUtil.cpp
#include "NativeUtil.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#import <objc/runtime.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
/**
* URLを指定して端末ブラウザと連携する
*/
void NativeUtil::showWebBrowser(std::string url)
{
NSString *urlString = [NSString stringWithFormat:@"%s" , url.c_str()];
NSURL *nsUrl = [NSURL URLWithString:urlString];
// ブラウザを起動する
[[UIApplication sharedApplication] openURL:nsUrl];
}
// NativeUtil.h
#ifndef __Cocos2dxNSObjCRuntimeErrorTest__NativeUtil__
#define __Cocos2dxNSObjCRuntimeErrorTest__NativeUtil__
#include <stdio.h>
class NativeUtil
{
public:
static void showWebBrowser(std::string url);
};
#endif /* defined(__Cocos2dxNSObjCRuntimeErrorTest__NativeUtil__) */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment