LoginSignup
15
14

More than 5 years have passed since last update.

XCode6.3でAlamofire-SwiftyJSONを使う

Last updated at Posted at 2015-06-07

iOS アプリ開発 Swift対応版」に書かれていた、
Alamofire-SwiftyJSONを導入する方法がうまくいかなかったので解決策をメモ。

  1. Podのinstall

この記事を参考に、以下のPodfileをinstall。

Podfile
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.2'
use_frameworks!

# for Xcode6.3
pod 'Alamofire', '~> 1.2.0'

# for Xcode6.3
pod 'SwiftyJSON'

# Alamofire-SwiftyJSON
pod 'Alamofire-SwiftyJSON', :git => "https://github.com/SwiftyJSON/Alamofire-SwiftyJSON.git"

pod 'SDWebImage' 

target 'GourmetSearch' do

end

target 'GourmetSearchTests' do

end

2.「segmentation fault: 11」エラーを解消

stackoverflowの以下のAnswerを参考に解消。

Alamofireモジュール等がビルドできていないことが原因でした。

XCODEの左上の■ボタンの右隣のビルドターゲットにAlamofire等が表示されていなかったので、
Manage Schemes で Pods-[Target名]-Alamofire等の>Showにチェックを入れました。

するとビルドターゲットに表示されたので、Alamofire、SwiftyJSON、Alamofire-SwiftyJSONの
順番でビルドしてから、自分のプロジェクトを最後にビルドすると、該当のエラーは消えました。

3.実機ビルド時に発生した例外を解決

iPhone5(iOS8.3)にビルドしようとしたところ、以下の例外が発生。

module.modulemap:10:12: error: header 'SwiftyJSON-Swift.h' not found

「SwiftyJSON-Swift.h」で検索してみたが、該当するファイルはない。
以下のようにエラー部分をコメントアウトしたらビルドできた。

module.modulemap
framework module SwiftyJSON {
  umbrella header "SwiftyJSON.h"

  export *
  module * { export * }
}

module SwiftyJSON.Swift {
    //実機ビルド時にエラーになったのでコメントアウト
    //header "SwiftyJSON-Swift.h"
}

このエラー、ビルド対象がシミューレータだと発生しない。なぜだろう。

15
14
4

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
15
14