1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
/*
This source file is part of the Swift.org open source project
Copyright (c) 2021 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
*/
import XCTest
import Basics
import TSCUtility
import _InternalTestSupport
import PackageModel
import PackageLoading
class PackageDescriptionAppleProductLoadingTests: PackageDescriptionLoadingTests {
override var toolsVersion: ToolsVersion {
.v6_0 // TODO: confirm this value
}
func testApplicationProducts() throws {
#if ENABLE_APPLE_PRODUCT_TYPES
let content = """
import PackageDescription
import AppleProductTypes
let package = Package(
name: "Foo",
products: [
.iOSApplication(
name: "Foo",
targets: ["Foo"],
bundleIdentifier: "com.my.app",
teamIdentifier: "ZXYTEAM123",
displayVersion: "1.4.2 Extra Cool",
bundleVersion: "1.4.2",
appIcon: .asset("icon"),
accentColor: .asset("accentColor"),
supportedDeviceFamilies: [.pad, .mac],
supportedInterfaceOrientations: [.portrait, .portraitUpsideDown(), .landscapeRight(.when(deviceFamilies: [.mac]))],
capabilities: [
.camera(purposeString: "All the better to see you with…"),
.microphone(purposeString: "All the better to hear you with…", .when(deviceFamilies: [.pad, .phone])),
.localNetwork(purposeString: "Communication is key…", bonjourServiceTypes: ["_ipp._tcp"], .when(deviceFamilies: [.mac]))
],
appCategory: .developerTools
),
],
targets: [
.executableTarget(
name: "Foo"
),
]
)
"""
let observability = ObservabilitySystem.makeForTesting()
let (manifest, _) = try loadAndValidateManifest(content, observabilityScope: observability.topScope)
XCTAssertNoDiagnostics(observability.diagnostics)
// Check the targets. We expect to have a single executable target.
XCTAssertEqual(manifest.targets.count, 1)
let mainTarget = manifest.targets[0]
XCTAssertEqual(mainTarget.type, .executable)
XCTAssertEqual(mainTarget.name, "Foo")
// Check the products. We expect to have a single executable product with iOS-specific settings.
XCTAssertEqual(manifest.products.count, 1)
let appProduct = manifest.products[0]
// Check the core properties and basic settings of the application product.
XCTAssertEqual(appProduct.type, .executable)
XCTAssertEqual(appProduct.settings.count, 5)
XCTAssertTrue(appProduct.settings.contains(.bundleIdentifier("com.my.app")))
XCTAssertTrue(appProduct.settings.contains(.bundleVersion("1.4.2")))
// Find the "iOS Application Info" setting.
var appInfoSetting: ProductSetting.IOSAppInfo? = nil
for case let ProductSetting.iOSAppInfo(value) in appProduct.settings {
appInfoSetting = .init(value)
}
guard let appInfoSetting = appInfoSetting else {
return XCTFail("product has no .iOSAppInfo() setting")
}
// Check the specific properties of the iOS Application Info.
XCTAssertEqual(appInfoSetting.appIcon, .asset(name: "icon"))
XCTAssertEqual(appInfoSetting.accentColor, .asset(name: "accentColor"))
XCTAssertEqual(appInfoSetting.supportedDeviceFamilies, [.pad, .mac])
XCTAssertEqual(appInfoSetting.supportedInterfaceOrientations, [
.portrait(condition: nil),
.portraitUpsideDown(condition: nil),
.landscapeRight(condition: .init(deviceFamilies: [.mac]))
])
XCTAssertEqual(appInfoSetting.capabilities, [
.init(purpose: "camera", purposeString: "All the better to see you with…", condition: nil),
.init(purpose: "microphone", purposeString: "All the better to hear you with…", condition: .init(deviceFamilies: [.pad, .phone])),
.init(purpose: "localNetwork", purposeString: "Communication is key…", bonjourServiceTypes: ["_ipp._tcp"], condition: .init(deviceFamilies: [.mac]))
])
XCTAssertEqual(appInfoSetting.appCategory?.rawValue, "public.app-category.developer-tools")
#else
throw XCTSkip("ENABLE_APPLE_PRODUCT_TYPES is not set")
#endif
}
}
|