はじめに
Flutterを一年ぶりくらいに触ってほぼ初心者がmobilenetを使った学習データをつかうために利用したtfliteのサンプルを動かす履歴です。
ハマりどころを覚えている限り残しており、抜けがあったらすみません。
環境
- Mac(Mojave)
- VSCode(1.43.1)
- Xcode(11.3.1)
iOS開発者プログラムに無料版、有料版での登録が必要です。
VSCodeで新規プロジェクトをつくる前に
Objective-Cを指定します。swiftを指定だとエラーがでて、動作もおかしいアプリになりました。
そのため設定を変更し、ユーザー
タブで設定変更してますが、他でswiftを使う場合はワークスペース
タブで指定して
VSCodeで新規プロジェクト
https://github.com/shaqian/flutter_tflite#usage
より
assetsフォルダを作成
サンプルにあるassetsのファイルを追加
pubspec.yamlにassets,tfliteの記述を追加
lib/main.dart
Xcodeで修正
flutter build ios
などでpodまわりでのエラーが多発し、その対処をした結果次の手順になりました。
Runner.xcworkspaceから起動します。
Signing & Capabilities
Teamには有料版でも無料版でもiOS開発者プログラムで発行されているものを指定します。
今回は無料版を設定しています(Personal Team)
General
- Bundle Identifier(任意)
- Deployment target(iOS9以上に変更)
出力されたエラー
- DEPLOYMENT_TARGETが設定されていない気がして、iOS9に
- Podfileのことを示唆されているとしてUncomment
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
1
Resolving dependencies of `Podfile`
CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking
is only perfomed in repo update
[!] CocoaPods could not find compatible versions for pod "tflite":
In Podfile:
tflite (from `.symlinks/plugins/tflite/ios`)
Specs satisfying the `tflite (from `.symlinks/plugins/tflite/ios`)` dependency were found,
but they required a higher minimum deployment target.
[!] Automatically assigning platform `iOS` with version `8.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`.
2
warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 4.3, but the
range of supported deployment target versions is 8.0 to 13.2.99. (in target
'image_picker' from project 'Pods')
その他
https://github.com/shaqian/flutter_tflite#ios
より
'tensorflow/lite/kernels/register.h' file not found
CONTRIB_PATHのコメント、アンコメント。これが一番格闘する相手になりました。
さいごに
サンプルは設定済みのiOSプロジェクトが入っているので、概ねMacでの環境設定ができればうまく行くのですが、VSCodeから作成されたプロジェクトはどうしてもうまく行きませんでした。
VSCodeでProject作成時にポップアップでflutterコマンドのオプションが表示されているのをみてswiftで作成されていることに気づきました。
あとはサンプルの中のプロジェクトとの差分を確認する作業がほとんどです。
自分のコードを書くのはこれからです。