Skip to content
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

Generate UI Test Target Attributes #221

Merged
merged 7 commits into from
Jan 10, 2018
Merged

Generate UI Test Target Attributes #221

merged 7 commits into from
Jan 10, 2018

Conversation

anreitersimon
Copy link

It seems that iOS UITest targets generated with XCodeGen fail to run (tested with Xcode 9.2).

The TargetApplication Setting for the UITest target isn't configured correctly.

Ive noticed toggling this setting in Xcode results in these diffs.

isa = PBXProject;
	attributes = {
		LastUpgradeCheck = 0920;
+		TargetAttributes = {
+			NT_493099431306 = {
+				TestTargetID = NT_791681633892;
+			};
+		};
	};

This appears to be some sort of look-up table for determining what target to test.

NT_493099431306 is the file-reference for the UITestTarget
NT_791681633892 is the file-reference for the target matching the UITestTargets TEST_TARGET_NAME

This PR adds generation of these target attributes

Copy link
Owner

@yonaskolb yonaskolb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.flatMap { ref in self.proj.objects.buildConfigurations[ref] }

return configs
.flatMap { $0.buildSettings["TEST_TARGET_NAME"] as? String }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's interesting that this could change across configs. I wonder how Xcode deals with this. This is probably fine though

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about that too.
Xcode doesnt let you specify this on a per configuration basis.
Meaning it adds the TEST_TARGET_NAME setting to all configurations.
and then (i assume) generates the target-attributes.

try expect(dependencies.count) == 1
try expect(dependencies.first!.target) == nativeTargets.first { $0.name == framework.name }!.reference
try expect(dependencies.count) == 2
try expect(dependencies[0].target) == nativeTargets.first { $0.name == framework.name }!.reference
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relying on the order in which target target-dependencies are generated might not be very resilient.
I did not know how to fix this.
Actually "resolving" the dependencies and then asserting that they reference the correct target might be a better aproach.

@yonaskolb yonaskolb changed the title Generate Target Attributes Generate UI Test Target Attributes Jan 10, 2018
@yonaskolb yonaskolb merged commit a9c5696 into yonaskolb:master Jan 10, 2018
@yonaskolb yonaskolb mentioned this pull request Jan 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants