iOS - 运行脚本“[CP] Embed Pods Frameworks”卡在 Github Actions 中

问题描述 投票:0回答:2

我正在使用 GitHub Actions 为 iOS 应用程序设置 CI 管道。

执行构建命令时:

  xcodebuild \
  -workspace xxx.xcworkspace \
  -scheme SecureImage \
  clean build | xcpretty

它会卡在

Running script '[CP] Embed Pods Frameworks'
,直到根据我设置的 2 小时超时而超时。

▸ Compiling Main.storyboard
▸ Compiling Albums.storyboard
▸ Processing Info.plist
▸ Running script '[CP] Embed Pods Frameworks'
Error: The operation was canceled.

经过大量谷歌搜索后,我怀疑唯一可能的事情是与钥匙串有关,但我看不出是什么。 这是我在解密后添加证书的脚本:

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

cp ./.github/secrets/Provisioning.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/Provisioning.mobileprovision


security create-keychain -p "" ~/Library/Keychains/build.keychain
security import ./.github/secrets/Certificates.p12 -t agg -k ~/Library/Keychains/build.keychain -P "" -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-key-partition-list -S apple-tool:,apple:,codesign: -s -k "" ~/Library/Keychains/build.keychain

我完全陷入困境。

ios swift github-actions
2个回答
0
投票

我在 Github actions 上构建 ios 应用程序时也遇到了这个问题,但是,我使用 Fastlane 在 CI 上构建应用程序。

有一些事情可以解决这个问题:

  1. 通过将以下内容添加到 Podfile 来禁用并行构建:

    install! 'cocoapods', :disable_input_output_paths => true

  2. 禁用 Pod 框架的代码签名:确保

    build_app
    xcargs
    参数集
    CODE_SIGNING_ALLOWED=NO

作为参考,这是用于构建应用程序的通道的完整代码:

  lane :beta do
    xcode_select "/Applications/Xcode_15.4.app"
    match(type: "appstore", readonly: is_ci)
    build_app(
      workspace: "App.xcworkspace",
      scheme: "App",
      xcargs: "PROVISIONING_PROFILE_SPECIFIER='match AppStore com.app' CODE_SIGN_IDENTITY='Apple Distribution' CODE_SIGN_STYLE=Manual CODE_SIGNING_ALLOWED=NO -allowProvisioningUpdates -verbose",
      destination: "generic/platform=iOS",
      export_method: "app-store",
      export_options: {
        provisioningProfiles: {
          "com.app" => "match AppStore com.app",
        },
      },
      )
    upload_to_testflight
  end

这是用于工作流程的 yaml 文件

name: iOS CI

on:
  pull_request:
    branches:
      - main
  workflow_dispatch:

jobs:
 build:
  runs-on: macos-latest

  steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Set up Node.js
      uses: actions/setup-node@v4
      with:
        node-version: '18.12.1'

    - name: Enable Corepack
      run: corepack enable

    - name: Install dependencies
      run: yarn install --frozen-lockfile

    - name: Build shared package
      run: yarn workspace shared build

    - name: Build storage package
      run: yarn workspace storage build

    - name: Set up Ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: '3.0'
        bundler-cache: true

    - name: Install Bundler
      run: gem install bundler

    - name: Install CocoaPods
      run: gem install cocoapods

    - name: Install CocoaPods dependencies
      working-directory: mobile/ios
      run: pod install

    - name: Install Gems
      run: bundle install
      working-directory: mobile/ios

    - name: Configure Git Credentials
      env:
        GIT_CREDENTIALS: ${{ secrets.GIT_CREDENTIALS }}
      run: |
        git config --global url."https://${GIT_CREDENTIALS}@github.com/".insteadOf "https://github.com/"
    
    - name: Select Xcode Version
      run: sudo xcode-select -s /Applications/Xcode_15.4.app
    
    - name: Clean DerivedData
      run: |
        rm -rf ~/Library/Developer/Xcode/DerivedData
    
    - name: Run Fastlane
      working-directory: mobile/ios
      run: bundle exec fastlane beta
      env:
        MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
        APP_STORE_CONNECT_KEY: ${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY }}
        APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
        APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
        GIT_CREDENTIALS: ${{ secrets.GIT_CREDENTIALS }}

-1
投票

我认为你需要在构建之前安装 Pod

- name: Install CocoaPod Dependencies
      run: pod install
© www.soinside.com 2019 - 2024. All rights reserved.