Movatterモバイル変換


[0]ホーム

URL:


LoginSignup
55

Go to list of users who liked

51

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Objective-C製プロジェクトにSwift製フレームワークを混ぜるときのエラーとその対策

Last updated atPosted at 2015-01-16

これまでObjective-Cだけで作ってきたプロジェクトに、Swift製のフレームワークをimport&embedして実行すると、次のような実行時エラーが出てアボートすることがあります。

dyld: Library not loaded: @rpath/libswiftCore.dylib  Referenced from: /private/var/mobile/Containers/Bundle/Application/A593E29F-12A5-4C42-A81E-E192AB7A99EB/foo.app/Frameworks/MySwiftFramework.framework/MySwiftClass  Reason: image not found

このエラーは、Swift製フレームワークからSwiftの標準ライブラリをdyld(3)しようとしたものの、そういうファイルは無いからロードできなかったために発生しています。Swiftの標準ライブラリはアプリにバンドルされたものを使うので(将来は変わるかも)、アプリの設定によって、きちんとバンドルしてあげないといけないのです。

この場合、ターゲットのBuild Settingsにある**[Build Options]-[Embeedded Content Contains Swift Code]**が、きちんとYesになっているかどうかをチェックします。そして、もしNoになっていたらYesに変更することで、解決するはずです。

ビルド設定のEmbeedded Content Contains Swift Codeをチェック

きちんとYesになっていれば、次図のようにアプリのバンドル内に一連のSwift用ライブラリも含まれ、無事に動くようになります。

SwiftLibs.png

この設定、Objective-Cとしてプロジェクトを作成した場合はデフォルトでOFFなので(当然と言えば当然ですが)、注意が必要です。

55

Go to list of users who liked

51
0

Go to list of comments

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
55

Go to list of users who liked

51

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?


[8]ページ先頭

©2009-2025 Movatter.jp