LoginSignup
10
9

More than 5 years have passed since last update.

既存プロジェクトがXCode9でビルドできなかった時の対処メモ

Last updated at Posted at 2017-09-16

事象: XCode9でビルドできない

Module compiled with Swift 3.1 cannot be imported in Swift 3.2

XCode9で既存のプロジェクトを開いてビルドしようとすると上記のエラーが出た。
毎年同じような事をやってる気がするので対処方法をメモしておく。

原因

importしようとしているライブラリがSwift3.1でコンパイルされている。
具体的にはcarthageで入れているパッケージが原因だったので、これを解消してやれば良い。

対処

環境としてはGM版をXCode-9.GMという名前で別に入れている状態だったので、コマンドラインツールを切り替えてから--nouse-binariesオプションでcarthage updateする。

$ sudo xcode-select --switch /Applications/Xcode-9.GM.app/Contents/Developer
$ carthage update --platform iOS --no-use-binaries

※fastlaneでCarthageを利用してる場合はそちらも対応

ライブラリ自体がまだ対応されていない場合、branchがある場合などは適宜対応されているbranchesから取ってくるようにする。
例えばObjectMapperではPullRequestが出ている状態だったので、PullRequest元から取ってくるように変更した

#TODO: 暫定対応
#github "Hearst-DD/ObjectMapper" ~> 2.2
github "dclelland/ObjectMapper" "swift-3.2"

コマンドラインツールを元に戻す場合は以下

$ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

参考

10
9
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
10
9