mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
Add improved support for simple iOS sticker packs (#824)
* Allow messages applications to skip the compile sources phase By default, simple iOS sticker packs created in Xcode do not include a compile sources phase. This change will allow messages applications with an empty list of sources to skip that phase entirely. * Add support for launchAutomaticallySubstyle in run schemes This is especially important for simple iOS sticker packs that require this run scheme setting to be set to 2 in order to run the scheme properly.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
## Next Version
|
||||
#### Added
|
||||
- Improve speed of metadata parsing and dependency resolution. [#803](https://github.com/yonaskolb/XcodeGen/pull/803) @michaeleisel
|
||||
- Improve support for iOS sticker packs and add support for `launchAutomaticallySubstyle` to run schemes. [#824](https://github.com/yonaskolb/XcodeGen/pull/824) @scelis
|
||||
|
||||
## 2.15.1
|
||||
|
||||
|
||||
@@ -7,3 +7,4 @@ These are a bunch of real world examples of XcodeGen project specs. Feel free to
|
||||
- [johndpope/swift-models](https://github.com/johndpope/swift-models/tree/stable/Inference)
|
||||
- [atelier-socle/AppRepositoryTemplate](https://github.com/atelier-socle/AppRepositoryTemplate/blob/master/project.yml)
|
||||
- [atelier-socle/FrameworkRepositoryTemplate](https://github.com/atelier-socle/FrameworkRepositoryTemplate/blob/master/project.yml)
|
||||
- [scelis/XcodeGen-TestStickers](https://github.com/scelis/XcodeGen-TestStickers/blob/master/project.yml)
|
||||
|
||||
@@ -738,6 +738,7 @@ The different actions share some properties:
|
||||
- [ ] **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.
|
||||
- [ ] **simulateLocation**: **[Simulate Location](#simulate-location)** - `run` action can define a simulated location
|
||||
- [ ] **launchAutomaticallySubstyle**: **String** - `run` action can define the launch automatically substyle ('2' for extensions).
|
||||
|
||||
### Execution Action
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ public struct Scheme: Equatable {
|
||||
public var stopOnEveryMainThreadCheckerIssue: Bool
|
||||
public var language: String?
|
||||
public var region: String?
|
||||
public var launchAutomaticallySubstyle: String?
|
||||
public var debugEnabled: Bool
|
||||
public var simulateLocation: SimulateLocation?
|
||||
|
||||
@@ -120,6 +121,7 @@ public struct Scheme: Equatable {
|
||||
stopOnEveryMainThreadCheckerIssue: Bool = stopOnEveryMainThreadCheckerIssueDefault,
|
||||
language: String? = nil,
|
||||
region: String? = nil,
|
||||
launchAutomaticallySubstyle: String? = nil,
|
||||
debugEnabled: Bool = debugEnabledDefault,
|
||||
simulateLocation: SimulateLocation? = nil
|
||||
) {
|
||||
@@ -132,6 +134,7 @@ public struct Scheme: Equatable {
|
||||
self.stopOnEveryMainThreadCheckerIssue = stopOnEveryMainThreadCheckerIssue
|
||||
self.language = language
|
||||
self.region = region
|
||||
self.launchAutomaticallySubstyle = launchAutomaticallySubstyle
|
||||
self.debugEnabled = debugEnabled
|
||||
self.simulateLocation = simulateLocation
|
||||
}
|
||||
@@ -349,6 +352,14 @@ extension Scheme.Run: JSONObjectConvertible {
|
||||
region = jsonDictionary.json(atKeyPath: "region")
|
||||
debugEnabled = jsonDictionary.json(atKeyPath: "debugEnabled") ?? Scheme.Run.debugEnabledDefault
|
||||
simulateLocation = jsonDictionary.json(atKeyPath: "simulateLocation")
|
||||
|
||||
// launchAutomaticallySubstyle is defined as a String in XcodeProj but its value is often
|
||||
// an integer. Parse both to be nice.
|
||||
if let int: Int = jsonDictionary.json(atKeyPath: "launchAutomaticallySubstyle") {
|
||||
launchAutomaticallySubstyle = String(int)
|
||||
} else if let string: String = jsonDictionary.json(atKeyPath: "launchAutomaticallySubstyle") {
|
||||
launchAutomaticallySubstyle = string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,6 +373,7 @@ extension Scheme.Run: JSONEncodable {
|
||||
"config": config,
|
||||
"language": language,
|
||||
"region": region,
|
||||
"launchAutomaticallySubstyle": launchAutomaticallySubstyle,
|
||||
]
|
||||
|
||||
if disableMainThreadChecker != Scheme.Run.disableMainThreadCheckerDefault {
|
||||
|
||||
@@ -41,6 +41,17 @@ extension PBXProductType {
|
||||
public var name: String {
|
||||
rawValue.replacingOccurrences(of: "com.apple.product-type.", with: "")
|
||||
}
|
||||
|
||||
public var canSkipCompileSourcesBuildPhase: Bool {
|
||||
switch self {
|
||||
case .stickerPack, .messagesApplication:
|
||||
// Sticker packs and simple messages applications without sources should not include a
|
||||
// compile sources build phase. Doing so can cause Xcode to produce an error on build.
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Platform {
|
||||
|
||||
@@ -927,9 +927,7 @@ public class PBXProjGenerator {
|
||||
}
|
||||
|
||||
let sourcesBuildPhaseFiles = getBuildFilesForPhase(.sources)
|
||||
// Sticker packs should not include a compile sources build phase as they
|
||||
// are purely based on a set of image files, and nothing else.
|
||||
let shouldSkipSourcesBuildPhase = sourcesBuildPhaseFiles.isEmpty && target.type == .stickerPack
|
||||
let shouldSkipSourcesBuildPhase = sourcesBuildPhaseFiles.isEmpty && target.type.canSkipCompileSourcesBuildPhase
|
||||
if !shouldSkipSourcesBuildPhase {
|
||||
let sourcesBuildPhase = addObject(PBXSourcesBuildPhase(files: sourcesBuildPhaseFiles))
|
||||
buildPhases.append(sourcesBuildPhase)
|
||||
|
||||
@@ -241,7 +241,8 @@ public class SchemeGenerator {
|
||||
commandlineArguments: launchCommandLineArgs,
|
||||
environmentVariables: launchVariables,
|
||||
language: scheme.run?.language,
|
||||
region: scheme.run?.region
|
||||
region: scheme.run?.region,
|
||||
launchAutomaticallySubstyle: scheme.run?.launchAutomaticallySubstyle
|
||||
)
|
||||
|
||||
let profileAction = XCScheme.ProfileAction(
|
||||
|
||||
@@ -1441,7 +1441,6 @@
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 1FC6945BE13C2202A2BCA3BC /* Build configuration list for PBXNativeTarget "iMessageApp" */;
|
||||
buildPhases = (
|
||||
D067D70CFD13DFBED478C228 /* Sources */,
|
||||
61001E265009194959C2CF36 /* Resources */,
|
||||
2F0735A423E554B267BBA0A5 /* Embed App Extensions */,
|
||||
);
|
||||
@@ -2143,13 +2142,6 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
D067D70CFD13DFBED478C228 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
D1F422E9C4DD531AA88418C9 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
|
||||
@@ -475,7 +475,8 @@ class ProjectSpecTests: XCTestCase {
|
||||
settingsTarget: "foo")],
|
||||
environmentVariables: [XCScheme.EnvironmentVariable(variable: "foo",
|
||||
value: "bar",
|
||||
enabled: false)]),
|
||||
enabled: false)],
|
||||
launchAutomaticallySubstyle: "2"),
|
||||
test: Scheme.Test(config: "Config",
|
||||
gatherCoverageData: true,
|
||||
disableMainThreadChecker: true,
|
||||
|
||||
@@ -771,6 +771,10 @@ class SpecLoadingTests: XCTestCase {
|
||||
],
|
||||
],
|
||||
],
|
||||
"run": [
|
||||
"config": "debug",
|
||||
"launchAutomaticallySubstyle": 2,
|
||||
],
|
||||
"test": [
|
||||
"config": "debug",
|
||||
"targets": [
|
||||
@@ -806,6 +810,12 @@ class SpecLoadingTests: XCTestCase {
|
||||
try expect(scheme.build.parallelizeBuild) == false
|
||||
try expect(scheme.build.buildImplicitDependencies) == false
|
||||
|
||||
let expectedRun = Scheme.Run(
|
||||
config: "debug",
|
||||
launchAutomaticallySubstyle: "2"
|
||||
)
|
||||
try expect(scheme.run) == expectedRun
|
||||
|
||||
let expectedTest = Scheme.Test(
|
||||
config: "debug",
|
||||
gatherCoverageData: true,
|
||||
@@ -835,6 +845,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
["variable": "ENVIRONMENT", "value": "VARIABLE"],
|
||||
["variable": "OTHER_ENV_VAR", "value": "VAL", "isEnabled": false],
|
||||
],
|
||||
"launchAutomaticallySubstyle": "2"
|
||||
],
|
||||
"test": [
|
||||
"environmentVariables": [
|
||||
@@ -864,11 +875,26 @@ class SpecLoadingTests: XCTestCase {
|
||||
]
|
||||
|
||||
try expect(scheme.run?.environmentVariables) == expectedRunVariables
|
||||
try expect(scheme.run?.launchAutomaticallySubstyle) == "2"
|
||||
try expect(scheme.test?.environmentVariables) == expectedTestVariables
|
||||
try expect(scheme.profile?.config) == "Release"
|
||||
try expect(scheme.profile?.environmentVariables.isEmpty) == true
|
||||
}
|
||||
|
||||
$0.it("parses alternate schemes variables") {
|
||||
let schemeDictionary: [String: Any] = [
|
||||
"build": [
|
||||
"targets": ["Target1": "all"],
|
||||
],
|
||||
"run": [
|
||||
"launchAutomaticallySubstyle": 2, // Both integer and string supported
|
||||
],
|
||||
]
|
||||
|
||||
let scheme = try Scheme(name: "Scheme", jsonDictionary: schemeDictionary)
|
||||
try expect(scheme.run?.launchAutomaticallySubstyle) == "2"
|
||||
}
|
||||
|
||||
$0.it("parses scheme templates") {
|
||||
let targetDictionary: [String: Any] = [
|
||||
"deploymentTarget": "1.2.0",
|
||||
|
||||
@@ -51,7 +51,7 @@ class SchemeGeneratorTests: XCTestCase {
|
||||
let scheme = Scheme(
|
||||
name: "MyScheme",
|
||||
build: Scheme.Build(targets: [buildTarget], preActions: [preAction]),
|
||||
run: Scheme.Run(config: "Debug", simulateLocation: simulateLocation)
|
||||
run: Scheme.Run(config: "Debug", launchAutomaticallySubstyle: "2", simulateLocation: simulateLocation)
|
||||
)
|
||||
let project = Project(
|
||||
name: "test",
|
||||
@@ -94,6 +94,7 @@ class SchemeGeneratorTests: XCTestCase {
|
||||
try expect(xcscheme.launchAction?.selectedDebuggerIdentifier) == XCScheme.defaultDebugger
|
||||
try expect(xcscheme.testAction?.selectedDebuggerIdentifier) == XCScheme.defaultDebugger
|
||||
|
||||
try expect(xcscheme.launchAction?.launchAutomaticallySubstyle) == "2"
|
||||
try expect(xcscheme.launchAction?.allowLocationSimulation) == true
|
||||
try expect(xcscheme.launchAction?.locationScenarioReference?.referenceType) == Scheme.SimulateLocation.ReferenceType.predefined.rawValue
|
||||
try expect(xcscheme.launchAction?.locationScenarioReference?.identifier) == "New York, NY, USA"
|
||||
|
||||
Reference in New Issue
Block a user