Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

test task invokes xcodebuild with a -target option instead of -scheme #653

Closed
armcknight opened this issue Jan 8, 2016 · 2 comments
Closed

Comments

@armcknight
Copy link

I have a scheme for a framework target (TestFramework) that also has a test target (TestFrameworkTests) set for running tests against the framework target. There is also a scheme created for the test target.

screen shot 2016-01-08 at 4 09 45 pm

invoking xcodebuild -scheme TestFramework[Tests] -sdk iphonesimulator test runs the tests fine, but xctool -scheme TestFramework[Tests] -sdk iphonesimulator test fails. I noticed by using -showTasks that the xctool invocation generates the following xcodebuild invocation:

/Applications/Xcode7_1_1/Xcode.app/Contents/Developer/usr/bin/xcodebuild \
    -configuration \
    Debug \
    -sdk \
    iphonesimulator9.1 \
    PLATFORM_NAME=iphonesimulator \
    -project \
    //Users/amcknight/Desktop/TestFramework/TestFramework.xcodeproj \
    -target \
    TestFrameworkTests \
    OBJROOT=/Users/amcknight/Desktop/TestFramework/Build/Intermediates \
    SYMROOT=/Users/amcknight/Desktop/TestFramework/Build/Products \
    SHARED_PRECOMPS_DIR=/Users/amcknight/Desktop/TestFramework/Build/Intermediates/PrecompiledHeaders \
    TARGETED_DEVICE_FAMILY=1,2 \
    test \
    -showBuildSettings

simply replacing the -target with -scheme fixes the issue. Is there a reason this doesn't happen?

Test project can be downloaded from: https://www.dropbox.com/s/ulq1433uhcm9euw/TestFramework.zip?dl=0

The invocations I used are in xcodebuild-test.sh and xctool-test.sh

@armcknight
Copy link
Author

OK, I found this comment

  // For Xcode 6, we can pass `test -showBuildSettings` to xcodebuild and get
  // build settings that are specific to the `test` action.  But in Xcode 7
  // `-scheme` should be passed along with `test` action which isn't always
  // defined. So we are using `build` action which doesn't require to specify
  // scheme.
  NSString *action = ToolchainIsXcode7OrBetter() ? @"build" : @"test";

here: https://github.com/facebook/xctool/blob/master/xctool/xctool/TestableExecutionInfo.m#L94

If there were a way to find if a scheme exists for the target (I'm sure there is somewhere in the project), I wonder if it would then be as easy as always providing test as the action and swapping out the @"-target", target with @"-scheme", <corresponding name of scheme>, and fall back to the current logic otherwise?

@armcknight
Copy link
Author

tracking work at https://github.com/armcknight/xctool/pull/1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant