在App Center上构建Flutter iOS失败,出现错误:“无效的Podfile文件:生成的.xcconfig必须存在

mo49yndu  于 2022-11-17  发布在  Flutter
关注(0)|答案(7)|浏览(288)

我刚刚通过article here将我的应用程序设置为在App Center上构建。
虽然Android版本在App Center上构建和部署都很好,但我在iOS构建中遇到了一个错误,如下面构建输出的摘录所示:

==============================================================================
Task         : CocoaPods
Description  : Install CocoaPods dependencies for Swift and Objective-C Cocoa projects
Version      : 0.151.1
Author       : Microsoft Corporation
Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/package/cocoapods
==============================================================================
[command]/usr/local/lib/ruby/gems/2.6.0/bin/pod --version
1.9.1
[command]/usr/local/lib/ruby/gems/2.6.0/bin/pod install --repo-update

[!] Invalid `Podfile` file: Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first.

 #  from /Users/runner/runners/2.165.2/work/1/s/bdstories/ios/Podfile:51
 #  -------------------------------------------
 #      unless File.exist?(generated_xcode_build_settings_path)
 >        raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
 #      end
 #  -------------------------------------------
##[error]The process '/usr/local/lib/ruby/gems/2.6.0/bin/pod' failed with exit code 1
##[error]The 'pod' command failed with error: The process '/usr/local/lib/ruby/gems/2.6.0/bin/pod' failed with exit code 1
##[section]Finishing: Pod install
##[section]Starting: Xcode build (signed)

我的生成脚本是:

#!/usr/bin/env bash
# Place this script in project/ios/.

# Fail if any command fails.
set -e

# Debug log.
set -x
cd ..

git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH

flutter channel beta
flutter doctor

echo "Installed flutter to `pwd`/flutter"

# Build the app.
flutter build ios --release --no-codesign

我确实添加了错误中提到的flutter pub get,但这并没有产生什么影响。同样值得注意的是,当我在本地Xcode中进行构建时,构建工作正常。我也可以将构建的归档文件部署到Testflight,没有任何问题。只是App Center的构建过程有问题。
我现在有点迷路了,我找不到任何关于如何解决这个问题的信息。我也是CI/CD的新手,所以任何帮助都很感激!

更新

我还尝试在脚本中添加以下内容,以强制AppCenter运行与本地计算机相同版本的Cocoapods,但这对错误没有任何影响。

sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.9.1
pod setup
h5qlskok

h5qlskok1#

我对我的克隆后脚本做了以下操作,它起作用了:

#!/usr/bin/env bash
#Place this script in project/ios/

echo "Uninstalling all CocoaPods versions"
sudo gem uninstall cocoapods --all --executables

COCOAPODS_VER=`sed -n -e 's/^COCOAPODS: \([0-9.]*\)/\1/p' Podfile.lock`

echo "Installing CocoaPods version $COCOAPODS_VER"
sudo gem install cocoapods -v $COCOAPODS_VER

# fail if any command fails
set -e
# debug log
set -x

pod setup

cd ..
git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH

flutter channel master
flutter doctor
flutter pub get

echo "Installed flutter to `pwd`/flutter"

flutter build ios --release --no-codesign

技巧似乎是将“如果任何命令失败则失败”部分移到了pod重新安装之后

zy1mlcev

zy1mlcev2#

我遇到了同样的问题。当www.example.com无法运行时,就会发生这种appcenter-post-clone.sh情况,因此,flutter没有安装,命令flutter build ios没有运行以生成Generated.xcconfig
为了修好它,我只是:

  • 已删除appcenter-post-clone并推送此提交
  • 在Build部分打开分支的配置。现在post-clone标记已经消失。保存它。
  • 再次使用www.example.com推送另一个提交appcenter-post-clone.sh。
  • 再次配置分支,现在恢复了克隆后标记。
  • 保存并构建。
nimxete2

nimxete23#

检查您的.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIgnore.gitIg
一旦添加回来,一切都很好。
还要注意在项目中为“Flutter”定义的路径。

hvvq6cgz

hvvq6cgz4#

1-导航至Flutter模块目录2-执行Flutter发布获取**同时确保您处于稳定通道“Flutter”

uklbhaso

uklbhaso5#

它现在似乎可以工作了。我认为App Center的构建过程有了更新。为了给你提供信息,我在下面包含了我的最终构建后脚本,如果这对你有用的话:

#!/usr/bin/env bash
#Place this script in project/ios/

# fail if any command fails
set -e
# debug log
set -x

cd ..
git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH

flutter channel beta
flutter doctor

echo "Installed flutter to `pwd`/flutter"

flutter build ios --release --no-codesign
wi3ka0sx

wi3ka0sx6#

我在从另一个分支复制现有的建置设定档之后,也遇到相同的问题。在删除建置设定档并为目的分支从头建立新的建置设定档之后,问题就解决了。

tcomlyy6

tcomlyy67#

尝试进入IOS文件夹,然后进入pod installpod update
在终端中

相关问题