ios - FaSTLane Match 环境变量未被 build_app 获取

标签 ios jenkins-pipeline fastlane fastlane-match

我开始使用 fastLane 并匹配 codesigning在 Jenkins 。 match 能够成功创建证书和配置文件。然而,build_app 步骤失败了,因为 pbxproj 文件将 CODE_SIGN_STYLE 设置为 Automatic。我想在不修改 pbxproj 文件的情况下实现构建,因为开发人员使用自动签名。

快速文件

        lane :upload_debug_test_flight do
          setup_jenkins
          match
          build_app(scheme: "MyWork Dev", clean: true, export_method: "app-store")
          upload_to_testflight(.....)
        end

匹配文件:

    git_url("git@github.mywork/cert_repo.git")
    storage_mode("git")
    type("appstore")
    api_key_path("./test.json")
    app_identifier(["com.mywork.mywork-test"])
    username("developer@mywork.com")

在我们的 project.pbxproj 中我们有

    CODE_SIGN_IDENTITY = "Apple Development";
    CODE_SIGN_STYLE = Automatic;
    PROVISIONING_PROFILE_SPECIFIER= ''

也尝试了以下方法,但 gym/build_app 仍然没有选择匹配的环境变量:

            build_app(
                skip_profile_detection: true,
                export_method: "app-store",
                export_options:{
                    signingStyle: "manual",
                    provisioningProfiles:{
                        "com.mywork.mywork-test": "match AppStore com.mywork.mywork-test"
                    }
                }
            )

最佳答案

Gym ( build_app ) 使用 Match 定义的配置文件映射进行归档 ( export_options ),但不用于构建应用程序(这是两个不同的步骤)。

因此,您需要配置您的 Xcode 项目以使用特定的配置文件,或者更新 PROVISIONING_PROFILE_SPECIFIER调用前的值 build_app .

如果开发者只使用 Debug配置,您可以在 Debug 之间指定不同的设置和 Release .这样,您可以保留 Automatic Debug 的选项配置并为 Release 手动指定代码签名身份和配置文件配置。

如果您根本不想接触您的 Xcode 项目并从 faSTLane 动态定义所有内容,您可以使用 update_code_signing_settings使用 Match 管理的配置文件的操作:

match(...)
profile_mapping = Actions.lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING]
update_code_signing_settings(
    use_automatic_signing: false,
    path: "path/to/your/project.xcodeproj",
    profile_name: profile_mapping['app_identifier'] # app_identifier could be an environment variable: ENV['APP_ID']
)
build_app(...)

另一个解决方案是传递 PROVISIONING_PROFILE_SPECIFIER变量到 xcargs选项。请注意,它会更新所有目标中的值,因此如果您的应用扩展具有不同的配置文件,它可能无法正常工作。

build_app(
    ...
    xcargs: "PROVISIONING_PROFILE_SPECIFIER='profile_name'"
)

关于ios - FaSTLane Match 环境变量未被 build_app 获取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70430700/

相关文章:

faSTLane - 有没有办法在车道中为 FaSTLane Pilot 传递详细标志?

ios - 无法在 NSNotificaitonCenter 的 addObserver : selector: name: object: method 中使用 UIApplicationDidEnterBackgroundNotification 作为名称

jenkins-pipeline - 失败后继续 Tekton 管道(类似于 jenkins 管道 catchError 行为)

jenkins - 如何在本地编译 Jenkins Pipeline Groovy?

ios - 是否有命令从 Firebase App Distribution 获取最新版本号,就像 TestFlight latest_testflight_build_number 一样?

ios - 内部版本号不是由 faSTLane 设置的,而是由 Xcode 设置的

ios - 如何读取和打开 iOS 应用程序文档目录中的文件?

iOS 应用内购买在生产环境中无声无息地失败

ios - 分析图像并在 iOS 中查找点

jenkins - 在我的 Jenkins 声明式管道中的多个代理上运行相同的任务