Build iOS app for simulator for Ionic Cordova App

I added the step Xcode Build for iOS Simulator to my workflow in a Ionic build workflow.

The apps build successful…

+------------------------------------------------------------------------------+
| (8) xcode-build-for-simulator                                                |
+------------------------------------------------------------------------------+
| id: xcode-build-for-simulator                                                |
| version: 0.9.0                                                               |
| collection: https://github.com/bitrise-io/bitrise-steplib.git                |
| toolkit: go                                                                  |
| time: 2018-08-23T11:49:12-07:00                                              |
+------------------------------------------------------------------------------+
|                                                                              |
INFO[11:49:12]  * [OK] Step dependency (xcode) installed, available. 
INFO[11:49:12]  * [OK] Step dependency (go) installed, available. 
Config:
- ProjectPath: /Users/vagrant/git/platforms/ios/[REDACTED].xcworkspace
- Scheme: [REDACTED]
- Configuration: Debug
- ArtifactName: 
- XcodebuildOptions: 
- Workdir: /Users/vagrant/git
- OutputDir: /Users/vagrant/deploy
- IsCleanBuild: false
- OutputTool: xcpretty
- SimulatorDevice: iPhone 6s Plus
- SimulatorOsVersion: latest
- SimulatorPlatform: iOS
- VerboseLog: false
Step determined configs:
- xcodebuildVersion: Xcode 9.4.1 (Build version 9F2000)
Checking if output tool (xcpretty) is installed
- xcprettyVersion: 0.2.8
Simulator info
Latest simulator for iPhone 6s Plus = 89D46AC4-62B0-432A-8693-90249E49DE07
Running build
[11:49:20] $ set -o pipefail && xcodebuild "-workspace" "/Users/vagrant/git/platforms/ios/[REDACTED].xcworkspace" "-scheme" "[REDACTED]" "-configuration" "Debug" "build" "-destination" "id=89D46AC4-62B0-432A-8693-90249E49DE07" "PROVISIONING_PROFILE_SPECIFIER=" | xcpretty
▸ Building CordovaLib/CordovaLib [Debug]

but raise this error when trying to export:

▸ Linking [REDACTED]
▸ Generating '[REDACTED].app.dSYM'
▸ Touching [REDACTED].app
▸ Signing /Users/vagrant/Library/Developer/Xcode/DerivedData/[REDACTED]-faqxtamjokzupbfcgmzixsylfopt/Build/Products/Debug-iphonesimulator/[REDACTED].app
▸ Build Succeeded
Copy artifacts from Derived Data to /Users/vagrant/deploy
Failed to export the artifacts, error: failed to fetch project's targets, error: Failed to found scheme ([REDACTED]) in project
|                                                                              |
+---+---------------------------------------------------------------+----------+
| x | xcode-build-for-simulator (exit code: 1)                      | 34 sec   |
+---+---------------------------------------------------------------+----------+
| Issue tracker: ...com/bitrise-steplib/steps-xcode-build-for-simulator/issues |
| Source: https://github.com/bitrise-steplib/steps-xcode-build-for-simulator   |
+---+---------------------------------------------------------------+----------+

That’s my bitryse.yml file:

---
format_version: '5'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: ionic
trigger_map:
- push_branch: "*"
  workflow: primary
- pull_request_source_branch: "*"
  workflow: primary
workflows:
  iOS:
    steps:
    - nvm:
        inputs:
        - node_version: 8.11.4
        - nvm_version: 0.33.8
    - activate-ssh-key:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
        inputs:
        - verbose: 'false'
    - git-clone: {}
    - script:
        title: Do anything with Script step
    - certificate-and-profile-installer: {}
    - npm:
        inputs:
        - command: install
    - generate-cordova-build-configuration: {}
    - ionic-archive:
        inputs:
        - options: "--prod"
        - cordova_android_version: 7.1.0
        - cordova_ios_version: 4.5.5
        - target: emulator
        - configuration: debug
        - platform: ios
    - xcode-build-for-simulator:
        inputs:
        - project_path: "$BITRISE_SOURCE_DIR/$BITRISE_PROJECT_PATH"
    - deploy-to-bitrise-io: {}
app:
  envs:
  - opts:
      is_expand: false
    IONIC_PLATFORM: ios,android
  - opts:
      is_expand: false
    BITRISE_SCHEME: Algarve
  - opts:
      is_expand: false
    BITRISE_PROJECT_PATH: platforms/ios/Algarve.xcworkspace

What I’m. doing wrong?

Hi @MrSparklle,

Sorry for the long delay!

Can you please paste here the log file or the URL to the build in question?

@bitce

The complete log:
https://pastebin.com/y2EmdCry

The error occurs in line 1984 and below.

Hi @MrSparklle,
Thanks for the logs! Could you check if the scheme that you are using in the xcode-build-for-simulator step is shared?

@tamasbazsonyi

It’s not me that I create or share the schemes in a Cordova Project. When Ionic builds the Cordova creates it automatically. Just for sure, I opened that project in my local Xcode to check if the scheme has been shared. And yes, it is shared, the corresponding checkbox is checked.

I also run this command:

xcodebuild -list
Information about project "Algarve":
    Targets:
        Algarve

    Build Configurations:
        Debug
        Release

    If no build configuration is specified and -scheme is not passed then "Release" is used.

    Schemes:
        Algarve
        Cordova
        CordovaLib

Hi @MrSparklle !

We will release a patch for the step in this week for this issue.

Hi @MrSparklle !

We have released the patch for the step (0.9.1)
Could you please wire it in and try again?

Thanks @BirmacherAkos

I will. When the 0.9.1 be available to select in the workflow step?

The webpage is caching the steps library, this is why you can’t see the new version of the step.
( This could be really annoying sometimes but this helps to load the workflow editor faster :smiley: )

In Google Chrome you can force refresh the page by the command + shift + r key combination.

Or you can use the browser’s incognito mode.

@BirmacherAkos

Tried to build with 0.9.1 unsuccessfully.

Build with Algarve.xcodeproj in $BITRISE_PROJECT_PATH:

THE COMPLETE LOG HERE

e[34;1mCopy artifacts from Derived Data to /Users/vagrant/deploye[0m
e[31;1mFailed to open xcproj - (/Users/vagrant/git/platforms/ios/Algarve.xcodeproj), error:%!(EXTRA *errors.errorString=no scheme found with name: Algarve in project: /Users/vagrant/git/platforms/ios/Algarve.xcodeproj)e[0m
|    

Build with Algarve.xcworkspace in $BITRISE_PROJECT_PATH:

THE COMPLETE LOG HERE

e[34;1mCopy artifacts from Derived Data to /Users/vagrant/deploye[0m
e[31;1mFailed to export the artifacts, error: failed to fetch project's targets, error: Failed to found scheme (Algarve) in projecte[0m
|     

My bitrise.yml:

---
format_version: '5'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: ionic
trigger_map:
- push_branch: "*"
  workflow: primary
- pull_request_source_branch: "*"
  workflow: primary
workflows:
  iOS:
    steps:
    - nvm:
        inputs:
        - node_version: 8.11.4
        - nvm_version: 0.33.8
    - activate-ssh-key:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
        inputs:
        - verbose: 'false'
    - git-clone: {}
    - script:
        title: Do anything with Script step
    - certificate-and-profile-installer: {}
    - npm:
        inputs:
        - command: install
    - generate-cordova-build-configuration: {}
    - ionic-archive:
        inputs:
        - options: "--prod"
        - cordova_android_version: 7.1.0
        - cordova_ios_version: 4.5.5
        - target: emulator
        - configuration: debug
        - platform: ios
    - xcode-build-for-simulator:
        inputs:
        - project_path: "$BITRISE_SOURCE_DIR/$BITRISE_PROJECT_PATH"
    - deploy-to-bitrise-io: {}
app:
  envs:
  - opts:
      is_expand: false
    IONIC_PLATFORM: ios,android
  - opts:
      is_expand: false
    BITRISE_SCHEME: Algarve
  - opts:
      is_expand: false
    BITRISE_PROJECT_PATH: platforms/ios/Algarve.xcodeproj

Could you please enable support user under the app’s settings tab? Also please copy here the build’s url here.

@tamasbazsonyi

Shared support enabled.
The builds URL: https://app.bitrise.io/app/c521145c691902bf#/builds

Hi!

It seems the problem is, that the “Inoic Archive” step will generate non-shared schemes in the generated iOS .xcodeproject.
And the “Xcode Build for simulator” step wants to use the shared scheme and this is why it’s failing.

I have created a ticket for the Tooling Team and they will fix it.

Ok. I will be waiting for a solution.

Hi @MrSparklle !

We will release a patch today (0.9.2)
In the new patch the step will check the user schemes too for the artifact export.

Could you please wire it in and try again?

It works fine now.

Thank you very much.

Glad to hear it worked.

Happy Building! :rocket: