LoginSignup
1
1

More than 5 years have passed since last update.

cocos2d-x-3.14.1 の static ライブラリを CocoaPod にする

Last updated at Posted at 2017-04-10

環境

  1. Mac OS X 10.12.4 (英語)
  2. Xcode 8.3.1
  3. CocoaPods 1.2.0

CocoaPod 作成手順

  1. ヘッダーファイルとライブラリを 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
    
    1. kenichi は適当に置き換える事
    2. cocos2d-x の static ライブラリをビルドしたライブラリを使った
    3. CocoaPods-1.0.0: ライブラリファイル名がスペースを含むと間違った xcconfig ファイルを生成してしまうので - に置換した
  2. tar してアップロード

    $ cd ..
    $ tar cjf pod-cocos2d-x-kenichi-3.14.1.0.tar.bz2 pod-cocos2d-x-kenichi-3.14.1.0
    
  3. 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
    
    1. 10.10.10.10 は適当に置き換える事
    2. CocoaPods-1.0.0: source:type を指定しないと Unsupported file type エラー

CocoaPod 利用手順

  1. 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
    
  2. 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.
    
  3. おまけ: 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
    
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1