【问题标题】:Flutter iOS build on the App Center fails with error: "Invalid Podfile file: Generated.xcconfig must existApp Center 上的 Flutter iOS 构建失败并出现错误:“Invalid Podfile file: Generated.xcconfig must exist
【发布时间】:2020-06-30 03:13:57
【问题描述】:

我刚刚通过article here 将我的应用设置为在应用中心上构建。

虽然 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://docs.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 的新手,因此感谢您的帮助!

更新

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

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

【问题讨论】:

  • 您有没有为此提出解决方案?我遇到了完全相同的问题,我尝试了所有相同的事情
  • 还没有,很遗憾。不过,我会在接下来的几天里再次查看它。应用中心的支持人员说他们会传递信息,但由于没有官方支持,他们不能承诺任何事情。

标签: ios flutter visual-studio-app-center


【解决方案1】:

我对我的克隆后脚本执行了此操作,并且成功了:

#!/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 之后

【讨论】:

    【解决方案2】:

    我有同样的问题。当 appcenter-post-clone.sh 运行失败时会发生这种情况,因此,flutter 未安装并且命令 flutter build ios 未运行以生成 Generated.xcconfig

    要修复它,我只是:

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

    【讨论】:

    • 这解决了我的问题。我还在ios 文件夹中的.gitignore 中评论了Generated.xcconfig。但我认为它可以在不改变 .gitignore 的情况下工作。
    【解决方案3】:

    检查你的 .gitIgnore。由于文件被从 repo 中排除,因此遇到了同样的问题。

    添加回来后一切正常。

    还要注意项目中为 Flutter 定义的路径。

    【讨论】:

    • 你能说得更具体点吗?我必须为 Android App Center 构建执行此操作,它工作正常,但我需要从 .gitignore 中删除哪些特定文件才能使 iOS 构建工作?
    • 此链接说明了一切,按照步骤操作,如果您仍有问题,请告诉我! medium.com/codespace69/…
    • 在 Stack Overflow 上回答问题时,最好链接到源并在答案中提供相关信息。由于超过本月的 Medium 限制,我无法阅读该文章 - 从标题来看,它甚至与我的 App Center CI/CD 设置问题无关。
    • 要解决这个问题,您需要在 .gitIgnore 中注释 Generated.xcconfig。这将解决该问题。如果那时您将在其他问题中运行,那么可能该项目生成不正确,就像发生在我身上一样。就我而言,这是由于使用了 VSCode 而不是 Android Studio。这解决了我项目中的所有问题。
    • generated.xcconfig 不包含在 .gitgnore 中,因为它被设计为在构建过程中生成,无论是在您的机器上还是由 App Center 构建。话虽如此,我作为测试所做的其中一件事是将它从 gitignore 中删除,看看会发生什么。正如预期的那样,由于其中的路径(仅与我的机器相关),它提出了一系列其他问题。编辑文件也不是一个好主意,因为每次我在本地进行构建以进行测试时,它都会被覆盖。所以,不是一个好的解决方案!
    【解决方案4】:

    它现在似乎可以工作了。我认为 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
    

    【讨论】:

      【解决方案5】:

      1- 导航到颤振模块目录 2-做一个颤动的酒吧 ** 还要确保您在稳定频道“Flutter”上

      【讨论】:

        【解决方案6】:

        尝试进入IOS文件夹然后pod installor pod update

        在终端中

        【讨论】:

        • 就像我提到的,这个问题不是我的机器的本地问题,它构建得很好。它在 App Center 构建过程中。
        猜你喜欢
        • 1970-01-01
        • 2022-11-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-06
        • 2019-02-23
        • 2022-01-06
        • 2022-07-07
        相关资源
        最近更新 更多