๐Ÿšจ [Flutter] CocoaPods installed but not working

dylanmskยท2023๋…„ 10์›” 17์ผ

์žฅ๋น„ ์ŠคํŽ™

  • M1 Mac mini
  • macOS Ventura 13.6

์ด์Šˆ ๋ฐœ์ƒ

์˜ค๋žœ๋งŒ์— Flutter๋ฅผ ๋‹ค์‹œ ํ•ด๋ณด๋ ค๊ณ  ์„ค์น˜๋ฅผ ํ•˜๋˜ ์™€์ค‘์— cocoapods ๋ผ๋Š”๊ฒŒ ์ž‘๋™ํ•˜์ง€ ์•Š๋Š”๋‹ค๋Š” ์—๋Ÿฌ๋ฅผ ๋งŒ๋‚ฌ๋‹ค.

โฏ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[โœ“] Flutter (Channel stable, 3.13.7, on macOS 13.6 22G120 darwin-arm64, locale
    ko-KR)
[โœ“] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 15.0)
    โœ— CocoaPods installed but not working.
        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.
[โœ“] Chrome - develop for the web
[โœ“] Android Studio (version 2022.3)
[โœ“] VS Code (version 1.82.2)
[โœ“] Connected device (2 available)
[โœ“] Network resources

์ด์Šˆ ํ•ด๊ฒฐ ์—ฌ์ •

1. cocoapods ์„ค์น˜

์ฒ˜์Œ์—๋Š” ๋Œ€์ˆ˜๋กญ์ง€ ์•Š๊ฒŒ ์œ„์— ๋‚˜์˜จ ๋งํฌ์— ๋“ค์–ด๊ฐ€์„œ 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.16.3/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 ./siteconf20231017-93806-nbnxjy.rb extconf.rb
*** 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-debug
	--disable-debug
	--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:546:in `block in try_link0'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:93:in `mktmpdir'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:543:in `try_link0'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:672:in `try_ldflags'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1832:in `pkg_config'
	from extconf.rb:9:in `system_libffi_usable?'
	from extconf.rb:46: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-22/2.6.0/ffi-1.16.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.16.3 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-22/2.6.0/ffi-1.16.3/gem_make.out

2. ruby ๋ฒ„์ „ ์ด์Šˆ ๋ฐœ์ƒ

๊ตฌ๊ธ€๋ง ํ•ด๋ณด๋‹ˆ M1์นฉ์—์„œ ๋ฐœ์ƒํ•˜๋Š” ์—๋Ÿฌ๋ผ๊ณ  ํ•˜๋Š”๋ฐ ruby ๋ฒ„์ „์„ ์˜ฌ๋ฆฌ๋ฉด ํ•ด๊ฒฐ๋œ๋‹ค๊ณ  ํ•œ๋‹ค. ๋‚ด๊บผ์— ์„ค์น˜๋˜์–ด ์žˆ๋Š” system ruby์˜ ๋ฒ„์ „์€ 2.6.10 ์ด๊ณ  2023๋…„ 10์›” ๊ธฐ์ค€ ์ตœ์‹  ๋ฒ„์ „ ruby๋Š” 3.2.2.

โฏ ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]

Ruby๋ฅผ ์—…๋ฐ์ดํŠธ ํ•˜๋ ค๊ณ  ๊ตฌ๊ธ€๋ง ์ข€ ํ•ด๋ดค๋Š”๋ฐ mac์— ๊น”๋ ค์žˆ๋Š” system ruby๋Š” ๊ฑด๋“œ๋ฆฌ์ง€ ๋ง๋ผ๋Š” ๊ธ€๋งŒ ์ž”๋œฉ ๋‚˜์˜จ๋‹ค...

mac์˜ ๋ ˆ๊ฑฐ์‹œ ์†Œํ”„ํŠธ์›จ์–ด๊ฐ€ ๊ตฌ๋ฒ„์ „์œผ๋กœ ๋นŒ๋“œ๋˜์–ด์žˆ๋Š”๊ฒŒ ๋งŽ์•„์„œ ruby๋ฒ„์ „์„ ์˜ฌ๋ฆฌ๊ฒŒ ๋˜๋ฉด ์ œ๋Œ€๋กœ ๋™์ž‘ํ•˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ๋‹ค๊ณ  ํ•œ๋‹ค. ํ•  ์ˆ˜ ์—†์ด pyenv ์ฒ˜๋Ÿผ ๋ฒ„์ „์„ ๊ฐ€์ƒํ™”์‹œ์ผœ์„œ ๊ด€๋ฆฌํ•˜๋Š” rbenv๋ฅผ ์„ค์น˜ํ•ด์•ผ๊ฒ ๋‹ค.

๋ณ„ ์ƒ๊ฐ์—†์ด ์‹œ์ž‘ํ–ˆ๋Š”๋ฐ ๋ญ”๊ฐ€ ์ ์  ๊ท€์ฐฎ์•„์ง„๋‹ค..

3. rbenv ์„ค์น˜

https://github.com/rbenv/rbenv
ํ•ด๋‹น ์˜คํ”ˆ์†Œ์Šค์˜ readme๋ฅผ ์ฐธ๊ณ ํ•ด์„œ ์ตœ์‹ ๋ฒ„์ „ ruby๋กœ ์„ค์น˜ํ–ˆ๋‹ค.

โฏ ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]

4. cocoapods ์žฌ์„ค์น˜

โฏ sudo gem install cocoapods
...
Done installing documentation for nanaimo, colored2, claide, CFPropertyList, atomos, xcodeproj, ruby-macho, nap, molinillo, gh_inspector, fourflusher, escape, cocoapods-try, netrc, cocoapods-trunk, cocoapods-search, cocoapods-plugins, cocoapods-downloader, cocoapods-deintegrate, ffi, ethon, typhoeus, public_suffix, fuzzy_match, concurrent-ruby, httpclient, algoliasearch, addressable, tzinfo, i18n, connection_pool, activesupport, cocoapods-core, cocoapods after 8 seconds
34 gems installed

cocoapods ๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ์„ค์น˜๋˜์—ˆ๋‹ค.

๋งˆ์ง€๋ง‰์œผ๋กœ flutter doctor๋กœ flutter๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์„ค์น˜ ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.

โฏ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[โœ“] Flutter (Channel stable, 3.13.7, on macOS 13.6 22G120 darwin-arm64, locale
    ko-KR)
[โœ“] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 15.0)
    โœ— CocoaPods installed but not working.
        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.
[โœ“] Chrome - develop for the web
[โœ“] Android Studio (version 2022.3)
[โœ“] VS Code (version 1.82.2)
[โœ“] Connected device (2 available)
[โœ“] Network resources

! Doctor found issues in 1 category.

????
๋ถ„๋ช…ํžˆ cocoapods ์„ค์น˜ ๋˜์—ˆ๋‹ค๊ณ  ๋กœ๊ทธ๊ฐ€ ์ฐํ˜”๋Š”๋ฐ Xcode๋Š” ์—ฌ์ „ํžˆ ์•ˆ๋œ๋‹ค..

5. ActiveSupport deprecated

โฏ pod --version
/Users/dyms/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.1/lib/active_support/core_ext/array/conversions.rb:108:in `<class:Array>': undefined method `deprecator' for ActiveSupport:Module (NoMethodError)

  deprecate to_default_s: :to_s, deprecator: ActiveSupport.deprecator
                                                          ^^^^^^^^^^^
Did you mean?  deprecate_constant
	from /Users/dyms/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.1/lib/active_support/core_ext/array/conversions.rb:8:in `<top (required)>'
	from <internal:/Users/dyms/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/Users/dyms/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /Users/dyms/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/cocoapods-1.13.0/lib/cocoapods.rb:9:in `<top (required)>'
	from <internal:/Users/dyms/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/Users/dyms/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /Users/dyms/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/cocoapods-1.13.0/bin/pod:36:in `<top (required)>'
	from /Users/dyms/.rbenv/versions/3.2.2/bin/pod:25:in `load'
	from /Users/dyms/.rbenv/versions/3.2.2/bin/pod:25:in `<main>'

์กฐ๊ธˆ ์ „์— ์„ค์น˜ํ•œ cocoapods ๋ฅผ ํ™•์ธํ•ด๋ณด๋‹ˆ ActiveSupport ๋ผ๋Š”๊ฒŒ deprecate ๋˜์—ˆ๋‹จ๋‹ค..

https://github.com/CocoaPods/CocoaPods/issues/12080

์ฐพ์•„๋ณด๋‹ˆ ๊ฐ€์žฅ ์ตœ์‹ ๋ฒ„์ „ gem ์—์„œ ๋ฐœ์ƒํ•˜๋Š” ์ด์Šˆ๋ผ๊ณ  ํ•˜๋Š”๋ฐ, ์ด๊ฒƒ๋งŒ ํ˜ธํ™˜๋˜๋Š” ๋ฒ„์ „์œผ๋กœ ๊ต์ฒดํ•ด์ฃผ๋ฉด ๋œ๋‹ค๊ณ  ํ•œ๋‹ค.

โฏ sudo gem uninstall activesupport
โฏ sudo gem install activesupport --version 7.0.8
โฏ pod --version
1.13.0

์ด์ œ์„œ์•ผ cocoapods ๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์ž‘๋™ํ•œ๋‹ค.

5. flutter doctor

โฏ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[โœ“] Flutter (Channel stable, 3.13.7, on macOS 13.6 22G120 darwin-arm64, locale
    ko-KR)
[โœ“] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[โœ“] Xcode - develop for iOS and macOS (Xcode 15.0)
[โœ“] Chrome - develop for the web
[โœ“] Android Studio (version 2022.3)
[โœ“] VS Code (version 1.82.2)
[โœ“] Connected device (2 available)
[โœ“] Network resources

โ€ข No issues found!

๋“œ๋””์–ด ํ•ด๊ฒฐ!๐ŸŽ‰

References

profile
๐Ÿ–ฅ๏ธ

0๊ฐœ์˜ ๋Œ“๊ธ€