Xcode 12.4 为模拟器和设备构建,但使用 Pods-MYAPP-frameworks.sh 归档失败:第 131 行:ARCHS[@]:未绑定变量

问题描述

我使用的是 Xcode 12.4(从 12.2 更新,希望我的问题得到解决)。如您所知,在 xcode 12.x 中,我们删除了 VALIDARCHS,将 arm64 添加到项目和 pod 文件中排除的 archs(仅适用于模拟器)。否则就会出现构建问题。我已经完成了我的开发,我已经准备好进行苹果的试飞,然后是最终的应用商店。如您所知,我们需要存档应用程序并从组织者上传。但是,我的应用程序归档失败。 我的问题是我可以成功地为所有模拟器和真实设备构建我的应用程序,但是,当我尝试存档应用程序时,它给了我一个错误

Error Image Here

bash 脚本是 PODS 的脚本第 131 行是部分: intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)"

# Strip invalid architectures
strip_invalid_archs() {
  binary="$1"
  warn_missing_arch=${2:-true}
  # Get architectures for current target binary
  binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)"
  # Intersect them with the architectures we are building for
  intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)"
  # If there are no archs supported by this binary then warn the user
  if [[ -z "$intersected_archs" ]]; then
    if [[ "$warn_missing_arch" == "true" ]]; then
      echo "warning: [CP] vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)."
    fi
    STRIP_BINARY_RETVAL=1
    return
  fi
  stripped=""
  for arch in $binary_archs; do
    if ! [[ "${ARCHS}" == *"$arch"* ]]; then
      # Strip non-valid architectures in-place
      lipo -remove "$arch" -output "$binary" "$binary"
      stripped="$stripped $arch"
    fi
  done
  if [[ "$stripped" ]]; then
    echo "Stripped $binary of architectures:$stripped"
  fi
  STRIP_BINARY_RETVAL=0
}

到目前为止我做了什么?

  • 可能检查过 stackoverflow、苹果论坛、github 等上的每个解决方案。
  • 脚本中我的源变量更改为 source:- 如上图所示
  • 我尝试过 xcodebuild 存档和其他在那里变坏的东西,所以我不想触摸终端进行存档。
  • 在寻找解决方案作为 podfile 的安装后解决方法时,我对其进行了更改,但没有任何效果
  • 为项目和 Pod 尝试了不同的配置。
  • 尝试在 bash 脚本中的 strip_invalid_archs() 中解决方法,但遇到其他错误
  • 甚至尝试在 strip_invalid_archs() 中手动定义 ARCHS,因为我找不到任何东西

我觉得架构有问题,因为归档需要所有可用的架构,所以无法归档。我也认为是 pod 问题,但我真的很迷茫。

这是我的架构项目和 pod 配置:

Project

Pod

# Uncomment the next line to define a global platform for your project
platform :ios,'14.3'
minimum_deployment_target = 14.3

target 'MYAPP' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for MYAPP
pod 'Firebase/Core'
pod 'Firebase/Auth'
  pod 'Firebase/Database'
        pod 'Firebase/Firestore'
  pod 'Firebase/Storage'
pod 'Firebase/Messaging'
target 'MYAPPTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'MYAPPUITests' do
    inherit! :search_paths
    # Pods for testing
  end

post_install do |installer|
    installer.generated_projects.each do |project|
        project.targets.each do |target|
            target.build_configurations.each do |config|
                # Ensure we set all Pods to match the minimum deployment target specified by the app
                config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = minimum_deployment_target
            end
        end
    end
installer.pods_project.build_configuration_list.build_configurations.each do |configuration|
        configuration.build_settings['ARCHS'] = 'arm64 armv7'
    end
end



end


编辑 podfile 中的 postinstall 部分是在归档失败后添加的。即使我的 podfile 中没有安装后部分,存档也不起作用。

提前致谢。当我认为我完成它时无法存档应用程序真的很令人失望。我已经在这上面花了几天时间。如果你能帮忙就太好了。谢谢

解决方法

我遇到了同样的问题,Github issue 解决了我的问题。 TLDR:进入构建设置并从有效和排除的架构中删除 arm64。