flutter iOS 项目中的 pod install 给出了 base64: invalid input

tja*_*and 5 ios cocoapods boringssl flutter

经过一段时间的停机后,我尝试为 iOS 构建 Flutter 应用程序,但没有成功。pod intall给我以下输出(即使在清理 XCode 工作区之后):

\n
$ pod install\nAnalyzing dependencies\ncloud_firestore: Using Firebase SDK version '8.15.0' defined in 'firebase_core'\nfirebase_analytics: Using Firebase SDK version '8.15.0' defined in 'firebase_core'\nfirebase_auth: Using Firebase SDK version '8.15.0' defined in 'firebase_core'\nfirebase_core: Using Firebase SDK version '8.15.0' defined in 'firebase_core'\nWarning: firebase_app_id_file.json file does not exist. This may cause issues in upload-symbols. If this error is unexpected, try running flutterfire configure again.\nfirebase_crashlytics: Using Firebase SDK version '8.15.0' defined in 'firebase_core'\nfirebase_dynamic_links: Using Firebase SDK version '8.15.0' defined in 'firebase_core'\nfirebase_messaging: Using Firebase SDK version '8.15.0' defined in 'firebase_core'\nfirebase_remote_config: Using Firebase SDK version '8.15.0' defined in 'firebase_core'\nfirebase_storage: Using Firebase SDK version '8.15.0' defined in 'firebase_core'\nDownloading dependencies\nInstalling AppAuth (1.5.0)\nInstalling BoringSSL-GRPC (0.0.24)\n[!] /opt/homebrew/bin/bash -c\nset -e\nset -e\n# Add a module map and an umbrella header\nmkdir -p src/include/openssl\ncat > src/include/openssl/umbrella.h <<EOF\n  #include "ssl.h"\n  #include "crypto.h"\n  #include "aes.h"\n  /* The following macros are defined by base.h. The latter is the first file included by the\n     other headers. */\n  #if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)\n  #  include "arm_arch.h"\n  #endif\n  #include "asn1.h"\n  #include "asn1_mac.h"\n  #include "asn1t.h"\n  #include "blowfish.h"\n  #include "cast.h"\n  #include "chacha.h"\n  #include "cmac.h"\n  #include "conf.h"\n  #include "cpu.h"\n  #include "curve25519.h"\n  #include "des.h"\n  #include "dtls1.h"\n  #include "hkdf.h"\n  #include "md4.h"\n  #include "md5.h"\n  #include "obj_mac.h"\n  #include "objects.h"\n  #include "opensslv.h"\n  #include "ossl_typ.h"\n  #include "pkcs12.h"\n  #include "pkcs7.h"\n  #include "pkcs8.h"\n  #include "poly1305.h"\n  #include "rand.h"\n  #include "rc4.h"\n  #include "ripemd.h"\n  #include "safestack.h"\n  #include "srtp.h"\n  #include "x509.h"\n  #include "x509v3.h"\nEOF\ncat > src/include/openssl/BoringSSL.modulemap <<EOF\n  framework module openssl {\n    umbrella header "umbrella.h"\n    textual header "arm_arch.h"\n    export *\n    module * { export * }\n  }\nEOF\n\n# To avoid symbol conflict with OpenSSL, gRPC needs to rename all the BoringSSL symbols with a\n# prefix. This is done with BoringSSL's BORINGSSL_PREFIX mechanism\n# (https://github.com/google/boringssl/blob/75148d7abf12bdd1797fec3c5da9a21963703516/BUILDING.md#building-with-prefixed-symbols).\n# The required prefix header file boringssl_prefix_symbols.h is not part of BoringSSL repo at\n# this moment. It has to be generated by BoringSSL's users and be injected to BoringSSL build.\n# gRPC generates this file in script /tools/distrib/upgrade_boringssl_objc.sh. This script\n# outputs a gzip+base64 encoded version of boringssl_prefix_symbols.h because of Cocoapods'\n# limit on the 'prepare_command' field length. The encoded header is generated from\n# /src/boringssl/boringssl_prefix_symbols.h. Here we decode the content and inject the header to\n# the correct location in BoringSSL.\ncase "$(uname)" in\n  Darwin) opts="" ;;\n       *) opts="--ignore-garbage" ;;\nesac\nbase64 --decode $opts <<EOF | gunzip > src/include/openssl/boringssl_prefix_symbols.h\n  *** SNIP: long base 64 string ***\nEOF\n\n# We are renaming openssl to openssl_grpc so that there is no conflict with openssl if it exists\nfind . -type f \\( -path '*.h' -or -path '*.cc' -or -path '*.c' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include <openssl/;#include <openssl_grpc/;g'\n\n# Include of boringssl_prefix_symbols.h does not follow Xcode import style. We add the package\n# name here so that Xcode knows where to find it.\nfind . -type f \\( -path '*.h' -or -path '*.cc' -or -path '*.c' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include <boringssl_prefix_symbols.h>;#include <openssl_grpc/boringssl_prefix_symbols.h>;g'\n\nbase64: invalid input\ngunzip: (stdin): unexpected end of file\n
Run Code Online (Sandbox Code Playgroud)\n

如果我从上面的输出中复制 base64 字符串并运行它,base64 --decode我确实会得到相同的错误(无效输入”:

\n
cat base64.txt | base64 --decode\n\xef\xbf\xbdboringssl_prefix_symbols.h\xef\xbf\xbd\xef\xbf\xbd]s\xdb\xb8\xef\xbf\xbdh\xef\xbf\xbd\xef\xbf\xbdW\xef\xbf\xbd\xef\xbf\xbd\xdc\xa9:5;\xef\xbf\xbdn\xef\xbf\xbdbase64: invalid input\n
Run Code Online (Sandbox Code Playgroud)\n

我不知道这是否是我的环境、cocoapods、BoringSSL-GRPC 或依赖它的东西的问题(可能是 firebase 包之一?)。如果有人有任何指示,我将非常感激。

\n

环境\n硬件:Mac mini M1\nCocoapods:来自 Homebrew 的 1.11.3\nFlutter doctor:

\n
Doctor summary (to see all details, run flutter doctor -v):\n[\xe2\x9c\x93] Flutter (Channel stable, 3.0.1, on macOS 12.4 21F79 darwin-arm, locale en-SE)\n[\xe2\x9c\x97] Android toolchain - develop for Android devices\n    \xe2\x9c\x97 ANDROID_HOME = /Users/tjarvstrand/Android/Sdk\n      but Android SDK not found at this location.\n[\xe2\x9c\x93] Xcode - develop for iOS and macOS (Xcode 13.4.1)\n[\xe2\x9c\x97] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)\n    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.\n[\xe2\x9c\x93] Android Studio (version 2021.1)\n[!] Android Studio\n    \xe2\x9c\x97 Unable to find bundled Java version.\n[\xe2\x9c\x93] IntelliJ IDEA Community Edition (version 2021.3.3)\n[\xe2\x9c\x93] VS Code (version 1.67.2)\n[\xe2\x9c\x93] VS Code (version 1.66.2)\n[\xe2\x9c\x93] Connected device (1 available)\n[\xe2\x9c\x93] HTTP Host Availability\n\n! Doctor found issues in 3 categories.\n
Run Code Online (Sandbox Code Playgroud)\n

tja*_*and 7

经过一番彻底的挖掘,结果发现这是因为我的系统上安装了 GNU coreutils,所以安装时使用了不兼容的 base64 命令。

编辑:为了澄清,我的PATH环境变量被设置为base64调用 GNU 版本的命令,它不喜欢 Cocapods 传递的输入参数。我通过更改我的PATH系统base64命令来解决我的问题。不确定它们在这种情况下如何/为什么不兼容,但这解决了我的问题。