Skip to content

Commit

Permalink
We are able to generate the project
Browse files Browse the repository at this point in the history
  • Loading branch information
pietrocaselani committed May 18, 2019
1 parent 46512cd commit fa4c7f0
Show file tree
Hide file tree
Showing 32 changed files with 146 additions and 74 deletions.
File renamed without changes.
23 changes: 0 additions & 23 deletions CouchTrackerUITests/CouchTrackerUITests.swift

This file was deleted.

197 changes: 146 additions & 51 deletions Project.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,140 @@
import ProjectDescription

// MARK: - Extensions

func + (lhs: [String: String], rhs: [String: String]) -> [String: String] {
return lhs.merging(rhs) { first, second in first }
}

extension Dictionary where Key == String, Value == String {
func asConfig() -> Configuration {
return Configuration(settings: self)
}
}


// MARK: - Constants

let baseBundleId = "io.github.pietrocaselani"
let miniOSVersion = "10.0"

// MARK: - Target structures

enum CouchTracker {
static let name = "CouchTracker"
static func target() -> Target {
return Target(name: CouchTracker.name,
platform: .iOS,
product: .app,
bundleId: "\(baseBundleId).couchtracker",
infoPlist: "CouchTracker/Info.plist",
sources: ["CouchTracker/**"],
resources: ["CouchTracker/Resources/**"],
dependencies: [
.target(name: "CouchTrackerApp"),
.target(name: "CouchTrackerPersistence"),
.target(name: "CouchTrackerDebug"),
.target(name: "CouchTrackerCore-iOS"),
.target(name: "TMDBSwift-iOS"),
.target(name: "TVDBSwift-iOS"),
.target(name: "TraktSwift-iOS"),
],
settings: settings())
}

private static func settings() -> Settings {
let debug = [
"PROVISIONING_PROFILE_SPECIFIER": "match Development io.github.pietrocaselani.couchtracker"
] + baseSettingsiOSTargets() + debugCodeSigning()


let release = [
"PROVISIONING_PROFILE_SPECIFIER": "match AppStore io.github.pietrocaselani.couchtracker"
] + baseSettingsiOSTargets() + releaseCodeSigning()

return Settings(debug: debug.asConfig(), release: release.asConfig())
}
}

enum CouchTrackerUITests {
static let name = "CouchTrackerUITests"

static func target() -> Target {
return Target(name: CouchTrackerUITests.name,
platform: .macOS,
product: .unitTests,
bundleId: "\(baseBundleId).CouchTrackerUITests",
infoPlist: "CouchTrackerUITests/Info.plist",
sources: ["CouchTrackerUITests/**"],
dependencies: [
.target(name: "CouchTrackerAppTestable")
],
settings: settings())
}

private static func settings() -> Settings {
let base = [
"TEST_HOST": "$(BUILT_PRODUCTS_DIR)/CouchTracker.app/CouchTracker",
"BUNDLE_LOADER": "$(TEST_HOST)",
] + disableCodeSigning() + baseSettingsiOSTargets()
return Settings(base: base)
}
}

enum CouchTrackerApp {
static let name = "CouchTrackerApp"

static func target() -> Target {
return Target(name: CouchTrackerApp.name,
platform: .iOS,
product: .framework,
bundleId: "\(baseBundleId).CouchTrackerApp",
infoPlist: "CouchTrackerApp/Info.plist",
sources: ["CouchTrackerApp/**"],
resources: ["CouchTrackerApp/Resources/**"],
headers: Headers(public: "CouchTrackerApp/Headers/Public/CouchTrackerApp.h"),
dependencies: [
.target(name: "CouchTrackerPersistence"),
.target(name: "CouchTrackerDebug"),
.target(name: "CouchTrackerCore-iOS"),
.target(name: "TMDBSwift-iOS"),
.target(name: "TVDBSwift-iOS"),
.target(name: "TraktSwift-iOS"),
],
settings: settings())
}

private static func settings() -> Settings {
return Settings(base: baseSettingsiOSTargets(),
debug: debugCodeSigning().asConfig(),
release: releaseCodeSigning().asConfig())
}
}

// MARK: - Settings functions

func baseSettingsiOSTargets() -> [String: String] {
return [
"IPHONEOS_DEPLOYMENT_TARGET": miniOSVersion,
"TARGETED_DEVICE_FAMILY": "1",
"CODE_SIGN_STYLE": "Manual",
"DEVELOPMENT_TEAM": "B5RPM7SE3L",
]
}

func disableCodeSigning() -> [String: String] {
return ["CODE_SIGN_IDENTITY": ""]
}

func releaseCodeSigning() -> [String: String] {
return ["CODE_SIGN_IDENTITY": "iPhone Distribution"]
}

func debugCodeSigning() -> [String: String] {
return ["CODE_SIGN_IDENTITY": "iPhone Developer"]
}

// MARK: - Legacy

func traktSwiftTargets() -> [Target] {
return [
Expand Down Expand Up @@ -31,7 +165,7 @@ func traktSwiftTargets() -> [Target] {
bundleId: "\(baseBundleId).TraktSwiftTests",
infoPlist: "TraktSwiftTests/Info.plist",
sources: ["TraktSwiftTests/**"],
dependencies: [])
dependencies: []),
]
}

Expand Down Expand Up @@ -64,7 +198,7 @@ func tmdbSwiftTargets() -> [Target] {
bundleId: "\(baseBundleId).TMDBSwiftTests",
infoPlist: "TMDBSwiftTests/Info.plist",
sources: ["TMDBSwiftTests/**"],
dependencies: [])
dependencies: []),
]
}

Expand Down Expand Up @@ -97,7 +231,7 @@ func tvdbSwiftTargets() -> [Target] {
bundleId: "\(baseBundleId).TVDBSwiftTests",
infoPlist: "TVDBSwiftTests/Info.plist",
sources: ["TVDBSwiftTests/**"],
dependencies: [])
dependencies: []),
]
}

Expand Down Expand Up @@ -131,34 +265,20 @@ func couchTrackerCoreTargets() -> [Target] {
bundleId: "\(baseBundleId).CouchTrackerCoreTests",
infoPlist: "CouchTrackerCoreTests/Info.plist",
sources: ["CouchTrackerCoreTests/**"],
dependencies: [])
dependencies: []),
]
}

func couchTrackerAppTargets() -> [Target] {
return [
Target(name: "CouchTrackerApp",
platform: .iOS,
product: .framework,
bundleId: "\(baseBundleId).CouchTrackerApp",
infoPlist: "CouchTrackerApp/Info.plist",
sources: ["CouchTrackerApp/**"],
dependencies: [
.target(name: "CouchTrackerPersistence"),
.target(name: "CouchTrackerDebug"),
.target(name: "CouchTrackerCore-iOS"),
.target(name: "TMDBSwift-iOS"),
.target(name: "TVDBSwift-iOS"),
.target(name: "TraktSwift-iOS"),
]),
Target(name: "CouchTrackerAppTestable",
platform: .macOS,
product: .framework,
bundleId: "\(baseBundleId).CouchTrackerAppTestable",
infoPlist: "CouchTrackerAppTestable/Info.plist",
sources: ["CouchTrackerAppTestable/**"],
dependencies: [])
]
dependencies: []),
] + [CouchTrackerApp.target()]
}

func persistanceAndDebugTargets() -> [Target] {
Expand All @@ -178,44 +298,19 @@ func persistanceAndDebugTargets() -> [Target] {
sources: ["CouchTrackerDebug/**"],
dependencies: [
.target(name: "CouchTrackerCore-iOS"),
])
]
}

func couchTrackerTargets() -> [Target] {
return [
Target(name: "CouchTracker",
platform: .iOS,
product: .app,
bundleId: "\(baseBundleId).couchtracker",
infoPlist: "CouchTracker/Info.plist",
sources: ["CouchTracker/**"],
dependencies: [
.target(name: "CouchTrackerApp"),
.target(name: "CouchTrackerPersistence"),
.target(name: "CouchTrackerDebug"),
.target(name: "CouchTrackerCore-iOS"),
.target(name: "TMDBSwift-iOS"),
.target(name: "TVDBSwift-iOS"),
.target(name: "TraktSwift-iOS"),
]),
Target(name: "CouchTrackerUITests",
platform: .macOS,
product: .unitTests,
bundleId: "\(baseBundleId).CouchTrackerUITests",
infoPlist: "CouchTrackerUITests/Info.plist",
sources: ["CouchTrackerUITests/**"],
dependencies: [])
]
}

func allTargets() -> [Target] {
let apiTargets = traktSwiftTargets() + tmdbSwiftTargets() + tvdbSwiftTargets()
let dependencies = couchTrackerCoreTargets() + couchTrackerAppTargets() + persistanceAndDebugTargets()
let appTargets = couchTrackerTargets()
let apiTargets = traktSwiftTargets() + tmdbSwiftTargets() + tvdbSwiftTargets()
let dependencies = couchTrackerAppTargets() + couchTrackerCoreTargets() + persistanceAndDebugTargets()
let appTargets = [CouchTracker.target(), CouchTrackerUITests.target()]

return apiTargets + dependencies + appTargets
return appTargets + dependencies + apiTargets
}

// MARK: - Project

let project = Project(name: "CouchTracker",
targets: allTargets())

0 comments on commit fa4c7f0

Please sign in to comment.