情報系人間のブログ

プログラミング、開発に関することを書いていきます。

error: failed to import bridging headerとuse_frameworks!

swiftで書かれたライブラリをCocoaPodsでinstallする場合は

use_frameworks!

とpodfileに書かないと以下の警告が出ます。

[!] Pods written in Swift can only be integrated as frameworks; this feature is still in beta. Add `use_frameworks!` to your Podfile or target to opt into using it.

書いてある通り、swiftライブラリはframeworkを作成して統合されます。
通常objective-cライブラリはstatic libraryが作成されるのですが、use_frameworks!を書くと全てのライブラリをswiftの場合と同様にframeworkとしてリンクしようとするようです。
このためにuse_frameworks!を書いてobjective-cライブラリをbridging-header.hでimportするとエラーが発生します。
エラー内容はこんな感じです。

error: 'xxxxxxxx.h' file not found
error: failed to import bridging header

回避策ですが、bridging-header.hから

 #import "xxxxxxx.h"

を削除してライブラリを使用するswiftファイルに

import xxxxxxxxx

を追加すれば良いです。