Realm導入
参考
CocoaPod導入
ターミナルで以下のコマンドを実行(場所はどこでも良い)
sudo gem install cocoapods
インストールが終わったら以下のコマンド
pod setup
CocoaPodをプロジェクトに適用
ターミナルでxcodeprojファイルがある場所へ移動。
下記のコマンドを実行してディレクトリ内に Podfile を作成する。
pod init
Podfileを編集。
vi Podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'アプリ名' do
pod 'RealmSwift'
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for アプリ名
最後にpod install
を行う。
pod install
処理が完了したら[プロジェクト名].wordkspaceというファイルが作成される。
プロジェクトが開いていたら一旦閉じて[プロジェクト名].wordkspaceを開く。
※CocoaPodsを使用する場合は常にこの[プロジェクト名].wordkspaceで開く。