Merge branch 'master' into external-target-ref

This commit is contained in:
Yuta Saito 2019-09-23 00:29:35 +09:00 committed by GitHub
commit cd1d370d91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 4 deletions

View File

@ -7,11 +7,13 @@
- Added `includes` to `sources` for a Target. This follows the same glob-style as `excludes` but functions as a way to only include files that match a specified pattern. Useful if you only want a certain file type, for example specifying `**/*.swift`. [#637](https://github.com/yonaskolb/XcodeGen/pull/637) @bclymer
- Support `dylib` SDK. [#650](https://github.com/yonaskolb/XcodeGen/pull/650) @kateinoigakukun
- Added `language` and `region` options for `run` and `test` scheme [#654](https://github.com/yonaskolb/XcodeGen/pull/654) @kateinoigakukun
- Added `debugEnabled` option for `run` and `test` scheme [#657](https://github.com/yonaskolb/XcodeGen/pull/657) @kateinoigakukun
- Support External Target Reference. [#655](https://github.com/yonaskolb/XcodeGen/pull/655) @kateinoigakukun
#### Fixed
- Expand template variable in Array of Any [#651](https://github.com/yonaskolb/XcodeGen/pull/651) @kateinoigakukun
- Significantly improve performance when running with a large number files. [#658](https://github.com/yonaskolb/XcodeGen/pull/658) @kateinoigakukun
## 2.7.0

View File

@ -691,6 +691,7 @@ The different actions share some properties:
- [ ] **disableMainThreadChecker**: **Bool** - `run` and `test` actions can define a boolean that indicates that this scheme should disable the Main Thread Checker. This defaults to false
- [ ] **language**: **String** - `run` and `test` actions can define a language that is used for Application Language
- [ ] **region**: **String** - `run` and `test` actions can define a language that is used for Application Region
- [ ] **debugEnabled**: **Bool** - `run` and `test` actions can define a whether debugger should be used. This defaults to true.
### Execution Action

View File

@ -69,6 +69,7 @@ public struct Scheme: Equatable {
public struct Run: BuildAction {
public static let disableMainThreadCheckerDefault = false
public static let debugEnabledDefault = true
public var config: String?
public var commandLineArguments: [String: Bool]
@ -78,6 +79,7 @@ public struct Scheme: Equatable {
public var disableMainThreadChecker: Bool
public var language: String?
public var region: String?
public var debugEnabled: Bool
public init(
config: String,
@ -87,7 +89,8 @@ public struct Scheme: Equatable {
environmentVariables: [XCScheme.EnvironmentVariable] = [],
disableMainThreadChecker: Bool = disableMainThreadCheckerDefault,
language: String? = nil,
region: String? = nil
region: String? = nil,
debugEnabled: Bool = debugEnabledDefault
) {
self.config = config
self.commandLineArguments = commandLineArguments
@ -97,12 +100,14 @@ public struct Scheme: Equatable {
self.disableMainThreadChecker = disableMainThreadChecker
self.language = language
self.region = region
self.debugEnabled = debugEnabled
}
}
public struct Test: BuildAction {
public static let gatherCoverageDataDefault = false
public static let disableMainThreadCheckerDefault = false
public static let debugEnabledDefault = true
public var config: String?
public var gatherCoverageData: Bool
@ -114,6 +119,7 @@ public struct Scheme: Equatable {
public var environmentVariables: [XCScheme.EnvironmentVariable]
public var language: String?
public var region: String?
public var debugEnabled: Bool
public struct TestTarget: Equatable, ExpressibleByStringLiteral {
public static let randomExecutionOrderDefault = false
@ -161,7 +167,8 @@ public struct Scheme: Equatable {
postActions: [ExecutionAction] = [],
environmentVariables: [XCScheme.EnvironmentVariable] = [],
language: String? = nil,
region: String? = nil
region: String? = nil,
debugEnabled: Bool = debugEnabledDefault
) {
self.config = config
self.gatherCoverageData = gatherCoverageData
@ -173,6 +180,7 @@ public struct Scheme: Equatable {
self.environmentVariables = environmentVariables
self.language = language
self.region = region
self.debugEnabled = debugEnabled
}
public var shouldUseLaunchSchemeArgsEnv: Bool {
@ -324,6 +332,7 @@ extension Scheme.Run: JSONObjectConvertible {
disableMainThreadChecker = jsonDictionary.json(atKeyPath: "disableMainThreadChecker") ?? Scheme.Run.disableMainThreadCheckerDefault
language = jsonDictionary.json(atKeyPath: "language")
region = jsonDictionary.json(atKeyPath: "region")
debugEnabled = jsonDictionary.json(atKeyPath: "debugEnabled") ?? Scheme.Run.debugEnabledDefault
}
}
@ -343,6 +352,9 @@ extension Scheme.Run: JSONEncodable {
dict["disableMainThreadChecker"] = disableMainThreadChecker
}
if debugEnabled != Scheme.Run.debugEnabledDefault {
dict["debugEnabled"] = debugEnabled
}
return dict
}
}
@ -372,6 +384,7 @@ extension Scheme.Test: JSONObjectConvertible {
environmentVariables = try XCScheme.EnvironmentVariable.parseAll(jsonDictionary: jsonDictionary)
language = jsonDictionary.json(atKeyPath: "language")
region = jsonDictionary.json(atKeyPath: "region")
debugEnabled = jsonDictionary.json(atKeyPath: "debugEnabled") ?? Scheme.Test.debugEnabledDefault
}
}
@ -396,6 +409,10 @@ extension Scheme.Test: JSONEncodable {
dict["disableMainThreadChecker"] = disableMainThreadChecker
}
if debugEnabled != Scheme.Run.debugEnabledDefault {
dict["debugEnabled"] = debugEnabled
}
return dict
}
}

View File

@ -161,6 +161,7 @@ public class SchemeGenerator {
testables: testables,
preActions: scheme.test?.preActions.map(getExecutionAction) ?? [],
postActions: scheme.test?.postActions.map(getExecutionAction) ?? [],
selectedDebuggerIdentifier: (scheme.test?.debugEnabled ?? Scheme.Test.debugEnabledDefault) ? XCScheme.defaultDebugger : "",
shouldUseLaunchSchemeArgsEnv: scheme.test?.shouldUseLaunchSchemeArgsEnv ?? true,
codeCoverageEnabled: scheme.test?.gatherCoverageData ?? Scheme.Test.gatherCoverageDataDefault,
disableMainThreadChecker: scheme.test?.disableMainThreadChecker ?? Scheme.Test.disableMainThreadCheckerDefault,
@ -176,6 +177,8 @@ public class SchemeGenerator {
preActions: scheme.run?.preActions.map(getExecutionAction) ?? [],
postActions: scheme.run?.postActions.map(getExecutionAction) ?? [],
macroExpansion: shouldExecuteOnLaunch ? nil : buildableReference,
selectedDebuggerIdentifier: (scheme.run?.debugEnabled ?? Scheme.Run.debugEnabledDefault) ? XCScheme.defaultDebugger : "",
selectedLauncherIdentifier: (scheme.run?.debugEnabled ?? Scheme.Run.debugEnabledDefault) ? XCScheme.defaultLauncher : "Xcode.IDEFoundation.Launcher.PosixSpawn",
disableMainThreadChecker: scheme.run?.disableMainThreadChecker ?? Scheme.Run.disableMainThreadCheckerDefault,
commandlineArguments: launchCommandLineArgs,
environmentVariables: launchVariables,

View File

@ -242,12 +242,15 @@ class SourceGenerator {
let groupReference: PBXGroup
if let cachedGroup = groupsByPath[path] {
var cachedGroupChildren = cachedGroup.children
for child in children {
// only add the children that aren't already in the cachedGroup
if !cachedGroup.children.contains(child) {
cachedGroup.children.append(child)
// Check equality by path and sourceTree because XcodeProj.PBXObject.== is very slow.
if !cachedGroupChildren.contains(where: { $0.path == child.path && $0.sourceTree == child.sourceTree }) {
cachedGroupChildren.append(child)
}
}
cachedGroup.children = cachedGroupChildren
groupReference = cachedGroup
} else {

View File

@ -87,6 +87,9 @@ class SchemeGeneratorTests: XCTestCase {
try expect(xcscheme.profileAction?.buildConfiguration) == "Release"
try expect(xcscheme.analyzeAction?.buildConfiguration) == "Debug"
try expect(xcscheme.archiveAction?.buildConfiguration) == "Release"
try expect(xcscheme.launchAction?.selectedDebuggerIdentifier) == XCScheme.defaultDebugger
try expect(xcscheme.testAction?.selectedDebuggerIdentifier) == XCScheme.defaultDebugger
}
$0.it("sets environment variables for a scheme") {
@ -174,6 +177,27 @@ class SchemeGeneratorTests: XCTestCase {
try expect(xcscheme.profileAction?.environmentVariables) == variables
}
$0.it("generate scheme without debugger") {
let scheme = Scheme(
name: "TestScheme",
build: Scheme.Build(targets: [buildTarget]),
run: Scheme.Run(config: "Debug", debugEnabled: false)
)
let project = Project(
name: "test",
targets: [app, framework],
schemes: [scheme]
)
let xcodeProject = try project.generateXcodeProject()
guard let xcscheme = xcodeProject.sharedData?.schemes.first else {
throw failure("Scheme not found")
}
try expect(xcscheme.launchAction?.selectedDebuggerIdentifier) == ""
try expect(xcscheme.launchAction?.selectedLauncherIdentifier) == "Xcode.IDEFoundation.Launcher.PosixSpawn"
}
$0.it("generates pre and post actions for target schemes") {
var target = app
target.scheme = TargetScheme(