LoginSignup
13
12

More than 5 years have passed since last update.

【初心者向け】徹底詳解!cocoapod + RealmでToDoアプリを作るチュートリアル (全4回)

Last updated at Posted at 2015-12-13

注意
このチュートリアルの最初のページはこちらになります。

!!手順2に行く前に!!

手順2ではpodコマンドやpod fileの話がメインになっていますので、

以下の記事などを参考に進めてください。

pod コマンドの導入方法

初めてのCocoaPods

podコマンドが上手くいかない場合の対応方法

[Swift]CocoaPodsを導入しようとして発生したエラー内容&対処方法(xcode6 beta4)

【詳解付き】【Podfile】pod installが途中で動かなくなる問題から解決まで

手順2 pod fileで外部ライブラリをビルドする。

手順2.1 作成したプロジェクトに移動し、vimを使ってPodfileの作成および更新を行う。

コマンド

vi Podfile

さらに「i」キーを押し、入力モードにして以下の内容を記入します。

Podfileの設定内容

target "TodoSample" do
    use_frameworks!
    pod 'RealmSwift'
end


入力後は「esc」キー押して編集モードに移行して「:wq」というコマンドで上書き + 強制終了を行います。

その後、podコマンドを使って外部ライブラリを読み込みます。

コマンド


pod install

結果


g08m11:TodoSample$ pod install
Updating local specs repositories

CocoaPods 0.39.0 is available.
To update use: `gem install cocoapods`
Until we reach version 1.0 the features of CocoaPods can and will change.
We strongly recommend that you use the latest version at all times.

For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.

Analyzing dependencies
Pre-downloading: `Realm` from `https://github.com/realm/realm-cocoa.git`, branch `swift-2.0`
Pre-downloading: `RealmSwift` from `https://github.com/realm/realm-cocoa.git`, branch `swift-2.0`
Downloading dependencies
Installing Realm (0.96.3)
Installing RealmSwift (0.96.3)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `TodoSample.xcworkspace` for this project from now on.
Sending stats
g08m11:TodoSample$

無事にインストールできましたら、「TodoSample.xcworkspace」というファイルが出来ます。
次回からは作成したプロジェクトではなくこちらの「TodoSample.xcworkspace」を開きます。
また、作成したプロジェクトは閉じましょう。
作成したプロジェクトが空いてる状態で「TodoSample.xcworkspace」を起動するとエラーが発生します。

!!【注意】手順3に行く前にビルドを実行!!

ToDo.swiftのimport RealmSwiftでエラーが出る場合があります。
その場合は一度、xcworkspaceを開いた後に「commandキー + b」(ビルド)を実行することで解消されますので手順3に行く前に「commandキー + b」(ビルド)を実行してください。

前へ

次へ

13
12
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
13
12