Skip to content

Commit

Permalink
Merge pull request #66 from jpsim/jp-xcodebuild-log-file
Browse files Browse the repository at this point in the history
Improve error reporting when compiler arguments can't be parsed.
  • Loading branch information
jpsim committed Sep 21, 2015
2 parents 4106ae3 + 14959a7 commit f49fd6b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## Master

##### Breaking

None.

##### Enhancements

* Improve error reporting when compiler arguments can't be parsed and log
`xcodebuild` output to file instead of stderr.
[JP Simard](https://github.com/jpsim)

##### Bug Fixes

None.


## 0.5.0

##### Breaking
Expand Down
7 changes: 6 additions & 1 deletion Source/SourceKittenFramework/Module.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright (c) 2015 SourceKitten. All rights reserved.
//

import Foundation

/// Represents source module to be documented.
public struct Module {
/// Module Name.
Expand Down Expand Up @@ -42,7 +44,10 @@ public struct Module {
let xcodeBuildOutput = runXcodeBuild(xcodeBuildArguments, inPath: path) ?? ""
guard let arguments = parseCompilerArguments(xcodeBuildOutput, language: .Swift, moduleName: name ?? moduleNameFromArguments(xcodeBuildArguments)) else {
fputs("Could not parse compiler arguments from `xcodebuild` output.\n", stderr)
fputs("\(xcodeBuildOutput)\n", stderr)
fputs("Please confirm that `xcodebuild` is building a Swift module.\n", stderr)
let file = NSURL(fileURLWithPath: NSTemporaryDirectory()).URLByAppendingPathComponent("xcodebuild-\(NSUUID().UUIDString).log")
xcodeBuildOutput.dataUsingEncoding(NSUTF8StringEncoding)?.writeToURL(file, atomically: true)
fputs("Saved `xcodebuild` log file: \(file.path!)\n", stderr)
return nil
}
guard let moduleName = moduleNameFromArguments(arguments) else {
Expand Down

0 comments on commit f49fd6b

Please sign in to comment.