前提・実現したいこと
FireBaseと連携したアプリを実行したい。
発生している問題・エラーメッセージ
M1Macでflutterの環境構築を実施し、flutter doctorで全てのチェック項目に問題ないことを実施。
vs codeにてcodeは記述しsimulstorも問題なく動いていることを確認。
FireBaseと連携したcodeをデバックしようとしたところcocoapodsのエラーが発生。
※環境構築時cocoapodsがインストールされていることは確認。
エラーメッセージ Warning: CocoaPods is installed but broken. Skipping pod install. You appear to have CocoaPods installed but it is not working. This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it. This can usually be fixed by re-installing CocoaPods. To re-install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions. CocoaPods not installed or not in valid state. Error launching application on iPhone 13.
該当のソースコード
flutter
1import 'package:cloud_firestore/cloud_firestore.dart'; 2import 'package:firebase_core/firebase_core.dart'; 3import 'package:flutter/material.dart'; 4 5void main() async{ 6 WidgetsFlutterBinding.ensureInitialized(); 7 await Firebase.initializeApp(); 8 runApp(MyApp()); 9} 10 11class MyApp extends StatelessWidget { 12 const MyApp({Key? key}) : super(key: key); 13 14 @override 15 Widget build(BuildContext context) { 16 return MaterialApp( 17 title: "Dog Name Voting", 18 home: MyHomePage(), 19 ); 20 } 21} 22 23class MyHomePage extends StatefulWidget { 24 const MyHomePage({Key? key}) : super(key: key); 25 26 @override 27 _MyHomePageState createState() { 28 return _MyHomePageState(); 29 } 30} 31 32class _MyHomePageState extends State<MyHomePage> { 33 @override 34 Widget build(BuildContext context) { 35 return Scaffold( 36 appBar: AppBar(title: const Text("Dog Name Voting")), 37 body: _buildBody(), 38 ); 39 } 40 41 Widget _buildBody() { 42 return StreamBuilder<QuerySnapshot>( 43 stream: FirebaseFirestore.instance.collection("dogs").snapshots(), 44 builder: (context, snapshot) { 45 if (!snapshot.hasData) return const LinearProgressIndicator(); 46 return _buildList(snapshot.data!.docs); 47 }, 48 ); 49 } 50 51 Widget _buildList(List<DocumentSnapshot> snapList) { 52 return ListView.builder( 53 padding: const EdgeInsets.all(18.0), 54 itemCount: snapList.length, 55 itemBuilder: (context, i) { 56 return _buildListItem(snapList[i]); 57 } 58 ); 59 } 60 61 Widget _buildListItem(DocumentSnapshot snap) { 62 Map<String, dynamic> data = snap.data(); 63 64 return Padding( 65 padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical:9.0), 66 child: Container( 67 decoration: BoxDecoration( 68 border: Border.all(color: Colors.grey), 69 borderRadius: BorderRadius.circular(8.0), 70 ), 71 child: ListTile( 72 title: Text(data["name"]), 73 trailing: Text(data["votes"].toString()), 74 onTap: () => snap.reference.update({"votes": FieldValue.increment(1)}), 75 ), 76 ), 77 ); 78 } 79}
試したこと
cocoapodsを再度インストールしようとしたがエラーが発生。
sudo gem install cocoapods
Building native extensions. This could take a while... ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension. current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/ext/ffi_c /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20211209-5702-1lb2u7p.rb extconf.rb checking for ffi.h... *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME) --with-ffi_c-dir --without-ffi_c-dir --with-ffi_c-include --without-ffi_c-include=${ffi_c-dir}/include --with-ffi_c-lib --without-ffi_c-lib=${ffi_c-dir}/lib --enable-system-libffi --disable-system-libffi --with-libffi-config --without-libffi-config --with-pkg-config --without-pkg-config /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `block in try_compile' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:534:in `with_werror' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `try_compile' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1109:in `block in have_header' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1108:in `have_header' from extconf.rb:10:in `system_libffi_usable?' from extconf.rb:42:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.15.4/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4 for inspection. Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.15.4/gem_make.out
mkmflog
1package configuration for libffi is not found 2"xcrun clang -o conftest -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin20 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/backward -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -DUSE_FFI_CLOSURE_ALLOC conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib -L. -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.6.Internal.sdk/usr/local/lib -lruby.2.6 " 3In file included from conftest.c:1: 4In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33: 5/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found 6#include "ruby/config.h" 7 ^~~~~~~~~~~~~~~ 8/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header 'config.h' in framework 'ruby' (loaded from '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks') 91 error generated. 10checked program was: 11/* begin */ 121: #include "ruby.h" 132: 143: int main(int argc, char **argv) 154: { 165: return 0; 176: } 18/* end */ 19 20
あなたの回答
tips
プレビュー