How to debug your build locally / "It works on my Mac/PC but not on bitrise.io"

debugging
#1

If the build works on your local Mac/PC but not on bitrise.io, that’s usually because of uncommitted / gitignored files or a tool version difference. There can be other reasons, for example in case of iOS code signing errors it’s usually because a code signing file which is available on your Mac, but you did not upload it to bitrise.io and so it’s not available there.

In any case, the first steps you should try, preferably before you’d report the issue (as this will be the first thing we’ll ask for anyway ;)) is to do a full clean clone of your project, and try to run the build there. This helps to eliminate the most common issue, that you have a file in your project’s regular working directory which is not committed into git, and so it’s not available when bitrise.io clones the repository.

Testing with a full clean git clone

  1. open your Terminal / Command Line
  2. type in: cd /tmp
  3. clone your repository with: git clone REPOURL ./quick-repo-test --branch BRANCH-YOU-WANT-TO-TEST
    • example: git clone https://github.com/bitrise-io/bitrise.git ./quick-repo-test --branch master
  4. cd ./quick-repo-test

and then run the commands you want to test, to build your project, or open the project file from this directory (you can open the directory in Finder / file browser by typing in: open .).

Test with the Bitrise CLI

You can also run the same build locally, using the Bitrise CLI. For this, follow the steps in the previous section (Testing with a full clean git clone), and once you’re in the /tmp/quick-repo-test directory:

  1. Do a clean git clone, as described in the previous section: Testing with a full clean git clone
  2. Install the Bitrise CLI following the install instructions (it takes less than a minute to install it, the Bitrise CLI is distributed as a single binary, without any installer)
  3. Download your app’s bitrise.yml from bitrise.io:
    1. open the app on bitrise.io
    2. click the Workflow tab to open the Workflow Editor
    3. on the left side select bitrise.yml
    4. download the yml and save it into /tmp/quick-repo-test with the file name bitrise.yml
  4. Now that you have the bitrise.yml in /tmp/quick-repo-test, run the build with: bitrise run WORKFLOW-TO-RUN (e.g. bitrise run primary)

This should help to reproduce the issue in most cases.

Additional notes for iOS projects

  • Make sure that you run the tests in the same simulator as the one bitrise.io runs. If you use the Bitrise CLI to run the tests locally this is not required, that uses the same configuration.
  • If you’re debugging an iOS unit/UI test issue, please make sure to reset the iOS Simulator (in the Simulator app select the Simulator menu bar item -> then Reset Content and Settings…).

Additional notes for Android/Gradle projects

  • If you still can’t reproduce the issue locally (after following the previous steps), you might also want to delete the $HOME/.gradle (hidden) directory, to clear your Gradle caches. (Quick Terminal / Command Line command: rm -rf $HOME/.gradle)

Download and use the Android/Linux environment

This only works if your project uses the Android/Linux environment. If you do, that’s awesome, as you can download and use the exact same environment as the one your build is running in on bitrise.io!

To do this, please follow this guide: https://bitrise-io.github.io/devcenter/docker/run-your-build-locally-in-docker/

Note: for best efficiency you should first do a clean git clone (as described above -> Testing with a full clean git clone) and run docker from there, so that files which are in your .gitignore won’t affect the build, and the build can run the way how it runs on bitrise.io.

Still doesn’t work

Please report the issue at https://discuss.bitrise.io/c/issues/build-issues - we’ll try to help as soon as possible!

3 Likes

Cordova Build module.js:472 throw err;
APK signing failed - Issue with input: [no KeystoreURL parameter specified]
Build fails on bitrise but works locally - ld: library not found for -lRNFetchBlob
Cocoapods install step failing
Bitrise not respecting public/private headers
Bitrise adding additional directory in build path?
SwiftDate via CocoaPods
Instrumentation run failed due to 'Process crashed.'
File writing tests fail in BitRise and pass locally
Tests involving keychain access in iOS
Android fastlane supply failing all time, cannot parse json file
Android fastlane supply failing all time, cannot parse json file
iOS Bundle Identifier not being modified
Gradle -> IllegalArgumentException: !zip.isFile()
Using environment variables in fastlane step
React native Android "com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry"
C compiler cannot create executables
Appium tests / setup
Couldn't find com.android.tools.build:gradle:3.0.0
Random failing Android UI test
Android Google Play Publisher is not working with split builds
Appium cannot find element on iOS Simulator
iOS / Xcode Archive fails with: “Touch” and then “ARCHIVE FAILED”, but no other error in the log
Cordova App Build Fail: framework not found FileProvider for architecture i386
Failed unmarshal json content of the inline environment variables: json: cannot unmarshal number into Go value of type string
Docker failure for Android builds
Build works in local but not on bitrise
Xcode build failed to find scheme in project (steps-xcode-build-for-simulator 0.9.4)
❌ error: exportArchive: No profiles for 'x' were found
'RCTOneSignalExtensionService.h' file not found
Ionic build fails on: platforms/ios/cordova/node_modules/.bin/ios-sim
Xcode Archive failed, error: exit status 65
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
Fastlane step fails with missing digest-crc
Issue with Stripe & Xcode 10
Archive failed, error: exit status 65 Not detecting app store provisioning profile
Not able to generate apk file at gradlew step - Java + Kotlin project
Error 403 on subsequent Android VDT steps
Can't get iOS app to build
Xcode-test build failed on Bitrise CLI
For Swift 4.2, Bitrise can't build, but my mac can build
Gradle Runner Step failing
Failed to get cordova version
Detox build script cannot be found in detox.configurations
Build issue Android and iOS
iOS Running tests in host application fails
Xcode build failed to find scheme in project
Project evaluation failed including an error in afterEvaluate {}
Build Issue
Empty platformBuildVersionName appearing in Android version name
Internal error: failed to create or connect to the perfect build environment. Don't worry, build should restart soon
Gradle execution very slow
Cannot sign the apk
Virtual Testing Devices freezes
Android Build fails issue with Gradlew
Appium tests dont run on the android emulator
[Android] Build failed in GradleRunner step with NDK error (not used)
Certificate-and-profile-installer@1.9.2 (exit code: 1)
Provisioning Profile doesn't match the entitlements file
Cannot execute Appium tests on Bitrise. Invalid Server Instance there are no installed Nodes
Turning off a specific Pod? (Bitrise on iOS)
bundleReleaseJsAndAssets task failed
Virtual-device-testing-for-android (exit code: 1)
Google play deploy - Write failed: Broken pipe
bundleReleaseJsAndAssets fails with error "bundle.getAssets is not a function"
Ionic build sign error
Inonic-archive no platform's iuput exist
Custom podspec clone works, but installation of pod fails
Ineligible destinations for the "App" scheme
Info.plist not exists at
Builds Failing on New Machine (Detox Test)
Cannot get tag when cloning repository for iOS
Export fails with Xcode3Core crash
Github repo cannot be found
iOS - PRODUCT_BUNDLE_IDENTIFIER is missing
Can't get past Fastlane Gym step (module declaration issue - Xcode 8.3)
iOS tests failed randomly/exit status 65
Bitrise build works locally, but failed on Bitrise.io at random unit tests each time
Xamarin iOS build started failing
Is Xamarin Forms .NET Standard 2.0 Already Supported?
Struggling with getting a Xamarin project with .NET Standard project to build
Build fails on bitrise but works locally - ld: library not found for -lRNFetchBlob
Steps-install-missing-android-tools, 2.0.3 failed with exit status 1
Detox failing to run on Bitrise, fine with local setup
Cannot install appium on Android, Ubuntu stack
Xamarin-archive@1.5.0 (exit code: 1)
AndroidTest with Kotlin Code fails
CLI, "missing required input" of keystore (as part of debugging a 'works locally, not in bitrise' situation)
"Check Pods Manifest.lock" always failed
Test UI xcode 9
Fastlane lane is not detecting snapfile
Script@1.1.4 (exit code: 1) Error
Script@1.1.4 (exit code: 1) Error
iOS workflow failed due to embedded library/framework
Reproducible crash on Android Emulators
Hang when Running Unit Test that Import Photos
Detox (Test) failing
CocoaPods fails to install ModelMapper pod
Android project is trying to run test from different branch
Android proguard build error
Error in fastlane/gym Preprocessing Info.plist
React Native packager doesn't work
Build failing with file not found (FBSDK) in IOS build
How to use "enableCodeCoverage" flag For Xcode test step
Trying to use $BITRISE_BUILD_NUMBER in my gradle but kept running into build fail
Build failing with file not found (FBSDK) in IOS build
Xamarin Archive step does not support C# 6 overload resolution
Build schedule has changed on DST transition
Xcode archive step failing
Fastlane scan fails: unable to open dependencies
Getting gateway timeouts when downloading android deps via gradle build
Build Error for React-Native
No response after VPN connection established
No development nor production certificate identified on development portal
Cache:Push step doesn't seem to work?
XCode 9.2 / 9.4 / 10.0 Archive block with signed framework
Flutter Android build fails due to multidex error, compiles locally
For Swift 4.2, Bitrise can’t build for pod files
#2

Most frequent UI/Unit Test issues:

  • Timezone: make sure your tests can run in any timezone, or mock the timezone. You most likely run your tests on your Mac in a different timezone, not the one the bitrise.io build servers are running in.
  • Clean simulator (especially iOS Simulator): your tests will run with a clean simulator on bitrise.io; when testing locally please make sure to use a clean simulator (iOS Simulator: “Reset Content and Settings”).
  • Simulator device: make sure to test with the same device and OS version locally when debugging issues. Your UI tests might expect a certain resolution or other parameter of a device (e.g. if you compare screenshots).
1 Like

#3

iOS Code Signing - debugging Provisioning Profiles:

Xcode looks for provisioning profiles in a single directory: $HOME/Library/MobileDevice/Provisioning Profiles

To test whether your app can be signed with the given signing files (e.g. the one you upload(ed) to bitrise.io):

  1. Create a new directory, e.g. on your Desktop, call it “ProvProfile-Backup”
  2. Open the ~/Library/MobileDevice/Provisioning Profiles directory
    • from Finder: click Go (menu) -> Go to Folder and then copy paste: ~/Library/MobileDevice/Provisioning Profiles
    • or if you prefer the Terminal, run: $ open "$HOME/Library/MobileDevice/Provisioning Profiles"
  3. Move all files from ~/Library/MobileDevice/Provisioning Profiles into the “Backup” directory, to have a backup. Make sure that ~/Library/MobileDevice/Provisioning Profiles is empty!
  4. Now, activate the provisioning profiles you want to test, e.g. download from bitrise.io and double click the files, or just move them into the ~/Library/MobileDevice/Provisioning Profiles directory. Note: if you double click a provisioning profile file, Xcode simply copies that file into the ~/Library/MobileDevice/Provisioning Profiles directory, with the UDID of the profile as the filename, but the filename does not matter actually.
  5. Now try to build / archive / etc your project.

If the build fails, or you’re prompted that files have to be downloaded that means that those files are also required for the actions you do, so you’ll have to upload those files to bitrise.io as well.

Once you can perform all the actions (build, archive, generate ipa, etc.) you want to, that means that all required provisioning profiles are in ~/Library/MobileDevice/Provisioning Profiles, and you can simply upload all of the provisioning profile files from ~/Library/MobileDevice/Provisioning Profiles bitrise.io / copy to another Mac etc. and if the certificate is available on the Mac (or on bitrise.io) the build, archive, export ipa etc. actions will work on the other Mac too.

0 Likes

#4

iOS Code Signing - debugging Certificates (.p12):

The same “temporary remove” for Certificate (which is about the same as for the Prov Profiles above) looks like this:

  1. Open Keychain Access on your Mac
  2. On the left side select the login Keychain (top left area)
  3. Select the My Certificates Category on the left side (bottom left area)
  4. Now, create a backup by selecting all the items on the right side (e.g. by clicking into the right side list and hitting Cmd + a)
  5. Right click -> Export X items…
  6. Save it into a .p12 file e.g. to your Desktop (that .p12 will include all of the certificates and private keys you selected!)
  7. Make sure it’s properly backed up, as private keys can’t be regenerated!! You’ll have to generate new ones if you’d accidentally delete or lose this .p12!
  8. Now that you have your backup, go back to Keychain Access, select all items just like you did before (same Keychain and Category, exactly the same steps) then Right click -> Delete X items… to delete those certs.

At this point your certificate list is empty and you can experiment with importing e.g. the .p12 you uploaded to bitrise.io or with any other .p12 file (e.g. the one you got from your colleague) and try to build with those.

Once you want to restore the original certs simply double click the .p12 backup file you created and that will restore all the original certs & private keys.

0 Likes