FlutterをiOSでビルドしようとしたとき、エラーが出た。
とりあえず現時点(2020/10/19)での解決法をメモしておく。
初期環境
- Xcode 12.1
- Cocoapods 1.9.3
- Dart 2.10.0
- Flutter 1.22.0
- Bundler 2.1.4
以下エラー。
Xcode build done. 115.3s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
In file included from /Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBWrappers.pbobjc.m:11:
/Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBProtocolBuffers_RuntimeSupport.h:34:9: warning: double-quoted include "GPBBootstrap.h" in framework header, expected angle-bracketed instead [-Wquoted-include-in-framework-header]
#import "GPBBootstrap.h"
^~~~~~~~~~~~~~~~
<GPBBootstrap.h>
/Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBProtocolBuffers_RuntimeSupport.h:36:9: warning: double-quoted include "GPBDescriptor_PackagePrivate.h" in framework header, expected angle-bracketed instead [-Wquoted-include-in-framework-header]
#import "GPBDescriptor_PackagePrivate.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<GPBDescriptor_PackagePrivate.h>
In file included from /Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBWrappers.pbobjc.m:11:
In file included from /Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBProtocolBuffers_RuntimeSupport.h:36:
/Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBDescriptor_PackagePrivate.h:35:9: warning: double-quoted include "GPBDescriptor.h" in framework header, expected angle-bracketed instead [-Wquoted-include-in-framework-header]
#import "GPBDescriptor.h"
^~~~~~~~~~~~~~~~~
<GPBDescriptor.h>
In file included from /Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBWrappers.pbobjc.m:11:
In file included from /Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBProtocolBuffers_RuntimeSupport.h:36:
In file included from /Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBDescriptor_PackagePrivate.h:35:
/Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBDescriptor.h:33:9: warning: double-quoted include "GPBRuntimeTypes.h" in framework header, expected angle-bracketed instead [-Wquoted-include-in-framework-header]
#import "GPBRuntimeTypes.h"
^~~~~~~~~~~~~~~~~~~
<GPBRuntimeTypes.h>
In file included from /Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBWrappers.pbobjc.m:11:
In file included from /Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBProtocolBuffers_RuntimeSupport.h:36:
In file included from /Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBDescriptor_PackagePrivate.h:35:
In file included from /Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBDescriptor.h:33:
どうも、Xcode12からはimportにdouble-quoteは使えなくなった様。
https://developer.apple.com/forums/thread/651941
ただ、ライブラリ側が対応できていないものが多いので、Xcode上で無効にする。
https://developer.apple.com/forums/thread/651941?answerId=617655022#617655022
この後、AndroidStudioでiOS向けにビルドすると、再度エラーが起こったので File -> Invalidate Caches / Restart ...
でAndroidStudioを再起動した。
CI上での設定
ローカルでビルドすることはできたが、CI上でビルドしようとすると同様のエラーが発生した。
CIを使うときは、Preview版のCocoapodsを使うとできたぞと書かれていたので設定する。
If you're getting this locally, upgrade CocoaPods. If your CI is getting this error, force the CocoaPods version to 1.10.0.rc.1.
// 前略
before_install:
- gem uninstall -ax cocoapods # <- 追加
- gem install cocoapods -v 1.10.0.rc.1 # <- 追加
- bundle install
- npm install -g firebase-tools
// 後略
ビルドできなかった。
Xcode build done. 113.7s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
error: the following command failed with exit code 0 but produced no further output
CompileC /Users/travis/Library/Developer/Xcode/DerivedData/Runner-hdibzqvbombrjjhkjascueuffcef/Build/Intermediates.noindex/Pods.build/Release-Develop-iphoneos/Protobuf.build/Objects-normal/armv7/GPBWrappers.pbobjc.o /Users/travis/build/Cookbiz/wakumin-app/ios/Pods/Protobuf/objectivec/GPBWrappers.pbobjc.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cocoapodsのバージョンを上げたのになぁと思って、上の方を見ると、、、
$ bundle install
Fetching gem metadata from https://rubygems.org/........
...中略...
Fetching cocoapods 1.9.3
Installing cocoapods 1.9.3
Using colored 1.2
あー・・・・・・。bundleか・・・・・・。
このプロジェクトはfastlaneを使っていて、bundle install をしているのでした。
ビルドに使われるpodは多分こっちになったのかな。
ということで、
source "https://rubygems.org"
gem "fastlane"
gem 'cocoapods', "1.10.0.rc.1" <= ここを指定
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
としてもう一度走らせると、、、
Running pod install... 214.8s (!)
Running Xcode build...
└─Compiling, linking and signing... 60.2s
Xcode build done. 561.4s
無事CIビルドができた
<追記>
cocoapods 1.10.0が出ているので、gemを修正。
source "https://rubygems.org"
gem "fastlane"
gem 'cocoapods', "1.10.0" <= ここを指定
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
補記
それはそうとこのビルド時間なんとかならないのか・・・・・・。
FlutterビルドとFastlaneビルド合わせて25分くらいビルドしている・・・・・。