mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
Added includeCarthageRelated global flag, updated tests + documentation to reflect changes
This commit is contained in:
@@ -111,6 +111,7 @@ Note that target names can also be changed by adding a `name` property to a targ
|
||||
- `bottom` (default) - at the bottom, after other files
|
||||
- [ ] **transitivelyLinkDependencies**: **Bool** - If this is `true` then targets will link to the dependencies of their target dependencies. If a target should embed its dependencies, such as application and test bundles, it will embed these transitive dependencies as well. Some complex setups might want to set this to `false` and explicitly specify dependencies at every level. Targets can override this with [Target](#target).transitivelyLinkDependencies. Defaults to `false`.
|
||||
- [ ] **generateEmptyDirectories**: **Bool** - If this is `true` then empty directories will be added to project too else will be missed. Defaults to `false`.
|
||||
- [ ] **includeCarthageRelatedDependencies**: **Bool** - When this is set to `true`, any carthage dependency with related dependencies will be included automatically. This flag can be overriden individually for each carthage dependency - for more details see See **includeRelated** in the [Dependency](#dependency) section. Defaults to `false`.
|
||||
|
||||
```yaml
|
||||
options:
|
||||
|
||||
@@ -10,6 +10,33 @@
|
||||
"version": "4.3.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Carthage",
|
||||
"repositoryURL": "https://github.com/Carthage/Carthage.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "6e1e70541ce8692945569cbcf6c9f108ee69af98",
|
||||
"version": "0.32.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Commandant",
|
||||
"repositoryURL": "https://github.com/Carthage/Commandant.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "07cad52573bad19d95844035bf0b25acddf6b0f6",
|
||||
"version": "0.15.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Curry",
|
||||
"repositoryURL": "https://github.com/thoughtbot/Curry.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "b6bf27ec9d711f607a8c7da9ca69ee9eaa201a22",
|
||||
"version": "4.0.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "JSONUtilities",
|
||||
"repositoryURL": "https://github.com/yonaskolb/JSONUtilities.git",
|
||||
@@ -19,6 +46,15 @@
|
||||
"version": "4.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Nimble",
|
||||
"repositoryURL": "https://github.com/Quick/Nimble.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "9a281b1cfa1c53d1e8bd92e1798e4e473af8d263",
|
||||
"version": "7.3.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "PathKit",
|
||||
"repositoryURL": "https://github.com/kylef/PathKit.git",
|
||||
@@ -28,6 +64,24 @@
|
||||
"version": "0.9.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "PrettyColors",
|
||||
"repositoryURL": "https://github.com/jdhealy/PrettyColors.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "1954a28331668a706134dc315fe264b15b74984e",
|
||||
"version": "5.0.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Quick",
|
||||
"repositoryURL": "https://github.com/Quick/Quick.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "f2b5a06440ea87eba1a167cab37bf6496646c52e",
|
||||
"version": "1.3.4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Rainbow",
|
||||
"repositoryURL": "https://github.com/onevcat/Rainbow.git",
|
||||
@@ -37,6 +91,33 @@
|
||||
"version": "3.1.4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "ReactiveSwift",
|
||||
"repositoryURL": "https://github.com/ReactiveCocoa/ReactiveSwift.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "4f6a12ae6762e825b0e19a4f7076eafa43847e6e",
|
||||
"version": "4.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "ReactiveTask",
|
||||
"repositoryURL": "https://github.com/Carthage/ReactiveTask.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "0f3be6022e2435e1bb91679bc2aabeff13eb794c",
|
||||
"version": "0.15.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Result",
|
||||
"repositoryURL": "https://github.com/antitypical/Result.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "2ca499ba456795616fbc471561ff1d963e6ae160",
|
||||
"version": "4.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Spectre",
|
||||
"repositoryURL": "https://github.com/kylef/Spectre.git",
|
||||
@@ -64,6 +145,15 @@
|
||||
"version": "4.1.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Tentacle",
|
||||
"repositoryURL": "https://github.com/mdiep/Tentacle.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "ace0aedb5bd90a41de254808dbe633813f7b1882",
|
||||
"version": "0.12.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "xcodeproj",
|
||||
"repositoryURL": "https://github.com/tuist/xcodeproj.git",
|
||||
|
||||
@@ -33,7 +33,7 @@ public struct Dependency: Equatable {
|
||||
public enum DependencyType: Equatable {
|
||||
case target
|
||||
case framework
|
||||
case carthage(includeRelated: Bool)
|
||||
case carthage(includeRelated: Bool?)
|
||||
case sdk
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ extension Dependency: JSONObjectConvertible {
|
||||
type = .framework
|
||||
reference = framework
|
||||
} else if let carthage: String = jsonDictionary.json(atKeyPath: "carthage") {
|
||||
let includeRelated = jsonDictionary.json(atKeyPath: "includeRelated") ?? false
|
||||
let includeRelated: Bool? = jsonDictionary.json(atKeyPath: "includeRelated")
|
||||
type = .carthage(includeRelated: includeRelated)
|
||||
reference = carthage
|
||||
} else if let sdk: String = jsonDictionary.json(atKeyPath: "sdk") {
|
||||
|
||||
@@ -20,6 +20,7 @@ public struct SpecOptions: Equatable {
|
||||
public var transitivelyLinkDependencies: Bool
|
||||
public var groupSortPosition: GroupSortPosition
|
||||
public var generateEmptyDirectories: Bool
|
||||
public var includeCarthageRelatedDependencies: Bool
|
||||
|
||||
public enum ValidationType: String {
|
||||
case missingConfigs
|
||||
@@ -74,7 +75,8 @@ public struct SpecOptions: Equatable {
|
||||
defaultConfig: String? = nil,
|
||||
transitivelyLinkDependencies: Bool = false,
|
||||
groupSortPosition: GroupSortPosition = .bottom,
|
||||
generateEmptyDirectories: Bool = false
|
||||
generateEmptyDirectories: Bool = false,
|
||||
includeCarthageRelatedDependencies: Bool = false
|
||||
) {
|
||||
self.minimumXcodeGenVersion = minimumXcodeGenVersion
|
||||
self.carthageBuildPath = carthageBuildPath
|
||||
@@ -93,6 +95,7 @@ public struct SpecOptions: Equatable {
|
||||
self.transitivelyLinkDependencies = transitivelyLinkDependencies
|
||||
self.groupSortPosition = groupSortPosition
|
||||
self.generateEmptyDirectories = generateEmptyDirectories
|
||||
self.includeCarthageRelatedDependencies = includeCarthageRelatedDependencies
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,6 +122,7 @@ extension SpecOptions: JSONObjectConvertible {
|
||||
transitivelyLinkDependencies = jsonDictionary.json(atKeyPath: "transitivelyLinkDependencies") ?? false
|
||||
groupSortPosition = jsonDictionary.json(atKeyPath: "groupSortPosition") ?? .bottom
|
||||
generateEmptyDirectories = jsonDictionary.json(atKeyPath: "generateEmptyDirectories") ?? false
|
||||
includeCarthageRelatedDependencies = jsonDictionary.json(atKeyPath: "includeCarthageRelatedDependencies") ?? false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,8 @@ public struct CarthageDependencyResolver {
|
||||
for dependency in nonExistentDependencies {
|
||||
switch dependency.type {
|
||||
case .carthage(let includeRelated):
|
||||
if includeRelated == true {
|
||||
let includeRelated = includeRelated ?? project.options.includeCarthageRelatedDependencies
|
||||
if includeRelated {
|
||||
relatedDependencies(for: dependency, in: target.platform)
|
||||
.filter { !frameworks.contains($0) }
|
||||
.forEach { frameworks.insert($0) }
|
||||
|
||||
@@ -573,6 +573,7 @@ public class PBXProjGenerator {
|
||||
targetFrameworkBuildFiles.append(buildFile)
|
||||
|
||||
case .carthage(let includeRelated):
|
||||
let includeRelated = includeRelated ?? project.options.includeCarthageRelatedDependencies
|
||||
let allDependencies = includeRelated
|
||||
? carthageResolver.relatedDependencies(for: dependency, in: target.platform) : [dependency]
|
||||
allDependencies.forEach { dependency in
|
||||
|
||||
@@ -98,7 +98,23 @@ class CarthageDependencyResolverTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testDependenciesForTopLevelTarget() {
|
||||
|
||||
let dependencyFixtureName = "CarthageTestFixture"
|
||||
let carthageBuildPath = fixturePath + "TestProject/Carthage/Build"
|
||||
|
||||
describe {
|
||||
|
||||
$0.it("overrides the includeRelated dependency global flag when specified") {
|
||||
let options = SpecOptions(carthageBuildPath: carthageBuildPath.string, includeCarthageRelatedDependencies: true)
|
||||
let dependency = Dependency(type: .carthage(includeRelated: false), reference: dependencyFixtureName)
|
||||
|
||||
let resolver = CarthageDependencyResolver(project: makeTestProject(options: options))
|
||||
let target = Target(name: "1", type: .application, platform: .iOS, dependencies: [dependency])
|
||||
let dependencies = resolver.dependencies(for: target)
|
||||
|
||||
try expect(dependencies) == [dependency]
|
||||
}
|
||||
|
||||
$0.it("fetches all carthage dependencies for a given target, sorted alphabetically") {
|
||||
let unsortedDependencyReferences = ["RxSwift", "RxCocoa", "RxBlocking", "RxTest", "RxAtomic"]
|
||||
let dependencies = unsortedDependencyReferences.map {
|
||||
|
||||
@@ -617,7 +617,8 @@ class SpecLoadingTests: XCTestCase {
|
||||
tvOS: "10.0",
|
||||
watchOS: "3.0",
|
||||
macOS: "10.12.1"
|
||||
)
|
||||
),
|
||||
includeCarthageRelatedDependencies: true
|
||||
)
|
||||
let expected = Project(name: "test", options: options)
|
||||
let dictionary: [String: Any] = ["options": [
|
||||
@@ -627,6 +628,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
"createIntermediateGroups": true,
|
||||
"developmentLanguage": "ja",
|
||||
"deploymentTarget": ["iOS": 11.1, "tvOS": 10.0, "watchOS": "3", "macOS": "10.12.1"],
|
||||
"includeCarthageRelatedDependencies": true
|
||||
]]
|
||||
let parsedSpec = try getProjectSpec(dictionary)
|
||||
try expect(parsedSpec) == expected
|
||||
|
||||
Reference in New Issue
Block a user