Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
Added basic support for Carthage dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
owensd committed Jul 5, 2015
1 parent b8bd8b5 commit 1971f74
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build
Carthage/

# Apous
bin/
Expand Down
2 changes: 2 additions & 0 deletions apous.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.1.0;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -199,6 +200,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.1.0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down
1 change: 1 addition & 0 deletions samples/carthage/Cartfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "thoughtbot/Argo" "td-swift-2"
2 changes: 2 additions & 0 deletions samples/carthage/Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github "thoughtbot/Runes" "3a46bd92d78061c76c08a0b2baf6ee214dba77e9"
github "thoughtbot/Argo" "5b18ce0da13e3e6d8a3a5188cbf00bd8d5c86a0c"
4 changes: 4 additions & 0 deletions samples/carthage/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Argo
import Runes

print("dependencies import properly")
28 changes: 20 additions & 8 deletions src/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,21 @@ func filesAtPath(path: String) -> [String] {

return items
.filter() { $0 != ".apous.swift" }
.filter() { $0.pathExtension == "swift" }
.map() { path.stringByAppendingPathComponent($0) }
}

func runTask(task: String, _ args: String...) {

let t = NSTask()
t.launchPath = task
t.arguments = args
t.standardOutput = NSFileHandle.fileHandleWithStandardOutput()
t.standardError = NSFileHandle.fileHandleWithStandardError()
t.launch()
t.waitUntilExit()
}


let arguments = NSProcessInfo.processInfo().arguments
if arguments.count != 2 {
Expand All @@ -74,6 +86,13 @@ if arguments.count != 2 {

let p = try path(arguments[1])

NSFileManager.defaultManager().changeCurrentDirectoryPath(p)

if NSFileManager.defaultManager().fileExistsAtPath(p.stringByAppendingPathComponent("Cartfile")) {
runTask("/usr/local/bin/carthage", "update")
}


let files = filesAtPath(p)

var script = ""
Expand All @@ -85,11 +104,4 @@ for f in files {
let scriptPath = p.stringByAppendingPathComponent(".apous.swift")
try script.writeToFile(scriptPath, atomically: true, encoding: NSUTF8StringEncoding)


var swift = NSTask()
swift.launchPath = "/usr/bin/swift"
swift.arguments = [scriptPath]
swift.standardOutput = NSFileHandle.fileHandleWithStandardOutput()
swift.standardError = NSFileHandle.fileHandleWithStandardError()
swift.launch()
swift.waitUntilExit()
runTask("/usr/bin/swift", "-F", "Carthage/Build/Mac", scriptPath)

0 comments on commit 1971f74

Please sign in to comment.