Thatchai
1 min readDec 2, 2019

วิธีเพิ่ม firebase sdk ใน cocos2d [iOS] 2019/12

1 create firebase project

2 download Firebase C++ SDK
down จาก https://firebase.google.com/download/cpp?hl=ja
แล้ว extract sdk ไปไว้ที่ใน folder ระดับเดียวกับ [proj.ios-mac]

3 create pod
ไปที่ [proj.ios-mac] แล้วสร้าง pod

pod init

เพิ่ม

# Uncomment the next line to define a global platform for your project
source 'https://github.com/CocoaPods/Specs.git' # add
platform :ios, '8.0'

target 'MyTest-desktop' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!

# Pods for MyTest-desktop

end

target 'MyTest-mobile' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!

# Pods for MyTest-mobile
pod 'Firebase' # add
pod 'Firebase/Analytics' # add


end

install

pod install

4 open xcode แก้ไข setting
เพิ่ม $(inherited) ลงใน
Other Linker Flags
Preprocessor Macros
Library Search Paths

ที่ Framework Search Paths ใส่
$(PROJECT_DIR)/../firebase_cpp_sdk/frameworks/ios/universal
ในนี้จะต้องมี ${PODS_ROOT}/FirebaseAnalytics/Frameworks กับ ${PODS_ROOT}/GoogleAppMeasurement/Frameworks อยู่ด้วย

ที่ Header Search Paths ใส่ $(PROJECT_DIR)/../firebase_cpp_sdk/include

เพิ่ม Lib ที่จะใช้เข้าไป หา lib จาก firebase_cpp_sdk/frameworks/ios/universal

Linked Frameworks and Libraries เพิ่ม
MediaPlayer.framework
GameController.framework

AppDelegate.mm

#import "AppController.h"
#import "cocos2d.h"
#import "AppDelegate.h"
#import "RootViewController.h"
#import <Firebase/Firebase.h> // add

...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[FIRApp configure]; // add

...
}

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Thatchai
Thatchai

No responses yet

Write a response