• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

gitリポジトリのurlを貼り付けるだけでアプリケーションのビルドを実行するアプリ。 macOS用


Commit MetaInfo

Revisionda5427fe686b36ec704418986d142e22878f1f3c (tree)
Zeit2018-05-26 21:43:15
Autormasakih <masakih@user...>
Commitermasakih

Log Message

URL(fileURLWithPath:relativeTo:)を利用するようにした

Ändern Zusammenfassung

Diff

--- a/AppBuilderWithGit/BuildInfo.swift
+++ b/AppBuilderWithGit/BuildInfo.swift
@@ -48,8 +48,8 @@ struct BuildInfo {
4848 switch type {
4949
5050 case .xcworkspace:
51- self.buildURL = ApplicationDirecrories.support.appendingPathComponent(BuildInfo.buildDir)
52- self.productURL = buildURL.appendingPathComponent("Build/Products/Release")
51+ self.buildURL = URL(fileURLWithPath: BuildInfo.buildDir, relativeTo: ApplicationDirecrories.support)
52+ self.productURL = URL(fileURLWithPath: "Build/Products/Release", relativeTo: buildURL)
5353 self.arguments = [
5454 "-workspace",
5555 projectFileURL.lastPathComponent,
@@ -62,8 +62,8 @@ struct BuildInfo {
6262 ]
6363
6464 case .xcodeproj:
65- self.buildURL = projectURL.appendingPathComponent("build")
66- self.productURL = buildURL.appendingPathComponent("Release")
65+ self.buildURL = URL(fileURLWithPath: "build", relativeTo: projectURL)
66+ self.productURL = URL(fileURLWithPath: "Release", relativeTo: buildURL)
6767 self.arguments = ["-configuration", "Release"]
6868 }
6969 }
--- a/AppBuilderWithGit/Git.swift
+++ b/AppBuilderWithGit/Git.swift
@@ -26,7 +26,8 @@ final class Git {
2626
2727 var repository: URL {
2828
29- return ApplicationDirecrories.support.appendingPathComponent(repositoryName)
29+ return URL(fileURLWithPath: repositoryName,
30+ relativeTo: ApplicationDirecrories.support)
3031 }
3132
3233 init(_ url: URL) {
@@ -62,7 +63,6 @@ final class Git {
6263
6364 completeHandler?(GitError.other("Unknown Error: \(error)"))
6465 }
65-
6666 }
6767
6868 private func excuteGit(workingURL: URL, args: [String]) throws {
@@ -72,8 +72,10 @@ final class Git {
7272 throw GitError.other("Iligal arguments")
7373 }
7474
75- let xcodeURL = NSApplication.appDelegate.xcodeURL
76- guard let gitURL = xcodeURL?.appendingPathComponent("/Contents/Developer/usr/bin/git") else {
75+ let gitURL = URL(fileURLWithPath: "Contents/Developer/usr/bin/git",
76+ relativeTo: NSApplication.appDelegate.xcodeURL)
77+ guard let gitReachable = try? gitURL.checkResourceIsReachable(),
78+ gitReachable else {
7779
7880 throw GitError.other("git is not found.")
7981 }
@@ -128,20 +130,16 @@ final class Git {
128130
129131 private func submoduleUpdate(shouldInit: Bool = false) throws {
130132
131- let workingURL = ApplicationDirecrories.support.appendingPathComponent(repositoryName)
132-
133133 let args = shouldInit ? ["submodule", "update", "-i"] : ["submodule", "update"]
134134
135- try excuteGit(workingURL: workingURL, args: args)
135+ try excuteGit(workingURL: repository, args: args)
136136 }
137137
138138 private func pull() throws {
139139
140- let workingURL = ApplicationDirecrories.support.appendingPathComponent(repositoryName)
141-
142140 let args = ["pull"]
143141
144- try excuteGit(workingURL: workingURL, args: args)
142+ try excuteGit(workingURL: repository, args: args)
145143 }
146144
147145 private func tryPull(completeHandler: ((GitError) -> ())?) {
--- a/AppBuilderWithGit/LogStocker.swift
+++ b/AppBuilderWithGit/LogStocker.swift
@@ -10,7 +10,7 @@ import Foundation
1010
1111 private func fileURL(for name: String) -> URL? {
1212
13- let base = ApplicationDirecrories.support.appendingPathComponent("Logs")
13+ let base = URL(fileURLWithPath: "Logs", relativeTo: ApplicationDirecrories.support)
1414 guard checkDirectory(base) else {
1515
1616 return base.appendingPathComponent(name)
--- a/AppBuilderWithGit/ProjectBuilder.swift
+++ b/AppBuilderWithGit/ProjectBuilder.swift
@@ -39,10 +39,12 @@ final class ProjectBuilder {
3939
4040 func build() throws {
4141
42- let xcodeURL = NSApplication.appDelegate.xcodeURL
43- guard let builderURL = xcodeURL?.appendingPathComponent("/Contents/Developer/usr/bin/xcodebuild") else {
44-
45- throw ProjectBuilderError.commandNotFound
42+ let builderURL = URL(fileURLWithPath: "Contents/Developer/usr/bin/xcodebuild",
43+ relativeTo: NSApplication.appDelegate.xcodeURL)
44+ guard let xcodebuildReachable = try? builderURL.checkResourceIsReachable(),
45+ xcodebuildReachable else {
46+
47+ throw ProjectBuilderError.commandNotFound
4648 }
4749
4850 guard let reachable = try? info.projectURL.checkResourceIsReachable(),