Skip to content

Commit

Permalink
Merge pull request mac-cain13#476 from Salfetamen/development-pods-fix
Browse files Browse the repository at this point in the history
Development pods output file validation fix
  • Loading branch information
mac-cain13 authored Jan 7, 2019
2 parents a5822fd + 154987f commit 48167ea
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"repositoryURL": "https://github.com/tomlokhorst/XcodeEdit",
"state": {
"branch": null,
"revision": "1055ca180cbea0405b2b98707e79872772b7fe7b",
"version": "2.5.0"
"revision": "90fd97fd8b298319edbb5093f5825b8b44e48680",
"version": "2.5.2"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let package = Package(
name: "rswift",
dependencies: [
.package(url: "https://github.com/kylef/Commander.git", from: "0.8.0"),
.package(url: "https://github.com/tomlokhorst/XcodeEdit", from: "2.4.1")
.package(url: "https://github.com/tomlokhorst/XcodeEdit", from: "2.5.0")
],
targets: [
.target(
Expand Down
6 changes: 3 additions & 3 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- R.swift.Library (5.0.0.alpha.2)
- R.swift.Library (5.0.0)
- SWRevealViewController (2.3.0)

DEPENDENCIES:
Expand All @@ -16,11 +16,11 @@ EXTERNAL SOURCES:

CHECKOUT OPTIONS:
R.swift.Library:
:commit: cb11aec9943393c9903b3623068207b26c9e246b
:commit: 03b3f069f43cab162eaba6e395fd293b6787e022
:git: https://github.com/mac-cain13/R.swift.Library.git

SPEC CHECKSUMS:
R.swift.Library: 3c21b823839bf5a6769dc7f96cb44479dab51b1b
R.swift.Library: 0bf390e729bc10bb2c9e4fb78bd043164a7be4ff
SWRevealViewController: 6d3fd97f70112fd7cef9de14df4260eacce4c63a

PODFILE CHECKSUM: dcf609a63a9cb222b7167b110c27de036120bae0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ _Tip:_ Add the `*.generated.swift` pattern to your `.gitignore` file to prevent
R.swift is built using [Swift Package Manager (SPM)](https://github.com/apple/swift-package-manager).

1. Check out the code
2. Run `swift build -c release -Xswiftc -static-stdlib` from the root directory
2. Run `swift build -c release -Xswiftc -static-stdlib -Xswiftc "-target" -Xswiftc "x86_64-apple-macosx10.11"` from the root directory
3. Follow the manual installation steps with the binary you now have

For developing on R.swift in Xcode, run `swift package generate-xcodeproj --xcconfig-overrides RswiftConfig.xcconfig`.
Expand Down
3 changes: 3 additions & 0 deletions RswiftConfig.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ CONFIGURATION_BUILD_DIR = $(SRCROOT)/build/$CONFIGURATION

// The final product executables and other build products go here
BUILT_PRODUCTS_DIR = $(SRCROOT)/build/$CONFIGURATION

// Mac OS SDK 10.11
MACOSX_DEPLOYMENT_TARGET = 10.11
15 changes: 11 additions & 4 deletions Sources/RswiftCore/EnvironmentValidation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public func validateRswiftEnvironment(
scriptOutputFiles: [String],
lastRunURL: URL,
podsRoot: String?,
podsTargetSrcroot: String?,
commandLineArguments: [String]) -> [String]
{
var errors: [String] = []
Expand All @@ -24,9 +25,11 @@ public func validateRswiftEnvironment(
var error = "Output path must specify a file, it should not be a directory."
if FileManager.default.directoryExists(atPath: outputURL.path) {
let rswiftGeneratedFile = outputURL.appendingPathComponent("R.generated.swift").path

let commandParts = commandLineArguments
.map { $0.replacingOccurrences(of: podsRoot ?? "", with: "$PODS_ROOT") }
.map { $0.replacingOccurrences(of: outputURL.path, with: rswiftGeneratedFile) }
.map { $0.replacingOccurrences(of: podsTargetSrcroot ?? "", with: "$PODS_TARGET_SRCROOT") }
.map { $0.replacingOccurrences(of: podsRoot ?? "", with: "$PODS_ROOT") }
.map { $0.replacingOccurrences(of: sourceRootPath, with: "$SRCROOT") }
.map { $0.contains(" ") ? "\"\($0)\"" : $0 }

Expand All @@ -38,12 +41,16 @@ public func validateRswiftEnvironment(
errors.append(error)
}

if !scriptInputFiles.contains(lastRunURL.path) {
let scriptInputPaths = scriptInputFiles.map { URL(fileURLWithPath: $0).standardized.path }
if !scriptInputPaths.contains(lastRunURL.standardized.path) {
errors.append("Build phase Intput Files does not contain '$TEMP_DIR/\(lastRunURL.lastPathComponent)'.")
}

if !scriptOutputFiles.contains(outputURL.path) {
let path = outputFileForError.replacingOccurrences(of: sourceRootPath, with: "$SRCROOT")
let scriptOutputPaths = scriptOutputFiles.map { URL(fileURLWithPath: $0).standardized.path }
if !scriptOutputPaths.contains(outputURL.standardized.path) && !scriptOutputPaths.contains(outputFileForError) {
let path = outputFileForError
.replacingOccurrences(of: podsTargetSrcroot ?? "", with: "$PODS_TARGET_SRCROOT")
.replacingOccurrences(of: sourceRootPath, with: "$SRCROOT")
errors.append("Build phase Output Files do not contain '\(path)'.")
}

Expand Down
1 change: 1 addition & 0 deletions Sources/rswift/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ let generate = command(
scriptOutputFiles: scriptOutputFiles,
lastRunURL: lastRunURL,
podsRoot: processInfo.environment["PODS_ROOT"],
podsTargetSrcroot: processInfo.environment["PODS_TARGET_SRCROOT"],
commandLineArguments: CommandLine.arguments)
guard errors.isEmpty else {
for error in errors {
Expand Down

0 comments on commit 48167ea

Please sign in to comment.