CocoaPods / CocoaPods/Xcodeproj

Include test targets in recreate_user_schemes

Open
#139 9 comments 0 reactions 0 assignees View on GitHub
d2:moderate s3:detailed t1:enhancement
Dominant language
Ruby
Stars
2.4k
Forks
488
PR merge metrics
No merged PRs in 30d

Description

When opening a project with tests in XCode the autogenerated schemes have ``s defined in their `` element, but schemes generated by `recreate_user_schemes` do not, which means `xcodebuild test` doesn't know what to do.

I think there's some way I can add ``s manually (via `XCScheme.add_test_target`), but if `recreate_user_schemes` is supposed to act just like XCode then this shouldn't be necessary.

---
### Demonstration
1. Create a new project in XCode which has at least one test.
2. Quit XCode.
3. Run a script like the following:

``` bash
#!/usr/bin/env bash

PROJECT=TestProject
PROJECT_FILE=$PROJECT.xcodeproj

# Clean up generated schemes.
rm -rf $PROJECT_FILE/xcuserdata/*.xcuserdatad/xcschemes

# Get XCode to generate schemes.
open "$PROJECT_FILE"
sleep 5

xcodebuild test -project "$PROJECT_FILE" -scheme "$PROJECT" -sdk iphonesimulator
```

It should work and the test(s) should run.
4. Quit XCode.
5. Now for the bug. Run a script like the following:

``` bash
#!/usr/bin/env bash

PROJECT=TestProject
PROJECT_FILE=$PROJECT.xcodeproj

# Clean up generated schemes.
rm -rf $PROJECT_FILE/xcuserdata/*.xcuserdatad/xcschemes

# Use Xcodeproj to generate schemes.
gem install xcodeproj
echo "
require 'xcodeproj'
project = Xcodeproj::Project.open '$PROJECT_FILE'
project.recreate_user_schemes
project.save
" | ruby

xcodebuild test -project "$PROJECT_FILE" -scheme "$PROJECT" -sdk iphonesimulator
```

**`xcodebuild` will complain about "Scheme TestProject is not currently configured for the test action", and if you inspect the generated scheme you'll notice that it doesn't specify any ``s.**

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at Project#recreate_user_schemes and compare its generated scheme with the Xcode-generated scheme, focusing on the Testables element and TestableReference entries. Review XCScheme.add_test_target and verify the result with the demonstrated xcodebuild test command; done means the recreated scheme is configured for testing and the tests run.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
build-system, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.