bitrise-steplib / steps-xcode-archive

Xcode Archive for iOS step
MIT License
65 stars 55 forks source link

Xcode archive succeeds but failed to export ipa from the archive #173

Closed el-hoshino closed 4 years ago

el-hoshino commented 4 years ago

I'm facing this weird issue that in xcode-archive step, the archive process itself succeeds, but then it fails to export ipa from the archive. The error message suggests that it couldn't get the scheme from the xcode project file, but since it has already successfully archived this error is non-sense.

The stack I'm using is the latest Xcode 11.3, and the project can be found here (currently the latest master branch) https://github.com/el-hoshino/QuickshaRe/tree/1f490e023a1acd55fab43c10440e2ec660f027f0

And here's the log:

INFO[17:53:25]  * [OK] Step dependency (xcode) installed, available. 
Configs:
- ExportMethod: ad-hoc
- UploadBitcode: true
- CompileBitcode: false
- ICloudContainerEnvironment: 
- TeamID: 
- UseDeprecatedExport: false
- ForceTeamID: 
- ForceProvisioningProfileSpecifier: 
- ForceProvisioningProfile: 
- ForceCodeSignIdentity: 
- CustomExportOptionsPlistContent: 
- OutputTool: xcpretty
- Workdir: /Users/vagrant/git
- ProjectPath: QuickshaRe.xcodeproj
- Scheme: QuickshaRe
- Configuration: 
- OutputDir: /Users/vagrant/deploy
- IsCleanBuild: true
- XcodebuildOptions: 
- DisableIndexWhileBuilding: true
- ExportAllDsyms: true
- ArtifactName: QuickshaRe
- VerboseLog: true
- CacheLevel: swift_packages
step determined configs:
- xcodebuildVersion: Xcode 11.3 (Build version 11C29)
Checking if output tool (xcpretty) is installed
- xcprettyVersion: 0.3.0
Create the Archive ...
[17:53:33] $ set -o pipefail && xcodebuild "-project" "/Users/vagrant/git/QuickshaRe.xcodeproj" "-scheme" "QuickshaRe" "COMPILER_INDEX_STORE_ENABLE=NO" "clean" "archive" "-archivePath" "/var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/__archive__144898784/QuickshaRe.xcarchive" | xcpretty
▸ Clean Succeeded
▸ Linking QuickshaRe
▸ Compiling LaunchScreen.storyboard
▸ Processing Info.plist
▸ Generating 'QuickshaRe.app.dSYM'
▸ Touching QuickshaRe.app (in target 'QuickshaRe' from project 'QuickshaRe')
▸ Archive Succeeded
Archive infos:
team: XIANGXIN SHI (KC8N9BMQJY)
profile: iOS Team Provisioning Profile: net.crazism.QuickshaRe (00517235-d375-4bad-ab25-65092c455e52)
export: development
xcode managed profile: true
Exporting ipa from the archive...
Exporting ipa with ExportOptions.plist
No custom export options content provided, generating export options...
export-method specified: ad-hoc
could not get scheme with name QuickshaRe from path /Users/vagrant/git/QuickshaRe.xcodeproj
|                                                                              |
+---+---------------------------------------------------------------+----------+
| x | xcode-archive (exit code: 1)                                  | 32.19 sec|
+---+---------------------------------------------------------------+----------+
| Issue tracker: https://github.com/bitrise-steplib/steps-xcode-archive/issues |
| Source: https://github.com/bitrise-steplib/steps-xcode-archive               |
+---+---------------------------------------------------------------+----------+
cathyharmon commented 4 years ago

Hi!

Could you provide the log file or the URL? Did this work before, or has it always failed?

el-hoshino commented 4 years ago

@cathyharmon Thanks for reply! I've attached the whole log file in this comment, and the build url is https://app.bitrise.io/build/b6d7642c0f5a52a6#?tab=log

It has never succeeded, actually this is a new project I've just created this week, and I haven't implemented any code yet, only a template project initialized by Xcode, because I wanted to build the CI/CD environment before starting implementation.

b6d7642c0f5a52a6.log

karagraysen commented 4 years ago

Hi @el-hoshino,

Thank you for your patience. We're back at full capacity now that the holidays are over.

I am going to be looking at this shortly.

Please let us know if this is no longer an issue for you.

Kind regards, Luna

el-hoshino commented 4 years ago

Hi @non-binary

Thanks for following. I tried to rebuild the commit just now and the same error occurred.

karagraysen commented 4 years ago

Hi @el-hoshino,

Thanks for clarifying that for me.

Would you be able to provide me with your bitrise.yml? I see that you don't have the file in your project directory which means it can be found on your project page. I am going to attempt to reproduce the issue locally using the Bitrise CLI.

Thanks and looking forward to hearing from you.

Kind regards,

el-hoshino commented 4 years ago

Yes, here's the bitrise.yml file's contents:

---
format_version: '8'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: ios
app:
  envs:
  - XCODE_WORKSPACE_PATH: QuickshaRe.xcworkspace
    opts:
      is_expand: false
      skip_if_empty: false
      title: ''
      description: ''
      summary: ''
      category: ''
      is_required: false
      is_dont_change_value: false
      is_template: false
      is_sensitive: false
      unset: false
  - XCODE_PROJECT_PATH: QuickshaRe.xcodeproj
    opts:
      is_expand: false
      skip_if_empty: false
      title: ''
      description: ''
      summary: ''
      category: ''
      is_required: false
      is_dont_change_value: false
      is_template: false
      is_sensitive: false
      unset: false
  - XCODE_INFO_PLIST_PATH: QuickshaRe/Info.plist
    opts:
      is_expand: false
      skip_if_empty: false
      title: ''
      description: ''
      summary: ''
      category: ''
      is_required: false
      is_dont_change_value: false
      is_template: false
      is_sensitive: false
      unset: false
  - opts:
      is_expand: false
    BITRISE_SCHEME: QuickshaRe
trigger_map:
- push_branch: develop
  workflow: ad_hoc-deploy
- push_branch: master
  workflow: ad_hoc-deploy
- pull_request_source_branch: "*"
  pull_request_target_branch: master
  workflow: full-test
- pull_request_source_branch: "*"
  pull_request_target_branch: develop
  workflow: fast-test-with-deploy
workflows:
  _archive:
    steps:
    - certificate-and-profile-installer: {}
    - xcode-archive:
        inputs:
        - project_path: "$XCODE_PROJECT_PATH"
        - scheme: "$BITRISE_SCHEME"
        - team_id: ''
        - compile_bitcode: 'no'
        - is_clean_build: 'yes'
        - export_method: "$ARCHIVE_METHOD"
  _bootstrap:
    steps:
    - script:
        title: Set Git Credential
        inputs:
        - content: |
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            # write your script here
            echo "Set Git Credential"

            git credential-osxkeychain store
            host=github.com
            protocol=https
            username="${CARTHAGE_GITHUB_API_USER}"
            password="${CARTHAGE_GITHUB_API_TOKEN}"
    - script:
        title: Bootstrap
        inputs:
        - content: |-
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            # write your script here
            echo "Bootstrap"
            sh bootstrap.sh
  _deploy-modification:
    steps:
    - set-ios-version:
        inputs:
        - bundle_version: "$BITRISE_BUILD_NUMBER"
        - bundle_version_short: ''
        - info_plist_file: "$XCODE_INFO_PLIST_PATH"
  _deploy_to_app_store_connect:
    steps:
    - deploy-to-itunesconnect-deliver:
        inputs:
        - password: "$APPLE_DEVELOPER_PASSWORD"
        - app_id: "$APP_APPLE_ID"
        - team_id: "$APPSTORE_UPLOAD_TEAM_ID"
        - itunescon_user: "$APPLE_DEVELOPER_ACCOUNT"
  _deploy_to_bitrise:
    steps:
    - deploy-to-bitrise-io:
        inputs:
        - notify_user_groups: none
  _install-dependencies:
    steps:
    - script:
        title: Gem Dependencies
        is_always_run: true
        inputs:
        - content: |-
            #!/usr/bin/env bash

            # fail if any commands fails
            set -e
            # debug log
            set -x

            # write your script here
            echo "Install Dependencies via Gem"
            bundle install
    - script:
        title: Brew Dependencies
        is_always_run: true
        inputs:
        - content: |
            #!/usr/bin/env bash

            # fail if any commands fails
            set -e
            # debug log
            set -x

            # write your script here
            echo "Install Dependencies via Brew"
            brew bundle

            bundles=$(brew bundle list)

            for bundle in ${bundles[@]}; do
              if [ "$(which $bundle)" = "" ]; then
                brew link $bundle
              fi
            done
    - cocoapods-install: {}
    - carthage:
        title: Carthage Bootstrap
        inputs:
        - carthage_options: "--use-ssh --no-use-binaries --cache-builds --platform
            ios"
        - carthage_command: bootstrap
  _pr-check:
    steps:
    - script:
        title: Run Danger
        is_always_run: true
        inputs:
        - content: |-
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            # write your script here

            # Run danger
            danger
  _pr-prebuild:
    steps:
    - script:
        title: Install XCPretty JSON Formatter
        is_always_run: true
        inputs:
        - content: |
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            # write your script here
            gem install xcpretty-json-formatter
    - script:
        title: Install Danger with Plugins
        is_always_run: true
        inputs:
        - content: |-
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            # write your script here

            # Install Danger
            echo "Install Danger"
            gem install danger

            # Install Danger-XcodeSummary
            echo "Install Danger-XcodeSummary"
            gem install danger-xcode_summary

            # Install Danger-SwiftLint
            echo "Install Danger-SwiftLint"
            gem install danger-swiftlint

            # Install Danger-slather
            gem install danger-slather
  _preparation:
    steps:
    - activate-ssh-key:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone: {}
  _pull-cache:
    steps:
    - cache-pull: {}
  _push-cache:
    steps:
    - script:
        title: Gem Cache Settings
        inputs:
        - content: |-
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            # write your script here
            set -ev
            envman add --key GEM_HOME --value "$(gem environment gemdir)"
    - script:
        title: Brew Cache Settings
        inputs:
        - is_debug: 'yes'
        - content: |-
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            # write your script here
            set -ev

            #echo "$(brew bundle list)"

            #bundle_paths=""
            #install_paths=""
            cellar_path=$(brew --cellar)
            install_path="/usr/local/opt"
            #bundles=$(brew bundle list)

            #for bundle in ${bundles[@]}; do
            #  bundle_paths+=$cellar_path/$bundle$'\n'
            #  install_paths+=$install_path/$bundle$'\n'
            #done

            #envman add --key BREW_BUNDLE_PATHS --value $bundle_paths
            #envman add --key BREW_INSTALL_PATHS --value $install_paths

            envman add --key BREW_SWIFTLINT_BUNDLE --value $cellar_path/swiftlint
            envman add --key BREW_SWIFTLINT_INSTALL --value $install_path/swiftlint

            envman add --key BREW_CARTHAGE_BUNDLE --value $cellar_path/carthage
            envman add --key BREW_CARTHAGE_INSTALL --value $install_path/carthage

            envman add --key BREW_MINT_BUNDLE --value $cellar_path/mint
            envman add --key BREW_MINT_INSTALL --value $install_path/mint

            envman add --key BREW_LICENSEPLIST_BUNDLE --value $cellar_path/license-plist
            envman add --key BREW_LICENSEPLIST_INSTALL --value $install_path/license-plist

            envman add --key BREW_ROME_BUNDLE --value $cellar_path/rome
            envman add --key BREW_ROME_INSTALL --value $install_path/rome
    - cache-push:
        run_if: ".IsCI"
        inputs:
        - cache_paths: |-
            $BITRISE_CACHE_DIR
            $GEM_HOME
        - compress_archive: 'true'
  _send_deploy_result_to_slack:
    steps:
    - create-install-page-qr-code: {}
    - slack:
        inputs:
        - image_url: "$BITRISE_PUBLIC_INSTALL_PAGE_QR_CODE_IMAGE_URL"
        - pretext: "*Deploy Succeeded!*"
        - pretext_on_error: "*Deploy Failed!*"
        - webhook_url: "$SLACK_INCOMMING_WEBHOOK"
    - comment-on-github-pull-request:
        inputs:
        - body: |-
            Install Link:
            ![$BITRISE_PUBLIC_INSTALL_PAGE_URL]($BITRISE_PUBLIC_INSTALL_PAGE_QR_CODE_IMAGE_URL)
        - personal_access_token: "$DANGER_GITHUB_API_TOKEN"
  _send_test_result_to_slack:
    steps:
    - slack:
        inputs:
        - fields: |-
            App|${BITRISE_APP_TITLE}
            Branch|${BITRISE_GIT_BRANCH}
            Workflow|${BITRISE_TRIGGERED_WORKFLOW_ID}
        - pretext: "*Test Succeeded!*"
        - pretext_on_error: "*Test Failed!*"
        - webhook_url: "$SLACK_INCOMMING_WEBHOOK"
  _xcode-test: {}
  _xcode-test-terminal:
    description: 通常の Xcode Test Integration 使うと、XCPretty の出力が必ず HTML になってしまい、「-f `xcpretty-json-formatter`」
      を書いても勝手に「"-f" "`xcpretty-json-formatter`"」になるせいで正しくパースできないので、こちらを利用することにしました
    steps:
    - script:
        title: Xcode Test
        inputs:
        - content: |-
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            # write your script here

            # Xcode Test
            # `GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES` will cause a build failure while importing Firebase via CocoaPods in new Xcode projects, so temporarily I also added -fprofile-arcs to OTHER_LDFLAGS
            # set -o pipefail && env "NSUnbufferedIO=YES" xcodebuild -workspace $XCODE_WORKSPACE_PATH -scheme $BITRISE_SCHEME clean build test -destination 'platform=iOS Simulator,name=iPhone 11' GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES $ADDITIONAL_XCODE_BUILD_OPTIONS | XCPRETTY_JSON_FILE_OUTPUT=xcodebuild.json xcpretty -f `xcpretty-json-formatter`
            set -o pipefail && env "NSUnbufferedIO=YES" xcodebuild -project $XCODE_PROJECT_PATH -scheme $BITRISE_SCHEME clean build test -destination 'platform=iOS Simulator,name=iPhone 11' GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES $ADDITIONAL_XCODE_BUILD_OPTIONS OTHER_LDFLAGS="\$(OTHER_LDFLAGS) -fprofile-arcs" | XCPRETTY_JSON_FILE_OUTPUT=xcodebuild.json xcpretty -f `xcpretty-json-formatter`
  ad_hoc-deploy:
    before_run:
    - _preparation
    - _bootstrap
    - _deploy-modification
    after_run:
    - _archive
    - _deploy_to_bitrise
    - _send_deploy_result_to_slack
    envs:
    - ARCHIVE_METHOD: ad-hoc
      opts:
        is_expand: false
        skip_if_empty: false
        title: ''
        description: ''
        summary: ''
        category: ''
        is_required: false
        is_dont_change_value: false
        is_template: false
        is_sensitive: false
        unset: false
  app_store-deploy:
    before_run:
    - _preparation
    - _bootstrap
    - _deploy-modification
    after_run:
    - _archive
    - _deploy_to_app_store_connect
    - _deploy_to_bitrise
    - _send_deploy_result_to_slack
    envs:
    - ARCHIVE_METHOD: app-store
      opts:
        is_expand: false
        skip_if_empty: false
        title: ''
        description: ''
        summary: ''
        category: ''
        is_required: false
        is_dont_change_value: false
        is_template: false
        is_sensitive: false
        unset: false
  fast-test-with-deploy:
    before_run:
    - _preparation
    - _pull-cache
    - _install-dependencies
    - _pr-prebuild
    - _push-cache
    after_run:
    - _xcode-test-terminal
    - _pr-check
    - _send_test_result_to_slack
    - _deploy-modification
    - _archive
    - _deploy_to_bitrise
    - _send_deploy_result_to_slack
    envs:
    - ADDITIONAL_XCODE_BUILD_OPTIONS: EXTRA_SWIFT_ACTIVE_COMPILATION_CONDITIONS=TEST_ON_CI
      opts:
        is_expand: false
        skip_if_empty: false
        title: ''
        description: ''
        summary: ''
        category: ''
        is_required: false
        is_dont_change_value: false
        is_template: false
        is_sensitive: false
        unset: false
    - ARCHIVE_METHOD: development
      opts:
        is_expand: false
        skip_if_empty: false
        title: ''
        description: ''
        summary: ''
        category: ''
        is_required: false
        is_dont_change_value: false
        is_template: false
        is_sensitive: false
        unset: false
  full-test:
    before_run:
    - _preparation
    - _bootstrap
    - _pr-prebuild
    after_run:
    - _xcode-test-terminal
    - _pr-check
    - _send_test_result_to_slack
    envs:
    - ADDITIONAL_XCODE_BUILD_OPTIONS: EXTRA_SWIFT_ACTIVE_COMPILATION_CONDITIONS=TEST_ON_CI
      opts:
        is_expand: false
        skip_if_empty: false
        title: ''
        description: ''
        summary: ''
        category: ''
        is_required: false
        is_dont_change_value: false
        is_template: false
        is_sensitive: false
        unset: false
  update-cache:
    before_run:
    - _preparation
    - _pull-cache
    - _install-dependencies
    - _push-cache

And the workflow which failed is ad_hoc-deploy.

Thanks for your help!

karagraysen commented 4 years ago

Hi @el-hoshino,

Thank you for sharing this with us.

I am going to inspect this and follow-up with you soon.

Thanks, Luna

karagraysen commented 4 years ago

Hi @el-hoshino,

Thank you for your patience.

I believe this may be related to https://github.com/bitrise-steplib/steps-xcode-archive/issues/129 and the previous fix may have regressed or popped up again in a new way.

Can you please try downgrading the xcode-archive step to version 2.7.0 or if that still doesn't work, 2.4.20 and report back if either of those versions fix your issue? This will help us determine where the issue came back and we can debug further.

Thanks and looking forward to hearing from you, Luna

el-hoshino commented 4 years ago

HI @non-binary

I just tried all 2.4.20, 2.7.0 and latest 2.7.1, and all these versions failed.

Actually I updated my project with some features implemented and now it's working fine, making this behavior like some sort of bug that only appears with an initial Xcode project, so it's not bothering me any more. If you'd like to I can close this issue, leaving it just a potential bug that only happens on initial Xcode projects.

karagraysen commented 4 years ago

Hi @el-hoshino,

Good to hear that it's working now. If you are able to reproduce it in another project, please follow-up and provide the project so we can investigate further. Otherwise I will close this now that it's working.

Cheers, Luna