flutter iOS 项目中的 pod 安装给出了 base64:无效输入

问题描述 投票:0回答:3

经过一段时间的停机后,我尝试为 iOS 构建 Flutter 应用程序,但没有成功。

pod intall
给我以下输出(即使在清理 XCode 工作区之后):

$ pod install
Analyzing dependencies
cloud_firestore: Using Firebase SDK version '8.15.0' defined in 'firebase_core'
firebase_analytics: Using Firebase SDK version '8.15.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '8.15.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '8.15.0' defined in 'firebase_core'
Warning: 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.
firebase_crashlytics: Using Firebase SDK version '8.15.0' defined in 'firebase_core'
firebase_dynamic_links: Using Firebase SDK version '8.15.0' defined in 'firebase_core'
firebase_messaging: Using Firebase SDK version '8.15.0' defined in 'firebase_core'
firebase_remote_config: Using Firebase SDK version '8.15.0' defined in 'firebase_core'
firebase_storage: Using Firebase SDK version '8.15.0' defined in 'firebase_core'
Downloading dependencies
Installing AppAuth (1.5.0)
Installing BoringSSL-GRPC (0.0.24)
[!] /opt/homebrew/bin/bash -c
set -e
set -e
# Add a module map and an umbrella header
mkdir -p src/include/openssl
cat > src/include/openssl/umbrella.h <<EOF
  #include "ssl.h"
  #include "crypto.h"
  #include "aes.h"
  /* The following macros are defined by base.h. The latter is the first file included by the
     other headers. */
  #if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)
  #  include "arm_arch.h"
  #endif
  #include "asn1.h"
  #include "asn1_mac.h"
  #include "asn1t.h"
  #include "blowfish.h"
  #include "cast.h"
  #include "chacha.h"
  #include "cmac.h"
  #include "conf.h"
  #include "cpu.h"
  #include "curve25519.h"
  #include "des.h"
  #include "dtls1.h"
  #include "hkdf.h"
  #include "md4.h"
  #include "md5.h"
  #include "obj_mac.h"
  #include "objects.h"
  #include "opensslv.h"
  #include "ossl_typ.h"
  #include "pkcs12.h"
  #include "pkcs7.h"
  #include "pkcs8.h"
  #include "poly1305.h"
  #include "rand.h"
  #include "rc4.h"
  #include "ripemd.h"
  #include "safestack.h"
  #include "srtp.h"
  #include "x509.h"
  #include "x509v3.h"
EOF
cat > src/include/openssl/BoringSSL.modulemap <<EOF
  framework module openssl {
    umbrella header "umbrella.h"
    textual header "arm_arch.h"
    export *
    module * { export * }
  }
EOF

# To avoid symbol conflict with OpenSSL, gRPC needs to rename all the BoringSSL symbols with a
# prefix. This is done with BoringSSL's BORINGSSL_PREFIX mechanism
# (https://github.com/google/boringssl/blob/75148d7abf12bdd1797fec3c5da9a21963703516/BUILDING.md#building-with-prefixed-symbols).
# The required prefix header file boringssl_prefix_symbols.h is not part of BoringSSL repo at
# this moment. It has to be generated by BoringSSL's users and be injected to BoringSSL build.
# gRPC generates this file in script /tools/distrib/upgrade_boringssl_objc.sh. This script
# outputs a gzip+base64 encoded version of boringssl_prefix_symbols.h because of Cocoapods'
# limit on the 'prepare_command' field length. The encoded header is generated from
# /src/boringssl/boringssl_prefix_symbols.h. Here we decode the content and inject the header to
# the correct location in BoringSSL.
case "$(uname)" in
  Darwin) opts="" ;;
       *) opts="--ignore-garbage" ;;
esac
base64 --decode $opts <<EOF | gunzip > src/include/openssl/boringssl_prefix_symbols.h
  *** SNIP: long base 64 string ***
EOF

# We are renaming openssl to openssl_grpc so that there is no conflict with openssl if it exists
find . -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'

# Include of boringssl_prefix_symbols.h does not follow Xcode import style. We add the package
# name here so that Xcode knows where to find it.
find . -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'

base64: invalid input
gunzip: (stdin): unexpected end of file

如果我从上面的输出中复制base64字符串并运行它

base64 --decode
我确实得到了相同的错误(无效输入“:

cat base64.txt | base64 --decode
�boringssl_prefix_symbols.h��]s۸�h��W��ܩ:5;�n�base64: invalid input

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

环境 硬件:Mac mini M1 Cocoapods:来自 Homebrew 的 1.11.3 扑医生:

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

! Doctor found issues in 3 categories.
ios flutter cocoapods boringssl
3个回答
5
投票

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

编辑:澄清一下,我设置了

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


0
投票

因此,在给定的解决方案的基础上,这意味着在

~/.bash_profile
~/.zshrc
(取决于您使用的内容)中注释以下行:



export PATH="$(brew --prefix coreutils)/libexec/gnubin:/usr/local/bin:$PATH"
PATH=$(brew --prefix)/opt/findutils/libexec/gnubin:$PATH
PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"

完成此编辑后,请不要忘记在重新尝试安装 Pod 之前执行

source ~/.bash_profile
source ~/.zshrc

基本上,在此过程之前,

which base64
会打印:
/opt/homebrew/opt/coreutils/libexec/gnubin/base64

但是,在此过程之后,

which base64
将打印以下内容:
/usr/bin/base64


0
投票

我能够通过删除

coreutils
来解决这个问题

brew uninstall coreutils
删除

coreutils

后再次运行

pod install
    
© www.soinside.com 2019 - 2024. All rights reserved.