Skip to content

Commit

Permalink
Bugfix/SimulateLocation Fix (yonaskolb#973)
Browse files Browse the repository at this point in the history
* Preemptively fix compilation for latest XcodeProj

* Add StoreKitConfiguration to scheme and generator

* Add scheme generator test

* Fix and add tests

* Support StoreKitConfiguration in TargetScheme

* Set default type of `storekit` to `.none`

* Upgrade XcodeProj to 7.15.0

* Create struct for StoreKitConfiguration

* Update tests

* Add storekit configuration to test project

* Update changelog

* Update project spec

* Fix xcodeprojs

* Fix projects

* Capitalize String

* Update CHANGELOG.md

Co-authored-by: Gemma Barlow <gemmakbarlow@gmail.com>

* Refactor StoreKitConfiguration init from json

* Change `forWorkspace` to `pathPrefix` and add tests

* Replace StoreKitConfiguration struct with string + option

* Fix tests

* Update project spec

* Fixup changelog

* Add `See Options` to `storeKitConfiguration` in project spec

* Make `simulateLocation` respect `schemePathPrefix`

* Update docs

Co-authored-by: Gemma Barlow <gemmakbarlow@gmail.com>
  • Loading branch information
jcolicchio and gemmakbarlow committed Feb 15, 2021
1 parent 2c600a7 commit ae186ed
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#### Changed
- **Breaking**: Info.plists with custom prefixes are no longer added to the Copy Bundle Resources build phase [#945](https://github.com/yonaskolb/XcodeGen/pull/945) @anivaros
- **Breaking**: `workingDirectory` of included legacy targets is now made relative to including project [#981](https://github.com/yonaskolb/XcodeGen/pull/981) @jcolicchio
- **Breaking**: Make `simulateLocation` respect `schemePathPrefix` option. [#973](https://github.com/yonaskolb/XcodeGen/pull/973) @jcolicchio

#### Fixed
- Fixed error message output for `minimumXcodeGenVersion`. [#967](https://github.com/yonaskolb/XcodeGen/pull/967) @joshwalker
Expand Down
2 changes: 2 additions & 0 deletions Docs/ProjectSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,8 @@ targets:
- location.gpx
```

Note that the path the gpx file will be prefixed according to the `schemePathPrefix` option in order to support both `.xcodeproj` and `.xcworkspace` setups. See [Options](#options).


### Environment Variable

Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodeGenKit/SchemeGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public class SchemeGenerator {
var locationScenarioReference: XCScheme.LocationScenarioReference?
if let simulateLocation = scheme.run?.simulateLocation, var identifier = simulateLocation.defaultLocation, let referenceType = simulateLocation.referenceType {
if referenceType == .gpx {
var path = Path("../\(identifier)")
var path = Path(components: [project.options.schemePathPrefix, identifier])
path = path.simplifyingParentDirectoryReferences()
identifier = path.string
}
Expand Down
8 changes: 6 additions & 2 deletions Tests/XcodeGenKitTests/SchemeGeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class SchemeGeneratorTests: XCTestCase {
let scheme = Scheme(
name: "EnvironmentVariablesScheme",
build: Scheme.Build(targets: [buildTarget]),
run: Scheme.Run(config: "Debug", environmentVariables: runVariables, storeKitConfiguration: "Configuration.storekit"),
run: Scheme.Run(config: "Debug", environmentVariables: runVariables, simulateLocation: .init(allow: true, defaultLocation: "File.gpx"), storeKitConfiguration: "Configuration.storekit"),
test: Scheme.Test(config: "Debug"),
profile: Scheme.Profile(config: "Debug")
)
Expand All @@ -184,6 +184,8 @@ class SchemeGeneratorTests: XCTestCase {
).beTrue()
try expect(xcscheme.launchAction?.environmentVariables) == runVariables
try expect(xcscheme.launchAction?.storeKitConfigurationFileReference?.identifier) == "../Configuration.storekit"
try expect(xcscheme.launchAction?.locationScenarioReference?.referenceType) == Scheme.SimulateLocation.ReferenceType.gpx.rawValue
try expect(xcscheme.launchAction?.locationScenarioReference?.identifier) == "../File.gpx"
try expect(xcscheme.testAction?.environmentVariables).to.beNil()
try expect(xcscheme.profileAction?.environmentVariables).to.beNil()
}
Expand Down Expand Up @@ -238,7 +240,7 @@ class SchemeGeneratorTests: XCTestCase {
let scheme = Scheme(
name: "TestScheme",
build: Scheme.Build(targets: [buildTarget]),
run: Scheme.Run(config: "Debug", debugEnabled: false, storeKitConfiguration: "Configuration.storekit")
run: Scheme.Run(config: "Debug", debugEnabled: false, simulateLocation: .init(allow: true, defaultLocation: "File.gpx"), storeKitConfiguration: "Configuration.storekit")
)
let project = Project(
name: "test",
Expand All @@ -252,6 +254,8 @@ class SchemeGeneratorTests: XCTestCase {
try expect(xcscheme.launchAction?.selectedDebuggerIdentifier) == ""
try expect(xcscheme.launchAction?.selectedLauncherIdentifier) == "Xcode.IDEFoundation.Launcher.PosixSpawn"
try expect(xcscheme.launchAction?.storeKitConfigurationFileReference?.identifier) == "../../Configuration.storekit"
try expect(xcscheme.launchAction?.locationScenarioReference?.referenceType) == Scheme.SimulateLocation.ReferenceType.gpx.rawValue
try expect(xcscheme.launchAction?.locationScenarioReference?.identifier) == "../../File.gpx"
}

$0.it("generate scheme without debugger - test") {
Expand Down

0 comments on commit ae186ed

Please sign in to comment.