LoginSignup
18
14

More than 1 year has passed since last update.

Flutter: CocoaPodからパッケージをインストールする際に起きたエラーの対処

Posted at

バーコードをスキャンする処理を勉強したくて公式サイトからflutter_barcode_scanner 2.0.0のサンプルアプリをダウンロードした後、ドキュメント通りにpod installをしたところ警告が発生。
スクリーンショット 2021-06-30 14.10.02.png

[!] Automatically assigning platform `iOS` with version `12.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` in your build configuration (`Flutter/Release.xcconfig`).

[!] Your project does not explicitly specify the CocoaPods master specs repo. Since CDN is now used as the default, you may safely remove it from your repos directory via `pod repo remove master`. To suppress this warning please add `warn_for_unused_master_specs_repo => false` to your Podfile.

この状態でiosの実機にビルドするとエラーが発生。

Xcode build done.                                           10.6s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Analyzing workspace
    note: Constructing build description
    note: Build preparation complete
    /(ファイルの場所)/flutter_barcode_scanner-2.0.0/example/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target 'Flutter' from project 'Pods')
    error: No profiles for 'com.amolg.flutterBarcodeScannerExamplePOC' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.amolg.flutterBarcodeScannerExamplePOC'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'Runner' from project 'Runner')

Could not build the precompiled application for the device.

Error launching application on iPhone.

対処1 IOSのバージョンを指定する

Podfileを選択し、二行目にあるコメントアウトされたコードを有効化し、手動でバージョンを指定する。エラー内容を見る限り、9.0〜14.5.99までのバージョンにする。
スクリーンショット 2021-06-30 14.18.43.png

Swiftで開発していたときに、データベース管理システムのRealmCocoaPodでインストールした際も同じエラーに遭遇した。バージョン指定は手動で行わないとエラーになるらしい。

対処2 CocoaPodの.xcconfigという設定ファイルの内容をFlutterに反映できるようにする

FlutterはCocoaPodとは別に.xcconfigファイルを独自に所有しており、デフォルトの状態だとCocoaPodで変更した内容が反映されないため、それができるように該当のファイルにコードを追記する。
example/ios/Flutter/Release.xcconfigに以下のコードを追記

#include "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"

スクリーンショット 2021-06-30 14.31.56.png

参考記事:FlutterでCocoaPodsのライブラリを使う

対処3 XcodeでIOSプロジェクトを開き、Signing&Capabillitiesのページで発生しているエラーを解決する

スクリーンショット 2021-06-30 14.49.21.png
Teamの項目がUnknown Nameになっていたので自分のアカウントに変更する。
他の記事を見たところ、Teamの上にあるAoutomatically manage signingのチェックを外すと治る場合もあるそうです。

あとはexample/ios/pod updateをしてからビルドすれば成功しました。

参考にした記事によると、このパッケージに限ったことではないみたいです。
また、Firebaseに関係するパッケージの場合はまた違った処理をしなくてはならないため、今後もこのようなエラーと戦っていくことになりそうです。。。

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