環境
- Mac OS X 10.11.6 (英語)
- Xcode 7.3.1
- Cocos2d-x 3.13.1
- CocoaPods 1.0.0
CocoaPod 作成手順
-
ヘッダーファイルとライブラリを cocos2d-x からコピー
$ mkdir pod-cocos2d-x-kenichi-3.13.1.0 $ cd pod-cocos2d-x-kenichi-3.13.1.0 $ mkdir Headers $ (cd ../cocos2d-x-3.13.1/cocos; tar cf - `find . -name '*.h' -not -path '*/android/*'`) | (cd Headers; tar xzf -) $ (cd ../cocos2d-x-3.13.1/cocos; tar cf - `find . -name '*.inl'`) | (cd Headers; tar xzf -) $ mkdir Libraries $ cp -p "../cocos2d-x-3.13.1/build/libcocos2d iOS.a" Libraries/libcocos2d-iOS.a
-
tar してアップロード
$ cd .. $ tar cjf pod-cocos2d-x-kenichi-3.13.1.0.tar.bz2 pod-cocos2d-x-kenichi-3.13.1.0
-
pod-cocos2d-x-kenichi-3.13.1.0.podspec
を作成してアップロードPod::Spec.new do |s| s.name = "cocos2d-x-kenichi" s.version = "3.13.1.0" s.summary = "cocos2d-x prebuild libraries for armv7, armv7s, arm64, i386, x86_64" s.author = "Kenichi" s.license = "MIT" s.homepage = "http://52.197.254.50/kenichi" s.platform = :ios, "8.0" s.source = { :http => "http://52.197.254.50/kenichi/pod-cocos2d-x-kenichi-3.13.1.0.tar.bz2", :type => :tbz } s.preserve_paths = "Headers/**/*.{h,inl}" s.public_header_files = "Headers/**/*.{h,inl}" s.header_mappings_dir = "Headers" s.vendored_libraries = 'Libraries/libcocos2d-iOS.a' # CocoaPods-1.0.0 messes up OTHER_LDFLAGS in xcconfig if the path contains a space s.frameworks = [ "AudioToolbox", "CoreMotion", "AVFoundation", "GameController", "MediaPlayer", "OpenAL" ] # AVFoundation, GameController, MediaPlayer, OpenAL are needed because CocoaPods adds -ObjC flag s.libraries = [ "z", "iconv" ] s.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'USE_FILE32API CC_ENABLE_CHIPMUNK_INTEGRATION=1' } # TODO: COCOS2D_DEBUG=1 should also be added for Debug configuration end
-
cocos2d-x の static ライブラリをビルドしたものを使った
-
ライブラリファイル名がスペースを含むと CocoaPods-1.0.0 は間違った xcconfig ファイルを生成してしまうので
-
に置換した -
source の :type を指定しないと
Unsupported file type
エラー
CocoaPod 利用手順
-
Podfile を作成
platform :ios, '8.0' use_frameworks! target 'ios-storyboard-cocos2dx' do pod 'cocos2d-x-kenichi', :podspec => 'http://10.10.10.10/kenichi/pod-cocos2d-x-kenichi-3.13.1.0.podspec' end
-
Pod をインストール
$ pod install Analyzing dependencies Fetching podspec for `cocos2d-x-kenichi` from `https://onedrive.live.com/download?cid=9F527730D70015D4&resid=9F527730D70015D4%21109&authkey=AAQFXJwi2CGgHO0` Downloading dependencies Installing cocos2d-x-kenichi 3.13.1.0 Generating Pods project Integrating client project [!] Please close any current Xcode sessions and use `ios-storyboard-cocos2dx.xcworkspace` for this project from now on. Sending stats Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
-
おまけ: Podfile に以下を追加して Debug 時に COCOS2D_DEBUG=1 を定義したかったが、効かなかった
post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['COCOS2D_DEBUG=1'] end end end