找不到代码签名身份,无法创建新身份,因为您启用了“只读”

Posted

技术标签:

【中文标题】找不到代码签名身份,无法创建新身份,因为您启用了“只读”【英文标题】:No code signing identity found and can not create a new one because you enabled `readonly` 【发布时间】:2021-08-17 15:27:38 【问题描述】:

当我使用fastlane在github上发布ios应用时:

- name: Deploy to TestFlight/PGY
        run: |
          cd ./ios
          bundle exec fastlane beta
        env:
          FLUTTER_ROOT: $ secrets.FLUTTER_ROOT 
          APPLE_ID: $ secrets.APPLE_ID 
          GIT_URL: $ secrets.GIT_URL 
          PGY_USER_KEY: $ secrets.PGY_USER_KEY 
          PGY_API_KEY: $ secrets.PGY_API_KEY 
          TEAM_ID: $ secrets.TEAM_ID 
          ITC_TEAM_ID: $ secrets.ITC_TEAM_ID 
          FASTLANE_USER: $ secrets.FASTLANE_USER 
          FASTLANE_PASSWORD: $ secrets.FASTLANE_PASSWORD 
          FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: $ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD 
          FASTLANE_SESSION: $ secrets.FASTLANE_SESSION 
          MATCH_PASSWORD: $ secrets.MATCH_PASSWORD 
          MATCH_KEYCHAIN_NAME: $ secrets.MATCH_KEYCHAIN_NAME 
          MATCH_KEYCHAIN_PASSWORD: $ secrets.MATCH_KEYCHAIN_PASSWORD 

显示此错误:

No code signing identity found and can not create a new one because you enabled `readonly`

这是日志的一部分:

+-----------------------+---------+--------+
|               Used plugins               |
+-----------------------+---------+--------+
| Plugin                | Version | Action |
+-----------------------+---------+--------+
| fastlane-plugin-pgyer | 0.2.2   | pgyer  |
+-----------------------+---------+--------+

[14:58:29]: Sending anonymous analytics information
[14:58:29]: Learn more at https://docs.fastlane.tools/#metrics
[14:58:29]: No personal or sensitive data is sent.
[14:58:29]: You can disable this by adding `opt_out_usage` at the top of your Fastfile
[14:58:29]: ------------------------------
[14:58:29]: --- Step: default_platform ---
[14:58:29]: ------------------------------
[14:58:29]: Driving the lane 'ios beta' ????
[14:58:29]: --------------------------
[14:58:29]: --- Step: xcode_select ---
[14:58:29]: --------------------------
[14:58:29]: Setting Xcode version to /Applications/Xcode_12.4.app for all build steps
[14:58:29]: -----------------------------
[14:58:29]: --- Step: create_keychain ---
[14:58:29]: -----------------------------
[14:58:29]: Found keychain '~/Library/Keychains/***', creation skipped
[14:58:29]: If creating a new Keychain DB is required please set the `require_create` option true to cause the action to fail
[14:58:29]: $ security list-keychains -d user
[14:58:29]: ▸ "/Users/runner/Library/Keychains/***-db"
[14:58:29]: Found keychain '/Users/runner/Library/Keychains/***-db' in list-keychains, adding to search list skipped
[14:58:29]: -------------------
[14:58:29]: --- Step: is_ci ---
[14:58:29]: -------------------
[14:58:30]: -------------------
[14:58:30]: --- Step: match ---
[14:58:30]: -------------------
[14:58:30]: Successfully loaded '/Users/runner/work/flutter-netease-music/flutter-netease-music/ios/fastlane/Matchfile' ????

+----------------+-----------------------------------------------------------------------------------------------------------------+
|                                           Detected Values from './fastlane/Matchfile'                                            |
+----------------+-----------------------------------------------------------------------------------------------------------------+
| git_url        | *** |
| git_branch     | master                                                                                                          |
| storage_mode   | git                                                                                                             |
| type           | adhoc                                                                                                           |
| app_identifier | ["com.reddwarf.musicapp"]                                                                                       |
| username       | ***                                                                                                |
+----------------+-----------------------------------------------------------------------------------------------------------------+


+--------------------------------+-----------------------------------------------------------------------------------------------------------------+
|                                                            Summary for match 2.191.0                                                             |
+--------------------------------+-----------------------------------------------------------------------------------------------------------------+
| app_identifier                 | ["com.reddwarf.musicapp"]                                                                                       |
| git_url                        | *** |
| type                           | adhoc                                                                                                           |
| readonly                       | true                                                                                                            |
| keychain_name                  | ***                                                                                                  |
| generate_apple_certs           | true                                                                                                            |
| skip_provisioning_profiles     | false                                                                                                           |
| username                       | ***                                                                                                |
| team_id                        | ***                                                                                                      |
| storage_mode                   | git                                                                                                             |
| git_branch                     | master                                                                                                          |
| shallow_clone                  | false                                                                                                           |
| clone_branch_directly          | false                                                                                                           |
| force                          | false                                                                                                           |
| force_for_new_devices          | false                                                                                                           |
| skip_confirmation              | false                                                                                                           |
| skip_docs                      | false                                                                                                           |
| platform                       | ios                                                                                                             |
| derive_catalyst_app_identifier | false                                                                                                           |
| fail_on_name_taken             | false                                                                                                           |
| skip_certificate_matching      | false                                                                                                           |
| skip_set_partition_list        | false                                                                                                           |
| verbose                        | false                                                                                                           |
+--------------------------------+-----------------------------------------------------------------------------------------------------------------+

[14:58:30]: Cloning remote git repo...
[14:58:30]: If cloning the repo takes too long, you can use the `clone_branch_directly` option in match.
[14:58:30]: Checking out branch master...
[14:58:30]: ????  Successfully decrypted certificates repo
[14:58:30]: Couldn't find a valid code signing identity for distribution... creating one for you now
+---------------------------+-----------------------------------------------------+
|                                  Lane Context                                   |
+---------------------------+-----------------------------------------------------+
| DEFAULT_PLATFORM          | ios                                                 |
| PLATFORM_NAME             | ios                                                 |
| LANE_NAME                 | ios beta                                            |
| KEYCHAIN_PATH             | ~/Library/Keychains/***                  |
| ORIGINAL_DEFAULT_KEYCHAIN | "/Users/runner/Library/Keychains/***-db" |
+---------------------------+-----------------------------------------------------+
[14:58:30]: No code signing identity found and can not create a new one because you enabled `readonly`

+------+------------------+-------------+
|           fastlane summary            |
+------+------------------+-------------+
| Step | Action           | Time (in s) |
+------+------------------+-------------+
| 1    | default_platform | 0           |
| 2    | xcode_select     | 0           |
| 3    | create_keychain  | 0           |
| 4    | is_ci            | 0           |
| ????   | match            | 0           |
+------+------------------+-------------+

[14:58:30]: fastlane finished with errors

我应该怎么做才能解决这个问题?

【问题讨论】:

【参考方案1】:

我看到is_ci 也跑了。您的 match 命令是否如下所示: match(.., readonly: is_ci, ...) 你是在 Jenkins 或其他 CI 服务上运行命令吗? 如果是这样,首先在本地运行它,这将生成所需的所有相关证书和配置文件。然后再次在您的 CI 服务上运行它。

【讨论】:

以上是关于找不到代码签名身份,无法创建新身份,因为您启用了“只读”的主要内容,如果未能解决你的问题,请参考以下文章

如何熟悉代码签名问题?

找不到匹配的签名身份“Mac 开发人员:”

iPhone:找不到有效的签名身份烦人的错误

XCode 4.5 中的代码签名身份

身份服务器4:为啥我在调用授权控制器时收到“找不到签名密钥”

iOS 没有可用于签名的身份