• 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

Revisión9ad183fc348f873d3191ae9026411690273484c1 (tree)
Tiempo2018-04-08 14:59:27
Autormasakih <masakih@user...>
Commitermasakih

Log Message

必要ならCocoaPodsを実行するようにした

Cambiar Resumen

Diferencia incremental

--- a/AppBuilderWithGit.xcodeproj/project.pbxproj
+++ b/AppBuilderWithGit.xcodeproj/project.pbxproj
@@ -18,6 +18,7 @@
1818 F41A45141F3E9DFA0066F83D /* BuildInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = F41A45131F3E9DFA0066F83D /* BuildInfo.swift */; };
1919 F41A45161F3EC0950066F83D /* WindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F41A45151F3EC0950066F83D /* WindowController.swift */; };
2020 F41A45181F401D4B0066F83D /* LogStocker.swift in Sources */ = {isa = PBXBuildFile; fileRef = F41A45171F401D4B0066F83D /* LogStocker.swift */; };
21+ F45853192079DDBE007B251A /* CocoaPods.swift in Sources */ = {isa = PBXBuildFile; fileRef = F45853182079DDBE007B251A /* CocoaPods.swift */; };
2122 F4DDB3B42077BB41004781AE /* CommandFinder.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DDB3B32077BB41004781AE /* CommandFinder.swift */; };
2223 F4DDB3B62077BBB2004781AE /* Process-extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DDB3B52077BBB2004781AE /* Process-extensions.swift */; };
2324 F4DDB3BE2077BD2B004781AE /* AppBuilderWithGitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DDB3BD2077BD2B004781AE /* AppBuilderWithGitTests.swift */; };
@@ -49,6 +50,7 @@
4950 F41A45131F3E9DFA0066F83D /* BuildInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BuildInfo.swift; sourceTree = "<group>"; };
5051 F41A45151F3EC0950066F83D /* WindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowController.swift; sourceTree = "<group>"; };
5152 F41A45171F401D4B0066F83D /* LogStocker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogStocker.swift; sourceTree = "<group>"; };
53+ F45853182079DDBE007B251A /* CocoaPods.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CocoaPods.swift; sourceTree = "<group>"; };
5254 F4DDB3B32077BB41004781AE /* CommandFinder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandFinder.swift; sourceTree = "<group>"; };
5355 F4DDB3B52077BBB2004781AE /* Process-extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Process-extensions.swift"; sourceTree = "<group>"; };
5456 F4DDB3BB2077BD2B004781AE /* AppBuilderWithGitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AppBuilderWithGitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -110,6 +112,7 @@
110112 F41A45051F3D83AE0066F83D /* ProjectFinder.swift */,
111113 F4DDB3C92079A3DB004781AE /* String-extensions.swift */,
112114 F4DDB3C72079A209004781AE /* Carthage.swift */,
115+ F45853182079DDBE007B251A /* CocoaPods.swift */,
113116 F41A44F21F3D6B1B0066F83D /* Assets.xcassets */,
114117 F41A44F41F3D6B1B0066F83D /* Main.storyboard */,
115118 F41A44F71F3D6B1B0066F83D /* Info.plist */,
@@ -235,6 +238,7 @@
235238 F4DDB3B62077BBB2004781AE /* Process-extensions.swift in Sources */,
236239 F41A45041F3D782A0066F83D /* Git.swift in Sources */,
237240 F4DDB3CA2079A3DB004781AE /* String-extensions.swift in Sources */,
241+ F45853192079DDBE007B251A /* CocoaPods.swift in Sources */,
238242 F41A44F11F3D6B1B0066F83D /* ViewController.swift in Sources */,
239243 F41A45141F3E9DFA0066F83D /* BuildInfo.swift in Sources */,
240244 F4DDB3C82079A209004781AE /* Carthage.swift in Sources */,
--- /dev/null
+++ b/AppBuilderWithGit/CocoaPods.swift
@@ -0,0 +1,81 @@
1+//
2+// CocoaPods.swift
3+// AppBuilderWithGit
4+//
5+// Created by Hori,Masaki on 2018/04/08.
6+// Copyright © 2018年 Hori,Masaki. All rights reserved.
7+//
8+
9+import Foundation
10+
11+enum CocoaPodsError: Error {
12+
13+ case commandNotFound
14+
15+ case commandFail
16+}
17+
18+final class CocoaPods {
19+
20+ let baseURL: URL
21+
22+ init(_ url: URL) {
23+
24+ self.baseURL = url
25+ }
26+
27+ private var podfileURL: URL? {
28+
29+ return findFile(pattern: "^Podfile$", in: baseURL, depth: 2)
30+ }
31+
32+ private var podURL: URL? {
33+
34+ return commandPath("pod")
35+ }
36+
37+ func checkCocoaPods() -> Bool {
38+
39+ guard podfileURL != nil else {
40+
41+ return false
42+ }
43+
44+ guard podURL != nil else {
45+
46+ return false
47+ }
48+
49+ return true
50+ }
51+
52+ func execute() throws {
53+
54+ guard let podfile = podfileURL else {
55+
56+ return
57+ }
58+
59+ guard let podURL = podURL else {
60+
61+ throw CarthageError.commandNotFound
62+ }
63+
64+ let pod = Process() <<< podURL.path <<< ["install"]
65+ pod.currentDirectoryPath = podfile.deletingLastPathComponent().path
66+
67+ pod >>> { output, error in
68+
69+ let log = LogStocker("cocoapods.log")
70+ log?.write(output.data)
71+ log?.write(error.data)
72+ }
73+ pod.waitUntilExit()
74+
75+ if pod.terminationStatus != 0 {
76+
77+ throw CarthageError.commandFail
78+ }
79+ }
80+}
81+
--- a/AppBuilderWithGit/ViewController.swift
+++ b/AppBuilderWithGit/ViewController.swift
@@ -117,6 +117,11 @@ extension ViewController {
117117 return
118118 }
119119
120+ guard self.cocoaPods(gitCloner.repository) else {
121+
122+ return
123+ }
124+
120125 self.build(gitCloner.repository)
121126
122127 case let .gitError(stat, mess):
@@ -157,6 +162,33 @@ extension ViewController {
157162 }
158163 }
159164
165+ private func cocoaPods(_ url: URL) -> Bool {
166+
167+ message = "Checking CocoaPods."
168+
169+ do {
170+
171+ let pod = CocoaPods(url)
172+
173+ guard pod.checkCocoaPods() else {
174+
175+ return true
176+ }
177+
178+ message = "Building frameworks with CocoaPods."
179+
180+ try pod.execute()
181+
182+ return true
183+
184+ } catch {
185+
186+ message = "Fail to CocoaPods."
187+
188+ return false
189+ }
190+ }
191+
160192 private func build(_ url: URL) {
161193
162194 message = "Building Project."