calabash / calabash-ios

Calabash for iOS
Other
1.81k stars 369 forks source link

xcodebuild: error: Scheme Companion-cal is not currently configured for the build-for-testing action. #1381

Closed zedtux closed 6 years ago

zedtux commented 6 years ago

I'm building a new react-native app (version 0.55) and followed the wiki to create the -cal target but when I run the tests using Fastlane (where I'm using scan in order to build the app, and then I'm running the calabash tests with $(which bundle) exec cucumber -p ios) it is failing at the building step with the following error:

[09:56:24]: $ set -o pipefail && env NSUnbufferedIO=YES xcodebuild -scheme Companion-cal -project ./ios/Companion.xcodeproj -destination 'platform=iOS Simulator,id=716C8AC7-9F4F-4754-A040-D3121A794B7F' -derivedDataPath '/Users/zedtux/Library/Developer/Xcode/DerivedData/Companion-bjukbjsnzoqxjeamrtsqcoubihhb' build-for-testing | tee '/Users/zedtux/Library/Logs/scan/Companion-cal-Companion-cal.log' | xcpretty  --report html --output '/Users/zedtux/Developments/companion/fastlane/test_output/report.html' --report junit --output '/Users/zedtux/Developments/companion/fastlane/test_output/report.junit' --report junit --output '/var/folders/g6/7k927_v113qdr3fpzp1rtwqr0000gn/T/junit_report20180608-3262-1fe0i46'
[09:56:24]: ▸ Loading...
[09:56:25]: ▸ xcodebuild: error: Scheme Companion-cal is not currently configured for the build-for-testing action.
xcodebuild: error: Scheme Companion-cal is not currently configured for the build-for-testing action.
[09:56:25]: Exit status: 66

Here is the :ios part of my Fastfile :

platform :ios do
  desc 'Runs all the tests'
  lane :tests do
    begin
      # Build the app
      scan(
        scheme: 'Companion-cal',
        project: './ios/Companion.xcodeproj',
        build_for_testing: true, # Do not run the unit tests
        skip_slack: true
      )

      # Run cucumber
      sh 'cd .. && $(which bundle) exec cucumber -p ios'
    ensure
      kill_simulator
      kill_react_native_packager
    end
  end

Looking on SO I found this answer which seem to fix my issue. Is it something I did wrong or should the wiki be updated?

Thank you.

jmoody commented 6 years ago

I don't use fastlane.

build_for_testing implies that you are using XCTest or XCUITest to test your application. You are not using either - you are using Cucumber + Calabash.

You should just build because your tests are Cucumber test not XCTest or XCUITest.

zedtux commented 6 years ago

Thank you @jmoody for your quick reply.

I'm not using build because the code signing part isn't yet done and build is failing due to that. This workaround I'm using is temporary. Do you think it is coming from here?

jmoody commented 6 years ago

I recommend trying automatic code signing.

You can use build-for-testing, but you need to create an XCUITest target whose target application is the -cal target.

zedtux commented 6 years ago

You can use build-for-testing, but you need to create an XCUITest target whose target application is the -cal target.

Isn't what the SO answer I pointed in my issue is doing?

jmoody commented 6 years ago

Maybe?

As I mentioned, I don't use fastlane.

I think you should figure out your code signing problem and use build

zedtux commented 6 years ago

Okay, now I got what you meant by build-for-testing... 😄.

So I configured the signing stuff, and I found how to build with build-for-testing. Now the problem I have is that calabash Launcher is not waiting long enough to run my tests. During the loading of my app, it crashes with Could not connect to the Calabash Server @ http://127.0.0.1:37265/. but my app is still loading my react-native app, and I believe this cause this crash.

Am I wrong ? If I'm right, is there a way to increase the timeout for the Launcher?

zedtux commented 6 years ago

Oh, I wasn't targeting the right scheme 😞. Now it's working, the test are executed against the app 👍.

zedtux commented 6 years ago

In the case, someone using Fastlane is facing this issue, here is my :ios Fastfile part :


platform :ios do
  desc 'Runs all the tests'
  lane :tests do
    begin
      # Build the app
      xcodebuild(
        clean: true,
        scheme: 'Companion-cal',
        project: './ios/Companion.xcodeproj',
        xcargs: ' build-for-testing'
      )

      # Run cucumber
      sh 'cd .. && $(which bundle) exec cucumber -p ios'
    ensure
      kill_simulator
      kill_react_native_packager
    end
  end

  private_lane :kill_simulator do
    puts '💣 Killing iOS Simulator ...'
    sh 'killall "Simulator"; exit 0'
  end

  private_lane :kill_react_native_packager do
    puts '💣 Killing Packager on port 8081 ...'
    sh "lsof -n -i4TCP:8081 | sed '1 d' | awk '{print $2}' | xargs kill -9; exit 0"
  end
end