in src/TulsiGeneratorTests/PBXTargetGeneratorTests.swift [2170:2340]
func testGenerateWatchOSTarget() {
let appTargetName = "targetName"
let appBuildPath = "test/app"
let appBuildTarget = "\(appBuildPath):\(appTargetName)"
let watchAppTargetName = "watchAppTargetName"
let watchAppBuildPath = "test/watchapp"
let watchAppBuildTarget = "\(watchAppBuildPath):\(watchAppTargetName)"
let watchExtTargetName = "watchExtTargetName"
let watchExtBuildPath = "test/watchext"
let watchExtBuildTarget = "\(watchExtBuildPath):\(watchExtTargetName)"
let appBundleID = "appBundleID"
let watchAppBundleID = "watchAppBundleID"
let watchExtBundleID = "watchAppExtBundleID"
let rules = Set([
makeTestRuleEntry(
appBuildTarget,
type: "ios_application",
extensions: Set([BuildLabel(watchAppBuildTarget)]),
bundleID: appBundleID,
productType: .Application,
platformType: "ios",
osDeploymentTarget: "9.0"),
makeTestRuleEntry(
watchAppBuildTarget,
type: "watchos_application",
extensions: Set([BuildLabel(watchExtBuildTarget)]),
bundleID: watchAppBundleID,
productType: .Watch2App,
extensionBundleID: watchExtBundleID,
platformType: "watchos",
osDeploymentTarget: "2.0"),
makeTestRuleEntry(
watchExtBuildTarget,
type: "watchos_extension",
bundleID: watchExtBundleID,
productType: .Watch2Extension,
platformType: "watchos",
osDeploymentTarget: "2.0"),
])
do {
_ = try targetGenerator.generateBuildTargetsForRuleEntries(
rules, ruleEntryMap: RuleEntryMap(), pathFilters: pathFilters)
} catch let e as NSError {
XCTFail("Failed to generate build targets with error \(e.localizedDescription)")
}
let topLevelConfigs = project.buildConfigurationList.buildConfigurations
XCTAssertEqual(topLevelConfigs.count, 0)
let targets = project.targetByName
XCTAssertEqual(targets.count, 3)
do {
let expectedBuildSettings = [
"ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
"BAZEL_TARGET": appBuildTarget,
"DEBUG_INFORMATION_FORMAT": "dwarf",
"INFOPLIST_FILE": stubPlistPaths.defaultStub,
"PRODUCT_BUNDLE_IDENTIFIER": appBundleID,
"PRODUCT_NAME": appTargetName,
"SDKROOT": "iphoneos",
"IPHONEOS_DEPLOYMENT_TARGET": "9.0",
"TULSI_BUILD_PATH": appBuildPath,
]
let expectedTarget = TargetDefinition(
name: appTargetName,
buildConfigurations: [
BuildConfigurationDefinition(
name: "Debug",
expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
),
BuildConfigurationDefinition(
name: "Release",
expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
),
BuildConfigurationDefinition(
name: "__TulsiTestRunner_Debug",
expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
BuildConfigurationDefinition(
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
],
expectedBuildPhases: [
BazelShellScriptBuildPhaseDefinition(bazelPath: bazelPath, buildTarget: appBuildTarget),
]
)
assertTarget(expectedTarget, inTargets: targets)
}
do {
let expectedBuildSettings = [
"ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
"BAZEL_TARGET": watchAppBuildTarget,
"DEBUG_INFORMATION_FORMAT": "dwarf",
"INFOPLIST_FILE": stubPlistPaths.watchOSStub,
"PRODUCT_BUNDLE_IDENTIFIER": watchAppBundleID,
"PRODUCT_NAME": watchAppTargetName,
"SDKROOT": "watchos",
"WATCHOS_DEPLOYMENT_TARGET": "2.0",
"TULSI_BUILD_PATH": watchAppBuildPath,
]
let expectedTarget = TargetDefinition(
name: watchAppTargetName,
buildConfigurations: [
BuildConfigurationDefinition(
name: "Debug",
expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
),
BuildConfigurationDefinition(
name: "Release",
expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
),
BuildConfigurationDefinition(
name: "__TulsiTestRunner_Debug",
expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
BuildConfigurationDefinition(
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
],
expectedBuildPhases: [
BazelShellScriptBuildPhaseDefinition(
bazelPath: bazelPath, buildTarget: watchAppBuildTarget),
]
)
assertTarget(expectedTarget, inTargets: targets)
}
do {
let expectedBuildSettings = [
"ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": "Stub Launch Image",
"BAZEL_TARGET": watchExtBuildTarget,
"DEBUG_INFORMATION_FORMAT": "dwarf",
"INFOPLIST_FILE": stubPlistPaths.watchOSAppExStub,
"PRODUCT_BUNDLE_IDENTIFIER": watchExtBundleID,
"PRODUCT_NAME": watchExtTargetName,
"SDKROOT": "watchos",
"WATCHOS_DEPLOYMENT_TARGET": "2.0",
"TULSI_BUILD_PATH": watchExtBuildPath,
]
let expectedTarget = TargetDefinition(
name: watchExtTargetName,
buildConfigurations: [
BuildConfigurationDefinition(
name: "Debug",
expectedBuildSettings: debugBuildSettingsFromSettings(expectedBuildSettings)
),
BuildConfigurationDefinition(
name: "Release",
expectedBuildSettings: releaseBuildSettingsFromSettings(expectedBuildSettings)
),
BuildConfigurationDefinition(
name: "__TulsiTestRunner_Debug",
expectedBuildSettings: debugTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
BuildConfigurationDefinition(
name: "__TulsiTestRunner_Release",
expectedBuildSettings: releaseTestRunnerBuildSettingsFromSettings(expectedBuildSettings)
),
],
expectedBuildPhases: [
BazelShellScriptBuildPhaseDefinition(
bazelPath: bazelPath, buildTarget: watchExtBuildTarget),
]
)
assertTarget(expectedTarget, inTargets: targets)
}
}