GitHub操作IOS xcode QA/Staging并发布证书和配置文件

GitHub操作IOS xcode QA/Staging并发布证书和配置文件,ios,xcode,github,github-actions,Ios,Xcode,Github,Github Actions,我正在使用xcode 11.3为IOS使用GitHub操作。我能够为开发环境构建、导出存档并推送到应用程序中心。但是,我在登台/质量保证环境中遇到了错误 如果我提供的证书和配置文件与我在staging/QA中用于dev环境的证书和配置文件相同,那么在导出归档文件时会出现错误(构建成功):- 如果我在apple开发者帐户中创建新证书(apple分发)和规定文件(临时分发)。导出文件并转换文件,然后在GitHub操作中上载.p12.gpg和mobileprovision.gpg。生成时,我收到错误:

我正在使用xcode 11.3为IOS使用GitHub操作。我能够为开发环境构建、导出存档并推送到应用程序中心。但是,我在登台/质量保证环境中遇到了错误

如果我提供的证书和配置文件与我在staging/QA中用于dev环境的证书和配置文件相同,那么在导出归档文件时会出现错误(构建成功):-

如果我在apple开发者帐户中创建新证书(apple分发)和规定文件(临时分发)。导出文件并转换文件,然后在GitHub操作中上载.p12.gpg和mobileprovision.gpg。生成时,我收到错误:-

#Build archives
##[error]Process completed with exit code 65.
Run xcodebuild archive -workspace abc.xcworkspace -scheme abcStaging -archivePath abc.xcarchive
User defaults from command line:
    IDEArchivePathOverride = /Users/runner/runners/2.169.0/work/abcappIOS-v1.0/abcappIOS-v1.0/abc.xcarchive

note: Using new build system
note: Planning build
note: Constructing build description
error: No profiles for 'com.abc.Staging' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.abc.Staging'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'abc' from project 'abc')

** ARCHIVE FAILED **

##[error]Process completed with exit code 65.
我在导出存档中提供了-allowProvisioningUpdates作为参数,但错误仍然存在

下面是github操作的代码

name: Deploy iOS to App Center

on:
  push:
    branches: [ staging ]
  pull_request:
    branches: [ staging ]

jobs:
  build:
    runs-on: macOS-latest
    steps:
      - uses: actions/checkout@v1

      - name: Install gpg
        run: brew install gnupg

      - name: Switch XCode Version
        run: sudo xcode-select -s /Applications/Xcode_11.3.app

      - name: Setup provisioning profile
        run: |
          chmod +x ./.github/secrets/secrets.sh
          ./.github/secrets/secrets.sh
        env:
          IOS_PROFILE_KEY: ${{ secrets.ios_profile_key }}

      - name: Install Cocoapods
        run: gem install cocoapods

      - name: Install pod dependencies
        run: |
          pod install
        shell: bash

      - name: Build archive
        run: |
          xcodebuild archive -workspace abc.xcworkspace -scheme abcStaging -archivePath abc.xcarchive

      - name: Export Archive
        run: |
          xcodebuild -exportArchive -archivePath abc.xcarchive -exportPath abc.ipa -exportOptionsPlist ./abc/ExportOptions.plist -allowProvisioningUpdates          


下面是shell脚本

#!/bin/sh
gpg --quiet --batch --yes --decrypt --passphrase="xxxx" --output ./.github/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxx.mobileprovision ./.github/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxx.mobileprovision.gpg

gpg --quiet --batch --yes --decrypt --passphrase="xxxx" --output ./.github/secrets/abc_Certificates.p12 ./.github/secrets/abc_Certificates.p12.gpg

mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles

cp ./.github/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxx.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/xxxxx-xxxx-xxxx-xxxx-xxxxxxxx.mobileprovision

security create-keychain -p "" build.keychain
security import ./.github/secrets/abc_Certificates.p12 -t agg -k ~/Library/Keychains/build.keychain -P "xxxx" -A

security list-keychains -s ~/Library/Keychains/build.keychain
security default-keychain -s ~/Library/Keychains/build.keychain
security unlock-keychain -p "" ~/Library/Keychains/build.keychain
security set-keychain-settings -lut 1500 ~/Library/Keychains/build.keychain

security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "" ~/Library/Keychains/build.keychain
如何为登台(非开发或非生产环境)创建证书、资源调配配置文件? 请告知,我如何解决上述分期付款/质量保证问题


谢谢

我得到了同样的错误,并且能够找到解决方案。可能会出现很多问题,因此我将补充几点,以帮助您纠正问题:

  • 开发人员与分发配置文件:存档+导出+部署需要不同的开发人员和分发配置文件。xcodebuild将自动选择正确的配置文件,但为此您必须创建2个不同的配置文件+2个不同的证书。必须针对每个环境(QA、阶段、产品等)执行此过程
  • 总之,对于每个环境,将有2个配置文件和2个证书(证书可以重用,但不能重用配置文件,因为它们取决于您拥有的不同捆绑包的数量)

    上面的错误表明您从未为com.abc.Staging创建配置文件,或者至少没有下载并将其添加到正确的位置

    您可以在Apple开发者控制台->证书、标识符和配置文件->配置文件中创建它们

    确保您还设置了登台(或其他)环境的标识符:com.app.staging等

  • 在XCode中添加开发配置文件并确保直接使用XCode构建时证书有效。然后在本地尝试脚本,然后将它们推送到Github操作

  • 有时,Apple Developer中的配置文件可能会失效(可能是您在XCode中撤销或删除了证书等)。这种情况在我身上发生过几次,所以一定要检查一切是否有效

  • 解密后按UUID保存配置文件。 我不确定这有多重要,但我还是用了它

  • 代码如下:

    for PROVISION in `ls ./*.mobileprovision`
    do
      UUID=`/usr/libexec/PlistBuddy -c 'Print :UUID' /dev/stdin <<< $(security cms -D -i ./$PROVISION)`
      cp "./$PROVISION" "$HOME/Library/MobileDevice/Provisioning Profiles/$UUID.mobileprovision"
    done
    
    用于'ls./*.mobileprovision中的规定`
    做
    
    UUID=`/usr/libexec/PlistBuddy-c'Print:UUID'/dev/stdin您找到解决方案了吗?我也面临着同样的问题。如果您发现了任何解决方案,请与我们分享,谢谢。我已经解决了这个问题,并在下面发布了我的答案。希望将来的任何人都会觉得它有用:)
    error: No profiles for 'com.abc.Staging' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.abc.Staging'
    
    for PROVISION in `ls ./*.mobileprovision`
    do
      UUID=`/usr/libexec/PlistBuddy -c 'Print :UUID' /dev/stdin <<< $(security cms -D -i ./$PROVISION)`
      cp "./$PROVISION" "$HOME/Library/MobileDevice/Provisioning Profiles/$UUID.mobileprovision"
    done