Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messages #22

Merged
merged 7 commits into from
Oct 4, 2018
Merged

Conversation

4brunu
Copy link
Contributor

@4brunu 4brunu commented Oct 4, 2018

Hello, this PR fixes #20.

It show's more explicit errors and add a verbose flag that prints all shell commands and the respective responses.

Here is an example of how the error are showed now:

/usr/bin/xcodebuild clean build -dry-run -project XcodeProject.xcodeproj -target XcodeProjectTarget -UseModernBuildSystem=0 -sdk iphonesimulator -destination platform=iOS Simulator,name=iPhone X,OS=latest
Terminated with the status 65.
User defaults from command line:
    UseModernBuildSystem = 0

Build settings from command line:
    SDKROOT = iphonesimulator12.0

Prepare build
note: Using legacy build system

=== CLEAN TARGET XcodeProjectTarget OF PROJECT XcodeProjectTarget WITH THE DEFAULT CONFIGURATION (Debug) ===

Check dependencies
[BEROR]No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=i386, VALID_ARCHS=arm64 armv7s).

Create product structure
/bin/mkdir -p /Users/User/Developer/XcodeProject/build/Debug-iphonesimulator/XcodeProjectTarget.app

Clean.Remove clean build/XcodeProjectTarget.build/Debug-iphonesimulator/XcodeProjectTarget.build
    builtin-rm -rf /Users/User/Developer/XcodeProject/build/XcodeProjectTarget.build/Debug-iphonesimulator/XcodeProjectTarget.build

Clean.Remove clean build/Debug-iphonesimulator/XcodeProjectTarget.app
    builtin-rm -rf /Users/User/Developer/XcodeProject/build/Debug-iphonesimulator/XcodeProjectTarget.app

** CLEAN SUCCEEDED **

Prepare build
note: Using legacy build system

=== BUILD TARGET XcodeProjectTarget OF PROJECT XcodeProjectTarget WITH THE DEFAULT CONFIGURATION (Debug) ===

Check dependencies
No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=i386, VALID_ARCHS=arm64 armv7s).


** BUILD FAILED **


The following build commands failed:
	Check dependencies
(1 failure)

var buffer = Data()
while ps.isRunning {
buffer.append(pipe.fileHandleForReading.readDataToEndOfFile())
ps.waitUntilExit()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid waitUntilExit cannot be used here since it depends on a runloop being installed on the current thread

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

let errorPipeResult = errorPipe.fileHandleForReading.readDataToEndOfFile()

guard let output = String(data: outputPipeResult, encoding: String.Encoding.utf8),
let error = String(data: errorPipeResult, encoding: String.Encoding.utf8) else {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coud you please reformat this like:

guard
    xxx,
    yyy
else {
    zzz
}

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The Xcode auto-formatting put it like this:

guard
    xxx,
    yyy
    else {
        zzz
}

It is ok? Or should I change it?

Bridgecraft/Utils.swift Outdated Show resolved Hide resolved
@lvsti
Copy link
Owner

lvsti commented Oct 4, 2018

👍

@lvsti lvsti merged commit 31fa23b into lvsti:master Oct 4, 2018
@4brunu 4brunu deleted the feature/improve_error_messages branch November 6, 2018 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add verbose option and more informative errors
2 participants