環境
- Mac OS X 10.12.4 (英語)
- Xcode 8.3.1
- CocoaPods 1.2.0
CocoaPod 作成手順
-
ヘッダーファイルとライブラリを cocos2d-x からコピー
$ mkdir pod-cocos2d-x-kenichi-3.14.1.0 $ cd pod-cocos2d-x-kenichi-3.14.1.0 $ mkdir Headers $ (cd ../cocos2d-x-3.14.1/cocos; tar cf - `find . -name '*.h' -not -path '*/android/*'`) | (cd Headers; tar xzf -) $ (cd ../cocos2d-x-3.14.1/cocos; tar cf - `find . -name '*.inl'`) | (cd Headers; tar xzf -) $ mkdir Libraries $ cp -p "../cocos2d-x-3.14.1/build/libcocos2d iOS.a" Libraries/libcocos2d-iOS.a
-
kenichi
は適当に置き換える事 -
cocos2d-x の static ライブラリをビルドしたライブラリを使った
-
CocoaPods-1.0.0: ライブラリファイル名がスペースを含むと間違った xcconfig ファイルを生成してしまうので
-
に置換した -
tar してアップロード
$ cd .. $ tar cjf pod-cocos2d-x-kenichi-3.14.1.0.tar.bz2 pod-cocos2d-x-kenichi-3.14.1.0
-
pod-cocos2d-x-kenichi-3.14.1.0.podspec
を作成してアップロードPod::Spec.new do |s| s.name = "cocos2d-x-kenichi" s.version = "3.14.1.0" s.summary = "cocos2d-x prebuild libraries for arm64, armv7, x86_64, i386" s.author = "Kenichi" s.license = "MIT" s.homepage = "https://10.10.10.10/dev/cocoapods/" s.platform = :ios, "8.0" s.source = { :http => "https://10.10.10.10/dev/cocoapods/pod-cocos2d-x-kenichi-3.14.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
-
10.10.10.10
は適当に置き換える事 -
CocoaPods-1.0.0:
source
の:type
を指定しないとUnsupported file type
エラー
CocoaPod 利用手順
-
Podfile を作成
platform :ios, '8.0' use_frameworks! target 'HelloCpp-mobile' do pod 'cocos2d-x-kenichi', :podspec => 'http://10.10.10.10/dev/cocoapods/pod-cocos2d-x-kenichi-3.14.1.0.podspec' end
-
Pod をインストール
$ pod install Analyzing dependencies Fetching podspec for `cocos2d-x-kenichi` from `https://10.10.10.10/dev/cocoapods/pod-cocos2d-x-kenichi-3.14.1.0.podspec` Downloading dependencies Installing cocos2d-x-kenichi (3.14.1.0) Generating Pods project Integrating client project [!] Please close any current Xcode sessions and use `HelloCpp.xcworkspace` for this project from now on. Sending stats Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
-
おまけ: CocoaPods-1.0.0 で 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