如何在Fastlane中指定Xcode版本?

7

现在我在Fastlane文件中指定Xcode版本,就像这样:

lane :beta do
    xcversion(version: "12.3")
    xcode_select "/Applications/Xcode_12.3.app"
    xcode-select -s /Applications/Xcode_12.3.app
    if is_ci
      create_keychain(
        name: ENV['MATCH_KEYCHAIN_NAME'],
        password: ENV["MATCH_KEYCHAIN_PASSWORD"],
        default_keychain: true,
        unlock: true,
        timeout: 3600,
        lock_when_sleeps: false
      )
    end
end

但是它显示了这个错误:

Run cd ./ios && bundle exec fastlane beta
+-----------------------+---------+--------+
|               Used plugins               |
+-----------------------+---------+--------+
| Plugin                | Version | Action |
+-----------------------+---------+--------+
| fastlane-plugin-pgyer | 0.2.2   | pgyer  |
+-----------------------+---------+--------+

[02:14:34]: Sending anonymous analytics information
[02:14:34]: Learn more at https://docs.fastlane.tools/#metrics
[02:14:34]: No personal or sensitive data is sent.
[02:14:34]: You can disable this by adding `opt_out_usage` at the top of your Fastfile
[02:14:34]:     12:   lane :beta do
[02:14:34]:     13:     xcversion(version: "12.3")
[02:14:34]:  => 14:     xcode-select -s /Applications/Xcode_12.3.app
[02:14:34]:     15:     if is_ci
[02:14:34]:     16:       create_keychain(

[!] Syntax error in your Fastfile on line 14: Fastfile:14: syntax error, unexpected unary-, expecting `do' or '{' or '('
    xcode-select -s /Applications/Xcode_12.3.app
                 ^
Fastfile:14: unknown regexp options - Xcd
...e-select -s /Applications/Xcode_12.3.app
...                         ^~~~~~
Fastfile:14: syntax error, unexpected local variable or method, expecting `end'
...elect -s /Applications/Xcode_12.3.app
...                            ^~~
Fastfile:14: unexpected fraction part after numeric literal
...ect -s /Applications/Xcode_12.3.app
...                             ^~
Fastfile:46: syntax error, unexpected `end', expecting end-of-input
Error: Process completed with exit code 1.

我该如何指定Xcode的版本?

2个回答

4
以下内容已足够: < p>以下是足够的:

xcversion(version:“12.3”)

根据文档的说明: < blockquote>

查找并选择安装的Xcode版本(...)

因此,不需要xcode-select命令。 关于xcode_select,不确定它是否存在。

你可以像Lopes所说的那样指定它,但我宁愿使用.xcode-version文件来完成。从文档中可以看到:你可以手动使用version:提供特定版本,或者使用.xcode-version文件。 - martinmose

4
2023年更新
截至Fastlane 2.211.0的发布,xcversion和xcode-install车道已被弃用并替换为xcodes。
现在有两种方法可以为fastlane执行设置Xcode版本(不影响系统选择并需要sudo权限)。
1.使用xcode_select操作提供可执行文件的完整路径:
xcode_select("/Applications/Xcode-14.1.app")

提供一个与新的 xcodes 操作相匹配的版本:
xcodes(version: "14.1", select_for_current_build_only: true)

请注意,如果您选择选项2,则需要在执行fastlane操作的系统中安装 xcodes CLI

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接