Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

環境

  1. macOS 10.13.3 (英語)
  2. Xcode 9.2
  3. CocoaPods 1.4.0

CocoaPod 作成手順

  1. ヘッダーファイルとライブラリを cocos2d-x からコピー

    $ mkdir pod-cocos2d-x-kenichi-3.16.0.0
    $ cd pod-cocos2d-x-kenichi-3.16.0.0
    $ mkdir Headers
    $ (cd ../cocos2d-x/cocos; tar cf - `find . -name '*.h' -not -path '*/android/*'`) | (cd Headers; tar xzf -)
    $ (cd ../cocos2d-x/cocos; tar cf - `find . -name '*.inl'`) | (cd Headers; tar xzf -)
    
    $ mkdir Libraries
    $ cp -p "../cocos2d-x/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.16.0.0.tar.bz2 pod-cocos2d-x-kenichi-3.16.0.0
    
  3. pod-cocos2d-x-kenichi-3.16.0.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/"
      s.platform     = :ios, "8.0"
      s.source       = { :http => "https://10.10.10.10/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. https://10.10.10.10/ は適当に置き換える事
    2. CocoaPods-1.0.0: source:type を指定しないと Unsupported file type エラー

CocoaPod 利用手順

  1. Podfile を作成

    platform :ios, '10.0'
    use_frameworks!
    
    target 'HelloCpp-mobile' do
      pod 'cocos2d-x-kenichi', :podspec => 'https://10.10.10.10/pod-cocos2d-x-kenichi-3.16.0.0.podspec'
    end
    
  2. Pod をインストール

    $ pod install
    Analyzing dependencies
    Fetching podspec for `cocos2d-x-kenichi` from `https://10.10.10.10/pod-cocos2d-x-kenichi-3.16.0.0.podspec`
    Downloading dependencies
    Installing cocos2d-x-kenichi (3.16.0.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
    
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away