-
Notifications
You must be signed in to change notification settings - Fork 466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include test targets in recreate_user_schemes #139
Comments
I came across this while using XCode 5.1, but I'm not sure if it's only that version which has problems. |
If there is in fact a straightforward way to add test targets manually, I'd love to hear it. After a few attempts I couldn't figure out how to make it work so for now I'm giving in and adding shared schemes to my project. |
Can you post the diff of the files after being edited by xcodeproj? |
Here's a diff of xcschemes directories generated by each method (with XCode files first): diff -Nur xcode-xcschemes/TestProject.xcscheme xcodeproj-xcschemes/TestProject.xcscheme
--- xcode-xcschemes/TestProject.xcscheme 2014-03-18 09:49:54.000000000 -0700
+++ xcodeproj-xcschemes/TestProject.xcscheme 2014-03-18 09:56:56.000000000 -0700
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0510"
+ LastUpgradeVersion = "0500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -28,26 +28,7 @@
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
- <TestableReference
- skipped = "NO">
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "A2CDAA1618D8AFB500C90658"
- BuildableName = "TestProjectTests.xctest"
- BlueprintName = "TestProjectTests"
- ReferencedContainer = "container:TestProject.xcodeproj">
- </BuildableReference>
- </TestableReference>
</Testables>
- <MacroExpansion>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "A2CDA9FB18D8AFB500C90658"
- BuildableName = "TestProject.app"
- BlueprintName = "TestProject"
- ReferencedContainer = "container:TestProject.xcodeproj">
- </BuildableReference>
- </MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
@@ -58,15 +39,6 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
- <BuildableProductRunnable>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "A2CDA9FB18D8AFB500C90658"
- BuildableName = "TestProject.app"
- BlueprintName = "TestProject"
- ReferencedContainer = "container:TestProject.xcodeproj">
- </BuildableReference>
- </BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
@@ -76,15 +48,6 @@
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
- <BuildableProductRunnable>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "A2CDA9FB18D8AFB500C90658"
- BuildableName = "TestProject.app"
- BlueprintName = "TestProject"
- ReferencedContainer = "container:TestProject.xcodeproj">
- </BuildableReference>
- </BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
diff -Nur xcode-xcschemes/TestProjectTests.xcscheme xcodeproj-xcschemes/TestProjectTests.xcscheme
--- xcode-xcschemes/TestProjectTests.xcscheme 1969-12-31 16:00:00.000000000 -0800
+++ xcodeproj-xcschemes/TestProjectTests.xcscheme 2014-03-18 09:56:56.000000000 -0700
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0500"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "A2CDAA1618D8AFB500C90658"
+ BuildableName = "TestProjectTests.xctest"
+ BlueprintName = "TestProjectTests"
+ ReferencedContainer = "container:TestProject.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ buildConfiguration = "Debug">
+ <Testables>
+ </Testables>
+ </TestAction>
+ <LaunchAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Debug"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ allowLocationSimulation = "YES">
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Release"
+ debugDocumentVersioning = "YES">
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff -Nur xcode-xcschemes/xcschememanagement.plist xcodeproj-xcschemes/xcschememanagement.plist
--- xcode-xcschemes/xcschememanagement.plist 2014-03-18 09:49:54.000000000 -0700
+++ xcodeproj-xcschemes/xcschememanagement.plist 2014-03-18 09:56:56.000000000 -0700
@@ -6,22 +6,16 @@
<dict>
<key>TestProject.xcscheme</key>
<dict>
- <key>orderHint</key>
- <integer>0</integer>
- </dict>
- </dict>
- <key>SuppressBuildableAutocreation</key>
- <dict>
- <key>A2CDA9FB18D8AFB500C90658</key>
- <dict>
- <key>primary</key>
+ <key>isShown</key>
<true/>
</dict>
- <key>A2CDAA1618D8AFB500C90658</key>
+ <key>TestProjectTests.xcscheme</key>
<dict>
- <key>primary</key>
+ <key>isShown</key>
<true/>
</dict>
</dict>
+ <key>SuppressBuildableAutocreation</key>
+ <dict/>
</dict>
</plist> Note that only Xcodeproj generates the TestProjectTests scheme. |
I think that the only missing piece to implement this is understanding the logic which Xcode uses to identify schemes? Is is based on the naming convention |
recreate_user_schemes
do not specify test targets
I had a similar issue and my diff (for only one of my targets) is below. Basically instead of a diff --git a/project-a-unittest.xcscheme b/project-a-unittest 2.xcscheme
index 692535e..644ec99 100644
--- a/project-a-unittest.xcscheme
+++ b/project-a-unittest 2.xcscheme
@@ -5,22 +5,6 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
- <BuildActionEntries>
- <BuildActionEntry
- buildForTesting = "YES"
- buildForRunning = "YES"
- buildForProfiling = "YES"
- buildForArchiving = "YES"
- buildForAnalyzing = "YES">
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "7C7124886C864E99BAAC79B5"
- BuildableName = "project-a-unittest"
- BlueprintName = "project-a-unittest"
- ReferencedContainer = "container:ios_x86/xcode/project-a.xcodeproj">
- </BuildableReference>
- </BuildActionEntry>
- </BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
@@ -28,6 +12,16 @@
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
+ <TestableReference
+ skipped = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "7C7124886C864E99BAAC79B5"
+ BuildableName = "project-a-unittest.xctest"
+ BlueprintName = "project-a-unittest"
+ ReferencedContainer = "container:build/ios_x86/xcode/project-a.xcodeproj">
+ </BuildableReference>
+ </TestableReference>
</Testables>
</TestAction>
<LaunchAction |
Dependant on #227. |
Does anyone have a workaround to get this running ? I want to set up a test target and run it like this: require 'rubygems' project = Xcodeproj::Project.new('test.xcodeproj') test_target = project.new_target(:unit_test_bundle, 'testing', :ios, '8.0',project.main_group,:objc) // Add a file to the project in the main group // Add the file to the main target //project.recreate_user_schemes project.save() Option 1 Option 2 Both options have problems, Option 1 does not work automatically the second one does not work at all. Do you have any idea how i can get this running ? |
@tkohub I just merged #288 which now allows you to manipulate XCScheme directly and easily add TestableReferences and all. It should help you with your issue and allow you to configure your scheme and targets to be tested anyhow you want :-) (and hopefully make a PR to add it to (Note: #288 is on master but hasn't been released yet — it will be in the next rubygem release —so you'll need to either use Xcodeproj's master or wait for the next Xcodeproj release) Keep us posted to tell if it helped solved your needs. |
When opening a project with tests in XCode the autogenerated schemes have
<TestableReference>
s defined in their<Testables>
element, but schemes generated byrecreate_user_schemes
do not, which meansxcodebuild test
doesn't know what to do.I think there's some way I can add
<TestableReference>
s manually (viaXCScheme.add_test_target
), but ifrecreate_user_schemes
is supposed to act just like XCode then this shouldn't be necessary.Demonstration
Create a new project in XCode which has at least one test.
Quit XCode.
Run a script like the following:
It should work and the test(s) should run.
Quit XCode.
Now for the bug. Run a script like the following:
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<TestableReference>
s.The text was updated successfully, but these errors were encountered: