ollieatkinson / Guise

A tool to generate the Swift public interface for Frameworks and Libraries
MIT License
53 stars 5 forks source link

Improve missing argument error reporting #11

Closed paulsamuels closed 6 years ago

paulsamuels commented 6 years ago

Using Decodable is nice but the errors it will raise for missing keys are not as nice as the ones this project originally reported.

e.g. compare

keyNotFound(CodingKeys(stringValue: "CONFIGURATION_BUILD_DIR", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"CONFIGURATION_BUILD_DIR\", intValue: nil) (\"CONFIGURATION_BUILD_DIR\").", underlyingError: nil))
Fatal error: file /Users/paul/src/swift/Guise/Sources/GuiseFramework/BuildArguments.swift, line 46

with

CONFIGURATION_BUILD_DIR is required to be set

The first commit in this PR maps missing keys to the frameworks own error type APIGeneratorError.buildArgumentRequired(name:) that has nicer reporting to the user.


In the change we also lost the helpful message when deploymentTarget could not be resolved e.g.

IPHONEOS_DEPLOYMENT_TARGET or MACOSX_DEPLOYMENT_TARGET is required to be set

The second commit - actively queries if IPHONEOS_DEPLOYMENT_TARGET or MACOSX_DEPLOYMENT_TARGET have been set and throws APIGeneratorError.buildArgumentRequired(name:) if not.