Carthage0.7.1の簡単な使い方

May 10, 2015

ここで書いているのは、Carthage/Carthageに記載があることです。

CarthageとCocoapodsの違い

Firstly, CocoaPods (by default) automatically creates and updates an Xcode workspace for your application and all dependencies. Carthage builds framework binaries using xcodebuild, but leaves the responsibility of integrating them up to the user. CocoaPods’ approach is easier to use, while Carthage’s is flexible and unintrusive.

Dynamic frameworks

Once you have Carthage installed, you can begin adding frameworks to your project. Note that Carthage only supports dynamic frameworks, which are only available on iOS 8 or later (or any version of OS X).

carthageコマンドのインストール

$ brew update $ brew carthage

HomebrewがまだMacに入っていない方はこちらから

用意

Carfileを作り下記にようにCarthage対応ライブラリを記述します。タグやブランチにも対応している。

github “ReactiveCocoa/ReactiveCocoa” >= 2.3.1

初回も、アップデート時も下記のコマンドでOKです。

$ carthage update

フレームワークを追加

Carthage/Build/iOS/CarthageSample.framework というフレームワークが出来上がっているので、プロジェクトのターゲットの General タブを開いて、Linked Frameworks and Libraries のところに、出来上がったフレームワークをドラッグアンドドロップします。

ビルドコマンドを記述

ターゲットの Build Phases+ ボタンを押して、New Run Script Phase を選びます。

/usr/local/bin/carthage copy-frameworks

を追加して、Input Filesのところに、

$(SRCROOT)/Carthage/Build/iOS/ReactiveCocoa.framework

というように今回利用するフレームワークへのパスを記述します。

これでOK!


Profile picture

Written by morizotter who lives and works in Tokyo building useful things. You should follow them on Twitter