generate TestTargetID project attributes for unit tests

This commit is contained in:
Yonas Kolb
2018-12-05 19:13:27 +11:00
parent c1334c6d9b
commit 12aea54878
2 changed files with 15 additions and 7 deletions
+6 -7
View File
@@ -310,8 +310,8 @@ public class PBXProjGenerator {
var targetAttributes: [PBXTarget: [String: Any]] = [:]
let uiTestTargets = pbxProj.nativeTargets.filter { $0.productType == .uiTestBundle }
for uiTestTarget in uiTestTargets {
let testTargets = pbxProj.nativeTargets.filter { $0.productType == .uiTestBundle || $0.productType == .unitTestBundle }
for testTarget in testTargets {
// look up TEST_TARGET_NAME build setting
func testTargetName(_ target: PBXTarget) -> String? {
@@ -322,11 +322,10 @@ public class PBXProjGenerator {
.first
}
guard let name = testTargetName(uiTestTarget) else { continue }
guard let name = testTargetName(testTarget) else { continue }
guard let target = self.pbxProj.targets(named: name).first else { continue }
// FIX: Can't set in xcproj 5.0+
targetAttributes[uiTestTarget, default: [:]].merge(["TestTargetID": target])
targetAttributes[testTarget, default: [:]].merge(["TestTargetID": target])
}
func generateTargetAttributes(_ target: ProjectTarget, pbxTarget: PBXTarget) {
@@ -817,12 +816,12 @@ public class PBXProjGenerator {
}
// automatically set test target name
if target.type == .uiTestBundle,
if target.type == .uiTestBundle || target.type == .unitTestBundle,
!project.targetHasBuildSetting("TEST_TARGET_NAME", target: target, config: config) {
for dependency in target.dependencies {
if dependency.type == .target,
let dependencyTarget = project.getTarget(dependency.reference),
dependencyTarget.type == .application {
dependencyTarget.type.isApp {
buildSettings["TEST_TARGET_NAME"] = dependencyTarget.name
break
}
@@ -1362,6 +1362,9 @@
AT_D40C01B2BAD29EDEA392714DFB69FE8F = {
CUSTOM = value;
};
NT_193BAF154270D1C21E269EDF2A1BD3F6 = {
TestTargetID = NT_BEB0891E36797FE2214A0A9D516D408D;
};
NT_B91A6EACD6F5192FECA2E95FD531D0CA = {
ProvisioningStyle = Automatic;
};
@@ -2829,6 +2832,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.project.App-iOS-Tests";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = App_iOS;
};
name = "Production Debug";
};
@@ -3119,6 +3123,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.project.App-iOS-Tests";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = App_iOS;
};
name = "Staging Release";
};
@@ -3359,6 +3364,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.project.App-iOS-Tests";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = App_iOS;
};
name = "Test Release";
};
@@ -3843,6 +3849,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.project.App-iOS-Tests";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = App_iOS;
};
name = "Test Debug";
};
@@ -4472,6 +4479,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.project.App-iOS-Tests";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = App_iOS;
};
name = "Production Release";
};
@@ -4488,6 +4496,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.project.App-iOS-Tests";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = App_iOS;
};
name = "Staging Debug";
};