So, it turned out to be an issue in the project itself, not related to the Simulator version at all.
I saw the project is open source (https://github.com/bluesnap/bluesnap-ios) so I registered cloned it & registered it for my own account, then I did Remote Desktop / VNC into the Build VM ( https://gist.github.com/viktorbenei/c6d4fe1e68de739dbb5f4f15de76b9db ) and tried to run the same xcodebuild
command - it failed with the same issue.
The thing is, once the project is opened in Xcode.app, it works from there as well from the terminal (using Xcode’s command line tool, xcodebuild
).
But if you don’t open it in Xcode.app first then it might or might not work, depends on the environment. Exactly what part of the environment I’m not sure, tried a couple of things but didn’t find the exact thing that makes it work or not work. Of course feel free to search for the error message (‘XCTest/XCTestDefines.h’ file not found
and the lines around it) in Google, there are quite a few possible reasons at least for the file not found
one, when it works from Xcode.app but not from the terminal / xcodebuild
. You can of course also VNC/Remote Desktop into the Build VM and try to debug it yourself ( https://gist.github.com/viktorbenei/c6d4fe1e68de739dbb5f4f15de76b9db ). I tried my best but didn’t have enough time, especially as it worked after opening the project in Xcode.app via a Script 
Historically these kind of issues (works once the project is opened in Xcode.app, but does not work with xcodebuild
without opening it in Xcode.app first) are related to some kind of Scheme issue, e.g. when the Scheme is not marked as shared, but in your case the Scheme you specified seems to be marked as shared and those issues are usually reproducible in every environment before opening the project in Xcode.app first, while in your case it happens in some environments but not in others.
My guess right now is that you might have .gitignore
d an important part of the scheme (schemes are stored as directories - http://devcenter.bitrise.io/ios/frequent-ios-issues/#xcode-scheme-not-found -> “This change should be reflected in your git repository, under you project / workspace (which is actually a directory, just seems like a file in Finder): *.xcodeproj OR *.xcworkspace/xcshareddata/xcschemes/SchemeName.xcscheme”).
We saw issues related to things like these before, e.g. that part of the Scheme was committed into the repo but then it got .gitignored
, in which case the state before the .gitignore
is still in the repo, but not the updates, e.g. other files related to the scheme / which reference the scheme, leaving it in a broken state. Usually opening the project in Xcode.app helps as Xcode.app can auto generate these Scheme related files - in fact if the Scheme is not marked as shared then it’s generated exactly when the project is opened in Xcode.app the first time.
Of course it can be related to something else too, but in any case this is not Bitrise related. It’s related to something in the environment (our build VMs are clean macOS installs with Xcode.app and a couple of tools preinstalled, and that’s pretty much all - you’d get the same after doing a clean install; you can find all the scripts we use for the prepare of the VM images at: https://github.com/bitrise-io/osx-box-bootstrap ) in combination with your xcode project.
Anyway, if you have some time feel free to remote desktop / vnc into the build VM and try to debug exactly what causes the issue.
The solution is quite simple: open the workspace file in Xcode.app
You can do that with a Script step, right before the first Xcode step:
#!/usr/bin/env bash
set -ex
open "$BITRISE_PROJECT_PATH"
That’s all. Once the project is opened in Xcode.app all other steps which use Xcode’s command line tool (xcodebuild
) will work. Of course this has a slight performance penalty, but in general it should be fine if your build is not RAM constraint.
I hope this helps, if you’d have any questions just let me know! 
P.S.: I’ll try to see which files change when the project is opened in Xcode.app once I have some time 