Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

bash: xcodebuild: command not found while setting up iOS (swift) CI/CD pipeline on bitbucket?

Akash Ashok Kondekar July 7, 2023


I am a newbie on CI/CD bitbucket integration stuff. When I was trying to execute any command related to xcodebuild,(such as clean, build, etc) by specifying it in yml file, it threw me an error "bash: xcodebuild: command not found command not found". 

I tried multiple solutions for it but not a single command/Path works for me hence if I get help related to that then that will be helpful or else If I get step-by-step Documentation related to CI/CD iOS with bitbucket integration will also work.


FYI: Checked with the correct Path and required xcodebuild to be in the same directory or not and found they both were at the same level.

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 10, 2023

Hi @Akash Ashok Kondekar,

MacOS Runners use Bash to run pipeline steps on your MacOS machine (host device), so the builds do not run in Docker containers.

What the runner will do for each step is clone the repo on your machine (unless you have disabled cloning in your bitbucket-pipelines.yml file) and then execute the commands from the step's script. The runner will try to empty the build directory after each step.

If a certain tool is installed on your MacOS machine and you can use it from bash, it should be possible to use it with a MacOS Runner.

If you try the following:

  • open a new terminal on your Mac
  • clone the repo you want to run builds for
  • change directory to the clone you created
  • execute the commands from your bitbucket-pipelines.yml file's script

are you then able to run the failing command this way?

Does the command which xcodebuild return any output?

Kind regards,

Akash Ashok Kondekar July 10, 2023

Thanks for the reply, @Theodora Boudale

Unfortunately, I am still facing the same issue. Posting screenshots that might help you to understand where I am failing at:


1. yml file: It started failing from line 18, i.e. xcodebuild clean... command




2. Output that I can see on bitbucket pipeline console:



As I said earlier, I had already committed and can see xcodebuild at the same level directory level where in my installing my pods.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 11, 2023

Hi @Akash Ashok Kondekar,

Thank you for the info.

I can see from both screenshots that you are running this Pipelines build on our own infrastructure. You mentioned in the title iOS pipeline, so I thought you were using a MacOS Runner (this is why I was talking about MacOS Runners in my previous post).

Pipelines that run in Atlassian's infrastructure currently run on a Kubernetes cluster of Linux Docker hosts. I believe that it is not possible to run xcodebuild on a computer that is not a MacOS, so I don't think you'll be able to run this build on our own infrastructure.

If you have a MacOS that you can use to run builds, you can set up a MacOS runner on that machine and run builds there:

The builds will run on your MacOS, but you'll still be able to view the logs on the Bitbucket website on the Pipelines page of the repo. Additionally, you won’t be charged for the build minutes used by your self-hosted runner.

You can see here the Supported platforms and Minimum Requirements for runners:

Please feel free to let me know if you have any questions.

Kind regards,

Like Sabine Mayer likes this
Akash Ashok Kondekar July 18, 2023

Thanks, @Theodora Boudale

Here's a summary of the actions we've tried so far:


  • Clearing Derived Data
    • We attempted to resolve any cached or corrupted build artifacts by clearing the derived data for your Xcode project.
  • Cleaning Build
    • To ensure there are no old artifacts causing conflicts, we performed a clean build by holding the "Option" key and selecting "Clean Build Folder" in Xcode.
  • CocoaPods Version
    • We ensured that we are using the latest version of CocoaPods by running "gem install cocoapods" and updating the pods with "pod update".
  • Xcode Version
    • We confirmed that we are using the latest stable version of Xcode to avoid any bugs or compatibility issues.
  • Review Pod Configuration
    • We reviewed the configurations in the Xcode project after installing the pods to ensure correct integration with the main app target.
  • Swift Code
    • We reviewed your Swift code for any syntax errors or issues that might be causing the compiler to fail.
  • Pod Dependency Conflicts
    • We checked for pod dependency conflicts and updated or removed specific pod versions to resolve any conflicts.
  • System and Xcode Compatibility
    • We verified that your macOS version and Xcode version are compatible with the Swift version and the pods we are using.
  • Verify Signing and Capabilities*We ensured that the signing and capabilities are correctly configured for the 'DailyMentor' target. This includes checking provisioning profiles, certificates, and any necessary entitlements.


Despite implementing the above steps, we still encounter the same error: ie. " BUILD FAILED The following build commands failed: SwiftEmitModule normal arm64 Emitting\ module\ for\ DailyMentor (in target 'DailyMentor' from project 'DailyMentor') (1 failure)"

PFA screenshots


I am not sure now what I am missing here.
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 18, 2023

Hi @Akash Ashok Kondekar,

Are you using a MacOS runner now for the build?

Is the issue reproducible outside of the runner, if you clone the repo and run the commands from your yml file's script?

I don't know what exactly the issue is as I'm not familiar with the tools you are using. If the issue is also reproducible outside the runner, I would suggest reaching out to a forum dedicated to xcode support.

Kind regards,

Akash Ashok Kondekar July 18, 2023

Hello @Theodora Boudale

Yes, we are now using MacOS runners. We tried without runner first and there we were getting the "Xcode command not found" error. Then as you mentioned a guided setup for the runner was, we did try that and after that, we are now started getting this issue.

" BUILD FAILED The following build commands failed: SwiftEmitModule normal arm64 Emitting\ module\ for\ DailyMentor (in target 'DailyMentor' from project 'DailyMentor') (1 failure)


So to summarise it:

MacOS Runner: Yes, we are using a MacOS runner for the build process. The build is being performed on a self-hosted MacOS runner provided by Atlassian Pipelines.

Reproducibility: We have tested the build commands from the yml file's script on our local development environment, and the issue is not reproducible there. The build process works as expected when executed locally.

Runner Environment: Considering that the build failure is specific to the runner environment, we suspect that there might be some differences or limitations in the runner setup that are causing the SwiftEmitModule failure.

Dependency on Runner Environment: As we have confirmed that the issue is not occurring outside of the runner environment, it indicates that the problem might be related to the specific runner's configuration or resources.

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 19, 2023

Hello @Akash Ashok Kondekar 

Since the macOS runners are executed in a shell session, could you please try executing the same exact commands you have in your pipeline script, but in a shell session outside the runner? 

You can open a new terminal window on the same machine that is hosting the runner, and try executing the xcodebuild command directly in that terminal to check if the same error happens. This will help us diagnose whether the issue lies within the host environment itself or on the runner.

Also, I found the following Stackoverflow thread reporting an error similar to the one you are receiving, which might be of help : 

Thank you, @Akash Ashok Kondekar !

Patrik S

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events