├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ └── missing-error-domain-request.md ├── .gitignore ├── .swiftpm └── xcode │ ├── package.xcworkspace │ └── contents.xcworkspacedata │ └── xcshareddata │ └── xcschemes │ └── WhatTheErrorCode.xcscheme ├── Assets ├── app_example.jpg └── rocketsim_developer_utilities.jpg ├── LICENSE ├── Package.swift ├── README.md ├── Sources └── WhatTheErrorCode │ ├── WhatTheErrorCode.swift │ ├── WhatTheErrorCodeInputFactory.swift │ ├── WhatTheErrorCodeInputView.swift │ └── errors.json ├── Tests └── WhatTheErrorCodeTests │ └── WhatTheErrorCodeTests.swift └── WhatTheErrorCodeExample ├── WhatTheErrorCodeExample.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist └── WhatTheErrorCodeExample ├── Assets.xcassets ├── AccentColor.colorset │ └── Contents.json ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── Preview Content └── Preview Assets.xcassets │ └── Contents.json ├── WhatTheErrorCodeExample.entitlements └── WhatTheErrorCodeExampleApp.swift /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [AvdLee] 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/missing-error-domain-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Missing Error Domain request 3 | about: Suggest an Error Domain for this project 4 | title: "[ERROR REQUEST]" 5 | labels: enhancement 6 | assignees: AvdLee 7 | 8 | --- 9 | 10 | **I tried the following input that didn't result in an explanation** 11 | I expected this input to work: 12 | 13 | ```code 14 | 15 | ``` 16 | 17 | **Are you aware of what the output error description should be?** 18 | A link to Apple's documentation or just the description of the error you expected. 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | -------------------------------------------------------------------------------- /.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.swiftpm/xcode/xcshareddata/xcschemes/WhatTheErrorCode.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 54 | 55 | 61 | 62 | 68 | 69 | 70 | 71 | 73 | 74 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Assets/app_example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AvdLee/WhatTheErrorCode/6af5d0e2b7db2383c1e6204949a285ec2e884c34/Assets/app_example.jpg -------------------------------------------------------------------------------- /Assets/rocketsim_developer_utilities.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AvdLee/WhatTheErrorCode/6af5d0e2b7db2383c1e6204949a285ec2e884c34/Assets/rocketsim_developer_utilities.jpg -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Antoine van der Lee 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version: 5.7 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "WhatTheErrorCode", 8 | platforms: [ 9 | .macOS(.v12), 10 | .iOS(.v16) 11 | ], 12 | products: [ 13 | .library( 14 | name: "WhatTheErrorCode", 15 | targets: ["WhatTheErrorCode"]), 16 | ], 17 | targets: [ 18 | .target( 19 | name: "WhatTheErrorCode", 20 | dependencies: [], 21 | resources: [ 22 | .process("errors.json") 23 | ] 24 | ), 25 | .testTarget( 26 | name: "WhatTheErrorCodeTests", 27 | dependencies: ["WhatTheErrorCode"]), 28 | ] 29 | ) 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # What *is* The Error Code? 2 | Received an error like: 3 | 4 | ``` 5 | Domain=NSCocoaErrorDomain 6 | Code=1590 \"The operation couldn't be completed. (Cocoa error 1590.) 7 | ``` 8 | 9 | And you have no clue what the code means? Use this app to find a description: 10 | 11 | ![](Assets/app_example.jpg) 12 | 13 | ## Supported error domains 14 | - [x] `NSCocoaErrorDomain` 15 | - [x] `NSURLErrorDomain` 16 | - [ ] `kCFErrorDomainCFNetwork` 17 | 18 | ## Can I help contribute? 19 | Yes, please! Feel free to open a PR and add new error descriptions to [this JSON file](Sources/WhatTheErrorCode/errors.json). 20 | 21 | ### Using ChatGPT to generate JSON 22 | ChatGPT has been a great help in creating JSON output from header files like [this one](https://gist.github.com/krin-san/eb5cc692dcce9f2034bc8961cfc58694). I've used the following prompt: 23 | 24 | ``` 25 | Create a JSON array of the following input and use property names key, code, and description: 26 | " 27 | NSPersistentStoreTimeoutError = 134090, // failed to connect to the persistent store within the specified timeout (see NSPersistentStoreTimeoutOption) 28 | NSPersistentStoreUnsupportedRequestTypeError = 134091, // an NSPersistentStore subclass was passed an NSPersistentStoreRequest that it did not understand 29 | " 30 | ``` 31 | 32 | ## I want to use the app and keep it up to date with the latest errors 33 | Download [RocketSim](https://www.rocketsim.app) and use it from the Menu Bar. 34 | 35 | ![](Assets/rocketsim_developer_utilities.jpg) 36 | 37 | ## Author 38 | This library is created by [Antoine van der Lee](https://www.twitter.com/twannl) after [getting enough likes](https://twitter.com/twannl/status/1636429057934909442). 39 | 40 | ## License 41 | 42 | WhatTheErrorCode is available under the MIT license. See the LICENSE file for more info. -------------------------------------------------------------------------------- /Sources/WhatTheErrorCode/WhatTheErrorCode.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct CocoaErrorDescription: Codable, Equatable, Identifiable { 4 | public var id: String { key + "_\(code)" } 5 | public let code: Int 6 | public let key: String 7 | public let description: String 8 | } 9 | 10 | struct CocoaErrorDomain: Codable { 11 | let key: String 12 | let errors: [CocoaErrorDescription] 13 | } 14 | 15 | public struct WhatTheErrorCode { 16 | 17 | static var errorDomains: [CocoaErrorDomain] = { 18 | guard 19 | let jsonURL = Bundle.module.url(forResource: "errors", withExtension: "json"), 20 | let jsonData = try? Data(contentsOf: jsonURL), 21 | let errorDomains = try? JSONDecoder().decode([CocoaErrorDomain].self, from: jsonData) 22 | else { 23 | return [] 24 | } 25 | return errorDomains 26 | }() 27 | 28 | public static func description(for input: String) -> [CocoaErrorDescription] { 29 | guard let input = WhatTheErrorCodeInputFactory(rawValue: input).make() else { 30 | return [] 31 | } 32 | print("Input is \(input)") 33 | 34 | return errorDomains.errors(for: input) 35 | } 36 | } 37 | 38 | extension [CocoaErrorDomain] { 39 | func errors(for input: WhatTheErrorCodeInput) -> [CocoaErrorDescription] { 40 | if let domain = input.domain { 41 | return first(where: { $0.key.lowercased() == domain.lowercased() })? 42 | .errors 43 | .filter { $0.code == input.code } ?? [] 44 | } else { 45 | return flatMap(\.errors) 46 | .filter { $0.code == input.code } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Sources/WhatTheErrorCode/WhatTheErrorCodeInputFactory.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WhatTheErrorCodeInput.swift 3 | // 4 | // 5 | // Created by Antoine van der Lee on 16/03/2023. 6 | // 7 | 8 | import Foundation 9 | 10 | struct WhatTheErrorCodeInput { 11 | let code: Int 12 | let domain: String? 13 | } 14 | 15 | struct WhatTheErrorCodeInputFactory { 16 | let rawValue: String 17 | 18 | func make() -> WhatTheErrorCodeInput? { 19 | let rawValue = rawValue.lowercased() 20 | let pattern = #"(?:domain=([^\s]+)\s+)?code=(-?\d+)"# 21 | let regex = try! NSRegularExpression(pattern: pattern) 22 | 23 | guard let result = regex.firstMatch(in: rawValue, options: [], range: NSRange(location: 0, length: rawValue.count)) else { 24 | if let errorCode = Int(rawValue) { 25 | /// For code only inputs. 26 | return WhatTheErrorCodeInput(code: errorCode, domain: nil) 27 | } 28 | 29 | return nil 30 | } 31 | 32 | guard 33 | let errorCodeRange = Range(result.range(at: 2), in: rawValue), 34 | let errorCode = Int(rawValue[errorCodeRange]) 35 | else { 36 | return nil 37 | } 38 | 39 | var domain: String? 40 | 41 | if let domainRange = Range(result.range(at: 1), in: rawValue) { 42 | domain = String(rawValue[domainRange]) 43 | } 44 | 45 | return WhatTheErrorCodeInput(code: errorCode, domain: domain) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Sources/WhatTheErrorCode/WhatTheErrorCodeInputView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WhatTheErrorCodeInputView.swift 3 | // 4 | // 5 | // Created by Antoine van der Lee on 16/03/2023. 6 | // 7 | 8 | import SwiftUI 9 | 10 | public struct WhatTheErrorCodeInputView: View { 11 | @State var input: String = "" 12 | @State var result: [CocoaErrorDescription] = [] 13 | 14 | public init() { } 15 | 16 | public var body: some View { 17 | VStack { 18 | header 19 | results 20 | }.navigationTitle("What The Error Code?") 21 | } 22 | 23 | private var header: some View { 24 | VStack { 25 | Text("Fill in an error description to clarify the code.") 26 | .font(.headline) 27 | Text("Example input: Domain=NSCocoaErrorDomain Code=1590 \"The operation couldn't be completed. (Cocoa error 1590.)") 28 | .italic() 29 | .padding(.bottom) 30 | HStack { 31 | TextField("Enter code description", text: $input) { 32 | updateResult() 33 | } 34 | Button("Clarify") { 35 | updateResult() 36 | } 37 | } 38 | }.padding(.horizontal, 20) 39 | .padding() 40 | } 41 | 42 | private var results: some View { 43 | Table(result) { 44 | TableColumn("Code") { error in 45 | Text(String(error.code)) 46 | }.width(50) 47 | 48 | TableColumn("Key", value: \.key) 49 | .width(340) 50 | 51 | TableColumn("Description") { error in 52 | Text(error.description.localizedCapitalized) 53 | } 54 | } 55 | .textSelection(.enabled) 56 | } 57 | 58 | private func updateResult() { 59 | result = WhatTheErrorCode.description(for: input) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Sources/WhatTheErrorCode/errors.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "key": "NSURLErrorDomain", 3 | "errors": [{ 4 | "key": "NSURLErrorAppTransportSecurityRequiresSecureConnection", 5 | "description": "App Transport Security disallowed a connection because there is no secure network connection.", 6 | "code": -1022 7 | }, 8 | { 9 | "key": "NSURLErrorBackgroundSessionInUseByAnotherProcess", 10 | "description": "An app or app extension attempted to connect to a background session that is already connected to a process.", 11 | "code": -996 12 | }, 13 | { 14 | "key": "NSURLErrorBackgroundSessionRequiresSharedContainer", 15 | "description": "The shared container identifier of the URL session configuration is needed but hasn’t been set.", 16 | "code": -995 17 | }, 18 | { 19 | "key": "NSURLErrorBackgroundSessionWasDisconnected", 20 | "description": "The app is suspended or exits while a background data task is processing.", 21 | "code": -997 22 | }, 23 | { 24 | "key": "NSURLErrorBadServerResponse", 25 | "description": "The URL Loading System received bad data from the server.", 26 | "code": -1011 27 | }, 28 | { 29 | "key": "NSURLErrorBadURL", 30 | "description": "A malformed URL prevented a URL request from being initiated.", 31 | "code": -1000 32 | }, 33 | { 34 | "key": "NSURLErrorCallIsActive", 35 | "description": "A connection was attempted while a phone call was active on a network that doesn’t support simultaneous phone and data communication, such as EDGE or GPRS.", 36 | "code": -1019 37 | }, 38 | { 39 | "key": "NSURLErrorCancelled", 40 | "description": "An asynchronous load has been canceled.", 41 | "code": -999 42 | }, 43 | { 44 | "key": "NSURLErrorCannotCloseFile", 45 | "description": "A download task couldn’t close the downloaded file on disk.", 46 | "code": -3002 47 | }, 48 | { 49 | "key": "NSURLErrorCannotConnectToHost", 50 | "description": "An attempt to connect to a host failed.", 51 | "code": -1004 52 | }, 53 | { 54 | "key": "NSURLErrorCannotCreateFile", 55 | "description": "A download task couldn’t create the downloaded file on disk because of an I\/O failure.", 56 | "code": -3000 57 | }, 58 | { 59 | "key": "NSURLErrorCannotDecodeContentData", 60 | "description": "Content data received during a connection request had an unknown content encoding.", 61 | "code": -1016 62 | }, 63 | { 64 | "key": "NSURLErrorCannotDecodeRawData", 65 | "description": "Content data received during a connection request couldn’t be decoded for a known content encoding.", 66 | "code": -1015 67 | }, 68 | { 69 | "key": "NSURLErrorCannotFindHost", 70 | "description": "The host name for a URL couldn’t be resolved.", 71 | "code": -1003 72 | }, 73 | { 74 | "key": "NSURLErrorCannotLoadFromNetwork", 75 | "description": "A specific request to load an item only from the cache couldn't be satisfied.", 76 | "code": -2000 77 | }, 78 | { 79 | "key": "NSURLErrorCannotMoveFile", 80 | "description": "A downloaded file on disk couldn’t be moved.", 81 | "code": -3005 82 | }, 83 | { 84 | "key": "NSURLErrorCannotOpenFile", 85 | "description": "A downloaded file on disk couldn’t be opened.", 86 | "code": -3001 87 | }, 88 | { 89 | "key": "NSURLErrorCannotParseResponse", 90 | "description": "A response to a connection request couldn’t be parsed.", 91 | "code": -1017 92 | }, 93 | { 94 | "key": "NSURLErrorCannotRemoveFile", 95 | "description": "A downloaded file couldn’t be removed from disk.", 96 | "code": -3004 97 | }, 98 | { 99 | "key": "NSURLErrorCannotWriteToFile", 100 | "description": "A download task couldn’t write the file to disk.", 101 | "code": -3003 102 | }, 103 | { 104 | "key": "NSURLErrorClientCertificateRejected", 105 | "description": "A server certificate was rejected.", 106 | "code": -1205 107 | }, 108 | { 109 | "key": "NSURLErrorClientCertificateRequired", 110 | "description": "A client certificate was required to authenticate an SSL connection during a connection request.", 111 | "code": -1206 112 | }, 113 | { 114 | "key": "NSURLErrorDataLengthExceedsMaximum", 115 | "description": "The length of the resource data exceeded the maximum allowed.", 116 | "code": -1103 117 | }, 118 | { 119 | "key": "NSURLErrorDataNotAllowed", 120 | "description": "The cellular network disallowed a connection.", 121 | "code": -1020 122 | }, 123 | { 124 | "key": "NSURLErrorDNSLookupFailed", 125 | "description": "The host address couldn’t be found via DNS lookup.", 126 | "code": -1006 127 | }, 128 | { 129 | "key": "NSURLErrorDownloadDecodingFailedMidStream", 130 | "description": "A download task failed to decode an encoded file during the download.", 131 | "code": -3006 132 | }, 133 | { 134 | "key": "NSURLErrorDownloadDecodingFailedToComplete", 135 | "description": "A download task failed to decode an encoded file after downloading.", 136 | "code": -3007 137 | }, 138 | { 139 | "key": "NSURLErrorFileDoesNotExist", 140 | "description": "The specified file doesn’t exist.", 141 | "code": -1100 142 | }, 143 | { 144 | "key": "NSURLErrorFileIsDirectory", 145 | "description": "A request for an FTP file resulted in the server responding that the file is not a plain file, but a directory.", 146 | "code": -1101 147 | }, 148 | { 149 | "key": "NSURLErrorFileOutsideSafeArea", 150 | "description": "An internal file operation failed.", 151 | "code": -1104 152 | }, 153 | { 154 | "key": "NSURLErrorHTTPTooManyRedirects", 155 | "description": "A redirect loop was detected or the threshold for number of allowable redirects was exceeded (currently 16).", 156 | "code": -1007 157 | }, 158 | { 159 | "key": "NSURLErrorInternationalRoamingOff", 160 | "description": "The attempted connection required activating a data context while roaming, but international roaming is disabled.", 161 | "code": -1018 162 | }, 163 | { 164 | "key": "NSURLErrorNetworkConnectionLost", 165 | "description": "A client or server connection was severed in the middle of an in-progress load.", 166 | "code": -1005 167 | }, 168 | { 169 | "key": "NSURLErrorNoPermissionsToReadFile", 170 | "description": "A resource couldn’t be read because of insufficient permissions.", 171 | "code": -1102 172 | }, 173 | { 174 | "key": "NSURLErrorNotConnectedToInternet", 175 | "description": "A network resource was requested, but an internet connection has not been established and can’t be established automatically.", 176 | "code": -1009 177 | }, 178 | { 179 | "key": "NSURLErrorRedirectToNonExistentLocation", 180 | "description": "A redirect was specified by way of server response code, but the server didn’t accompany this code with a redirect URL.", 181 | "code": -1010 182 | }, 183 | { 184 | "key": "NSURLErrorRequestBodyStreamExhausted", 185 | "description": "A body stream was needed but the client did not provide one.", 186 | "code": -1021 187 | }, 188 | { 189 | "key": "NSURLErrorResourceUnavailable", 190 | "description": "A requested resource couldn’t be retrieved.", 191 | "code": -1008 192 | }, 193 | { 194 | "key": "NSURLErrorSecureConnectionFailed", 195 | "description": "An attempt to establish a secure connection failed for reasons that can’t be expressed more specifically.", 196 | "code": -1200 197 | }, 198 | { 199 | "key": "NSURLErrorServerCertificateHasBadDate", 200 | "description": "A server certificate is expired, or is not yet valid.", 201 | "code": -1201 202 | }, 203 | { 204 | "key": "NSURLErrorServerCertificateHasUnknownRoot", 205 | "description": "A server certificate wasn’t signed by any root server.", 206 | "code": -1203 207 | }, 208 | { 209 | "key": "NSURLErrorServerCertificateNotYetValid", 210 | "description": "A server certificate isn’t valid yet.", 211 | "code": -1204 212 | }, 213 | { 214 | "key": "NSURLErrorServerCertificateUntrusted", 215 | "description": "A server certificate was signed by a root server that isn’t trusted.", 216 | "code": -1202 217 | }, 218 | { 219 | "key": "NSURLErrorTimedOut", 220 | "description": "An asynchronous operation timed out.", 221 | "code": -1001 222 | }, 223 | { 224 | "key": "NSURLErrorUnknown", 225 | "description": "The URL Loading System encountered an error that it can’t interpret.", 226 | "code": -1 227 | }, 228 | { 229 | "key": "NSURLErrorUnsupportedURL", 230 | "description": "A properly formed URL couldn’t be handled by the framework.", 231 | "code": -1002 232 | }, 233 | { 234 | "key": "NSURLErrorUserAuthenticationRequired", 235 | "description": "Authentication was required to access a resource.", 236 | "code": -1013 237 | }, 238 | { 239 | "key": "NSURLErrorUserCancelledAuthentication", 240 | "description": "An asynchronous request for authentication has been canceled by the user.", 241 | "code": -1012 242 | }, 243 | { 244 | "key": "NSURLErrorZeroByteResource", 245 | "description": "A server reported that a URL has a non-zero content length, but terminated the network connection gracefully without sending any data.", 246 | "code": -1014 247 | } 248 | ] 249 | }, 250 | { 251 | "key": "NSCocoaErrorDomain", 252 | "errors": [{ 253 | "key": "NSManagedObjectValidationError", 254 | "code": 1550, 255 | "description": "generic validation error" 256 | }, { 257 | "key": "NSValidationMultipleErrorsError", 258 | "code": 1560, 259 | "description": "generic message for error containing multiple validation errors" 260 | }, { 261 | "key": "NSValidationMissingMandatoryPropertyError", 262 | "code": 1570, 263 | "description": "non-optional property with a nil value" 264 | }, { 265 | "key": "NSValidationRelationshipLacksMinimumCountError", 266 | "code": 1580, 267 | "description": "to-many relationship with too few destination objects" 268 | }, { 269 | "key": "NSValidationRelationshipExceedsMaximumCountError", 270 | "code": 1590, 271 | "description": "bounded, to-many relationship with too many destination objects" 272 | }, { 273 | "key": "NSValidationRelationshipDeniedDeleteError", 274 | "code": 1600, 275 | "description": "some relationship with NSDeleteRuleDeny is non-empty" 276 | }, { 277 | "key": "NSValidationNumberTooLargeError", 278 | "code": 1610, 279 | "description": "some numerical value is too large" 280 | }, { 281 | "key": "NSValidationNumberTooSmallError", 282 | "code": 1620, 283 | "description": "some numerical value is too small" 284 | }, { 285 | "key": "NSValidationDateTooLateError", 286 | "code": 1630, 287 | "description": "some date value is too late" 288 | }, { 289 | "key": "NSValidationDateTooSoonError", 290 | "code": 1640, 291 | "description": "some date value is too soon" 292 | }, 293 | { 294 | "key": "NSValidationInvalidDateError", 295 | "code": 1650, 296 | "description": "some date value fails to match date pattern" 297 | }, 298 | { 299 | "key": "NSValidationStringTooLongError", 300 | "code": 1660, 301 | "description": "some string value is too long" 302 | }, 303 | { 304 | "key": "NSValidationStringTooShortError", 305 | "code": 1670, 306 | "description": "some string value is too short" 307 | }, 308 | { 309 | "key": "NSValidationStringPatternMatchingError", 310 | "code": 1680, 311 | "description": "some string value fails to match some pattern" 312 | }, 313 | { 314 | "key": "NSManagedObjectContextLockingError", 315 | "code": 132000, 316 | "description": "can't acquire a lock in a managed object context" 317 | }, 318 | { 319 | "key": "NSPersistentStoreCoordinatorLockingError", 320 | "code": 132010, 321 | "description": "can't acquire a lock in a persistent store coordinator" 322 | }, 323 | { 324 | "key": "NSManagedObjectReferentialIntegrityError", 325 | "code": 133000, 326 | "description": "attempt to fire a fault pointing to an object that does not exist (we can see the store, we can't see the object)" 327 | }, 328 | { 329 | "key": "NSManagedObjectExternalRelationshipError", 330 | "code": 133010, 331 | "description": "an object being saved has a relationship containing an object from another store" 332 | }, 333 | { 334 | "key": "NSManagedObjectMergeError", 335 | "code": 133020, 336 | "description": "merge policy failed - unable to complete merging" 337 | }, 338 | { 339 | "key": "NSPersistentStoreInvalidTypeError", 340 | "code": 134000, 341 | "description": "unknown persistent store type/format/version" 342 | }, 343 | { 344 | "key": "NSPersistentStoreTypeMismatchError", 345 | "code": 134010, 346 | "description": "returned by persistent store coordinator if a store is accessed that does not match the specified type" 347 | }, 348 | { 349 | "key": "NSPersistentStoreIncompatibleSchemaError", 350 | "code": 134020, 351 | "description": "store returned an error for save operation (database level errors ie missing table, no permissions)" 352 | }, 353 | { 354 | "key": "NSPersistentStoreSaveError", 355 | "code": 134030, 356 | "description": "unclassified save error - something we depend on returned an error" 357 | }, 358 | { 359 | "key": "NSPersistentStoreIncompleteSaveError", 360 | "code": 134040, 361 | "description": "one or more of the stores returned an error during save (stores/objects that failed will be in userInfo)" 362 | }, 363 | { 364 | "key": "NSPersistentStoreSaveConflictsError", 365 | "code": 134050, 366 | "description": "an unresolved merge conflict was encountered during a save. userInfo has NSPersistentStoreSaveConflictsErrorKey" 367 | }, 368 | { 369 | "key": "NSCoreDataError", 370 | "code": 134060, 371 | "description": "general Core Data error" 372 | }, 373 | { 374 | "key": "NSPersistentStoreOperationError", 375 | "code": 134070, 376 | "description": "the persistent store operation failed" 377 | }, 378 | { 379 | "key": "NSPersistentStoreOpenError", 380 | "code": 134080, 381 | "description": "an error occurred while attempting to open the persistent store" 382 | }, 383 | { 384 | "key": "NSPersistentStoreTimeoutError", 385 | "code": 134090, 386 | "description": "failed to connect to the persistent store within the specified timeout (see NSPersistentStoreTimeoutOption)" 387 | }, { 388 | "key": "NSPersistentStoreUnsupportedRequestTypeError", 389 | "code": 134091, 390 | "description": "an NSPersistentStore subclass was passed an NSPersistentStoreRequest that it did not understand" 391 | }, { 392 | "key": "NSPersistentStoreIncompatibleVersionHashError", 393 | "code": 134100, 394 | "description": "entity version hashes incompatible with data model" 395 | }, { 396 | "key": "NSMigrationError", 397 | "code": 134110, 398 | "description": "general migration error" 399 | }, { 400 | "key": "NSMigrationCancelledError", 401 | "code": 134120, 402 | "description": "migration failed due to manual cancellation" 403 | }, { 404 | "key": "NSMigrationMissingSourceModelError", 405 | "code": 134130, 406 | "description": "migration failed due to missing source data model" 407 | }, { 408 | "key": "NSMigrationMissingMappingModelError", 409 | "code": 134140, 410 | "description": "migration failed due to missing mapping model" 411 | }, { 412 | "key": "NSMigrationManagerSourceStoreError", 413 | "code": 134150, 414 | "description": "migration failed due to a problem with the source data store" 415 | }, { 416 | "key": "NSMigrationManagerDestinationStoreError", 417 | "code": 134160, 418 | "description": "migration failed due to a problem with the destination data store" 419 | }, { 420 | "key": "NSEntityMigrationPolicyError", 421 | "code": 134170, 422 | "description": "migration failed during processing of the entity migration policy" 423 | }, { 424 | "key": "NSSQLiteError", 425 | "code": 134180, 426 | "description": "general SQLite error" 427 | }, { 428 | "key": "NSInferredMappingModelError", 429 | "code": 134190, 430 | "description": "inferred mapping model creation error" 431 | }, { 432 | "key": "NSExternalRecordImportError", 433 | "code": 134200, 434 | "description": "general error encountered while importing external records" 435 | }, { 436 | "key": "NSPersistentHistoryTokenExpiredError", 437 | "code": 134301, 438 | "description": "The history token passed to NSPersistentChangeRequest was invalid" 439 | } 440 | ] 441 | } 442 | ] 443 | -------------------------------------------------------------------------------- /Tests/WhatTheErrorCodeTests/WhatTheErrorCodeTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import WhatTheErrorCode 3 | 4 | final class WhatTheErrorCodeTests: XCTestCase { 5 | func testCodeWithKeyOnlyInput() throws { 6 | let expectedError = CocoaErrorDescription( 7 | code: 1590, 8 | key: "NSValidationRelationshipExceedsMaximumCountError", 9 | description: "bounded, to-many relationship with too many destination objects" 10 | ) 11 | XCTAssertEqual( 12 | WhatTheErrorCode.description(for: "code=1590"), 13 | [expectedError] 14 | ) 15 | } 16 | 17 | func testCodeOnlyInput() throws { 18 | let expectedError = CocoaErrorDescription( 19 | code: 1590, 20 | key: "NSValidationRelationshipExceedsMaximumCountError", 21 | description: "bounded, to-many relationship with too many destination objects" 22 | ) 23 | XCTAssertEqual( 24 | WhatTheErrorCode.description(for: "1590"), 25 | [expectedError] 26 | ) 27 | } 28 | 29 | func testCoreDataExample() throws { 30 | let expectedError = CocoaErrorDescription( 31 | code: 1590, 32 | key: "NSValidationRelationshipExceedsMaximumCountError", 33 | description: "bounded, to-many relationship with too many destination objects" 34 | ) 35 | XCTAssertEqual( 36 | WhatTheErrorCode.description(for: "Domain=NSCocoaErrorDomain Code=1590 \"The operation couldn't be completed. (Cocoa error 1590.)"), 37 | [expectedError] 38 | ) 39 | } 40 | 41 | func testLowercaseExample() throws { 42 | let expectedError = CocoaErrorDescription( 43 | code: 1590, 44 | key: "NSValidationRelationshipExceedsMaximumCountError", 45 | description: "bounded, to-many relationship with too many destination objects" 46 | ) 47 | XCTAssertEqual( 48 | WhatTheErrorCode.description(for: "domain=nscocoaerrordomain code=1590 \"The operation couldn't be completed. (Cocoa error 1590.)"), 49 | [expectedError] 50 | ) 51 | } 52 | 53 | func testNSURLErrorDomainExample() throws { 54 | let expectedError = CocoaErrorDescription( 55 | code: -1020, 56 | key: "NSURLErrorDataNotAllowed", 57 | description: "The cellular network disallowed a connection." 58 | ) 59 | XCTAssertEqual( 60 | WhatTheErrorCode.description(for: """ 61 | Error Domain=NSURLErrorDomain Code=-1020 "De momento, não é permitida a transmissão de dados." UserInfo={_kCFStreamErrorCodeKey=50 62 | """), 63 | [expectedError] 64 | ) 65 | } 66 | 67 | func testValidateJSON() throws { 68 | let errorDomains = WhatTheErrorCode.errorDomains 69 | XCTAssertFalse(errorDomains.isEmpty) 70 | 71 | let uniqueErrorDomains = Set(errorDomains.map(\.key)) 72 | XCTAssertEqual(uniqueErrorDomains.count, errorDomains.count, "There are duplicate domains") 73 | 74 | errorDomains.forEach { errorDomain in 75 | let uniqueErrorCodes = Set(errorDomain.errors.map(\.code)) 76 | XCTAssertEqual(uniqueErrorCodes.count, errorDomain.errors.count, "There are duplicate codes") 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /WhatTheErrorCodeExample/WhatTheErrorCodeExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 56; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 844E8A5329C383E3008C5AC8 /* WhatTheErrorCodeExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844E8A5229C383E3008C5AC8 /* WhatTheErrorCodeExampleApp.swift */; }; 11 | 844E8A5729C383E3008C5AC8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 844E8A5629C383E3008C5AC8 /* Assets.xcassets */; }; 12 | 844E8A5B29C383E3008C5AC8 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 844E8A5A29C383E3008C5AC8 /* Preview Assets.xcassets */; }; 13 | 8475826529C38DDA00682924 /* WhatTheErrorCode in Frameworks */ = {isa = PBXBuildFile; productRef = 8475826429C38DDA00682924 /* WhatTheErrorCode */; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXFileReference section */ 17 | 844E8A4F29C383E3008C5AC8 /* WhatTheErrorCodeExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WhatTheErrorCodeExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 18 | 844E8A5229C383E3008C5AC8 /* WhatTheErrorCodeExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhatTheErrorCodeExampleApp.swift; sourceTree = ""; }; 19 | 844E8A5629C383E3008C5AC8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 20 | 844E8A5829C383E3008C5AC8 /* WhatTheErrorCodeExample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WhatTheErrorCodeExample.entitlements; sourceTree = ""; }; 21 | 844E8A5A29C383E3008C5AC8 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 22 | 8475826229C38DCE00682924 /* WhatTheErrorCode */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = WhatTheErrorCode; path = ..; sourceTree = ""; }; 23 | /* End PBXFileReference section */ 24 | 25 | /* Begin PBXFrameworksBuildPhase section */ 26 | 844E8A4C29C383E3008C5AC8 /* Frameworks */ = { 27 | isa = PBXFrameworksBuildPhase; 28 | buildActionMask = 2147483647; 29 | files = ( 30 | 8475826529C38DDA00682924 /* WhatTheErrorCode in Frameworks */, 31 | ); 32 | runOnlyForDeploymentPostprocessing = 0; 33 | }; 34 | /* End PBXFrameworksBuildPhase section */ 35 | 36 | /* Begin PBXGroup section */ 37 | 844E8A4629C383E3008C5AC8 = { 38 | isa = PBXGroup; 39 | children = ( 40 | 8475826229C38DCE00682924 /* WhatTheErrorCode */, 41 | 844E8A5129C383E3008C5AC8 /* WhatTheErrorCodeExample */, 42 | 844E8A5029C383E3008C5AC8 /* Products */, 43 | 8475826329C38DDA00682924 /* Frameworks */, 44 | ); 45 | sourceTree = ""; 46 | }; 47 | 844E8A5029C383E3008C5AC8 /* Products */ = { 48 | isa = PBXGroup; 49 | children = ( 50 | 844E8A4F29C383E3008C5AC8 /* WhatTheErrorCodeExample.app */, 51 | ); 52 | name = Products; 53 | sourceTree = ""; 54 | }; 55 | 844E8A5129C383E3008C5AC8 /* WhatTheErrorCodeExample */ = { 56 | isa = PBXGroup; 57 | children = ( 58 | 844E8A5229C383E3008C5AC8 /* WhatTheErrorCodeExampleApp.swift */, 59 | 844E8A5629C383E3008C5AC8 /* Assets.xcassets */, 60 | 844E8A5829C383E3008C5AC8 /* WhatTheErrorCodeExample.entitlements */, 61 | 844E8A5929C383E3008C5AC8 /* Preview Content */, 62 | ); 63 | path = WhatTheErrorCodeExample; 64 | sourceTree = ""; 65 | }; 66 | 844E8A5929C383E3008C5AC8 /* Preview Content */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 844E8A5A29C383E3008C5AC8 /* Preview Assets.xcassets */, 70 | ); 71 | path = "Preview Content"; 72 | sourceTree = ""; 73 | }; 74 | 8475826329C38DDA00682924 /* Frameworks */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | ); 78 | name = Frameworks; 79 | sourceTree = ""; 80 | }; 81 | /* End PBXGroup section */ 82 | 83 | /* Begin PBXNativeTarget section */ 84 | 844E8A4E29C383E3008C5AC8 /* WhatTheErrorCodeExample */ = { 85 | isa = PBXNativeTarget; 86 | buildConfigurationList = 844E8A7429C383E4008C5AC8 /* Build configuration list for PBXNativeTarget "WhatTheErrorCodeExample" */; 87 | buildPhases = ( 88 | 844E8A4B29C383E3008C5AC8 /* Sources */, 89 | 844E8A4C29C383E3008C5AC8 /* Frameworks */, 90 | 844E8A4D29C383E3008C5AC8 /* Resources */, 91 | ); 92 | buildRules = ( 93 | ); 94 | dependencies = ( 95 | ); 96 | name = WhatTheErrorCodeExample; 97 | packageProductDependencies = ( 98 | 8475826429C38DDA00682924 /* WhatTheErrorCode */, 99 | ); 100 | productName = WhatTheErrorCodeExample; 101 | productReference = 844E8A4F29C383E3008C5AC8 /* WhatTheErrorCodeExample.app */; 102 | productType = "com.apple.product-type.application"; 103 | }; 104 | /* End PBXNativeTarget section */ 105 | 106 | /* Begin PBXProject section */ 107 | 844E8A4729C383E3008C5AC8 /* Project object */ = { 108 | isa = PBXProject; 109 | attributes = { 110 | BuildIndependentTargetsInParallel = 1; 111 | LastSwiftUpdateCheck = 1420; 112 | LastUpgradeCheck = 1420; 113 | TargetAttributes = { 114 | 844E8A4E29C383E3008C5AC8 = { 115 | CreatedOnToolsVersion = 14.2; 116 | }; 117 | }; 118 | }; 119 | buildConfigurationList = 844E8A4A29C383E3008C5AC8 /* Build configuration list for PBXProject "WhatTheErrorCodeExample" */; 120 | compatibilityVersion = "Xcode 14.0"; 121 | developmentRegion = en; 122 | hasScannedForEncodings = 0; 123 | knownRegions = ( 124 | en, 125 | Base, 126 | ); 127 | mainGroup = 844E8A4629C383E3008C5AC8; 128 | productRefGroup = 844E8A5029C383E3008C5AC8 /* Products */; 129 | projectDirPath = ""; 130 | projectRoot = ""; 131 | targets = ( 132 | 844E8A4E29C383E3008C5AC8 /* WhatTheErrorCodeExample */, 133 | ); 134 | }; 135 | /* End PBXProject section */ 136 | 137 | /* Begin PBXResourcesBuildPhase section */ 138 | 844E8A4D29C383E3008C5AC8 /* Resources */ = { 139 | isa = PBXResourcesBuildPhase; 140 | buildActionMask = 2147483647; 141 | files = ( 142 | 844E8A5B29C383E3008C5AC8 /* Preview Assets.xcassets in Resources */, 143 | 844E8A5729C383E3008C5AC8 /* Assets.xcassets in Resources */, 144 | ); 145 | runOnlyForDeploymentPostprocessing = 0; 146 | }; 147 | /* End PBXResourcesBuildPhase section */ 148 | 149 | /* Begin PBXSourcesBuildPhase section */ 150 | 844E8A4B29C383E3008C5AC8 /* Sources */ = { 151 | isa = PBXSourcesBuildPhase; 152 | buildActionMask = 2147483647; 153 | files = ( 154 | 844E8A5329C383E3008C5AC8 /* WhatTheErrorCodeExampleApp.swift in Sources */, 155 | ); 156 | runOnlyForDeploymentPostprocessing = 0; 157 | }; 158 | /* End PBXSourcesBuildPhase section */ 159 | 160 | /* Begin XCBuildConfiguration section */ 161 | 844E8A7229C383E4008C5AC8 /* Debug */ = { 162 | isa = XCBuildConfiguration; 163 | buildSettings = { 164 | ALWAYS_SEARCH_USER_PATHS = NO; 165 | CLANG_ANALYZER_NONNULL = YES; 166 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 167 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 168 | CLANG_ENABLE_MODULES = YES; 169 | CLANG_ENABLE_OBJC_ARC = YES; 170 | CLANG_ENABLE_OBJC_WEAK = YES; 171 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 172 | CLANG_WARN_BOOL_CONVERSION = YES; 173 | CLANG_WARN_COMMA = YES; 174 | CLANG_WARN_CONSTANT_CONVERSION = YES; 175 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 176 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 177 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 178 | CLANG_WARN_EMPTY_BODY = YES; 179 | CLANG_WARN_ENUM_CONVERSION = YES; 180 | CLANG_WARN_INFINITE_RECURSION = YES; 181 | CLANG_WARN_INT_CONVERSION = YES; 182 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 183 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 184 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 185 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 186 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 187 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 188 | CLANG_WARN_STRICT_PROTOTYPES = YES; 189 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 190 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 191 | CLANG_WARN_UNREACHABLE_CODE = YES; 192 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 193 | COPY_PHASE_STRIP = NO; 194 | DEBUG_INFORMATION_FORMAT = dwarf; 195 | ENABLE_STRICT_OBJC_MSGSEND = YES; 196 | ENABLE_TESTABILITY = YES; 197 | GCC_C_LANGUAGE_STANDARD = gnu11; 198 | GCC_DYNAMIC_NO_PIC = NO; 199 | GCC_NO_COMMON_BLOCKS = YES; 200 | GCC_OPTIMIZATION_LEVEL = 0; 201 | GCC_PREPROCESSOR_DEFINITIONS = ( 202 | "DEBUG=1", 203 | "$(inherited)", 204 | ); 205 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 206 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 207 | GCC_WARN_UNDECLARED_SELECTOR = YES; 208 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 209 | GCC_WARN_UNUSED_FUNCTION = YES; 210 | GCC_WARN_UNUSED_VARIABLE = YES; 211 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 212 | MTL_FAST_MATH = YES; 213 | ONLY_ACTIVE_ARCH = YES; 214 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 215 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 216 | }; 217 | name = Debug; 218 | }; 219 | 844E8A7329C383E4008C5AC8 /* Release */ = { 220 | isa = XCBuildConfiguration; 221 | buildSettings = { 222 | ALWAYS_SEARCH_USER_PATHS = NO; 223 | CLANG_ANALYZER_NONNULL = YES; 224 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 225 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 226 | CLANG_ENABLE_MODULES = YES; 227 | CLANG_ENABLE_OBJC_ARC = YES; 228 | CLANG_ENABLE_OBJC_WEAK = YES; 229 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 230 | CLANG_WARN_BOOL_CONVERSION = YES; 231 | CLANG_WARN_COMMA = YES; 232 | CLANG_WARN_CONSTANT_CONVERSION = YES; 233 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 234 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 235 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 236 | CLANG_WARN_EMPTY_BODY = YES; 237 | CLANG_WARN_ENUM_CONVERSION = YES; 238 | CLANG_WARN_INFINITE_RECURSION = YES; 239 | CLANG_WARN_INT_CONVERSION = YES; 240 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 241 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 242 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 243 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 244 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 245 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 246 | CLANG_WARN_STRICT_PROTOTYPES = YES; 247 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 248 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 249 | CLANG_WARN_UNREACHABLE_CODE = YES; 250 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 251 | COPY_PHASE_STRIP = NO; 252 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 253 | ENABLE_NS_ASSERTIONS = NO; 254 | ENABLE_STRICT_OBJC_MSGSEND = YES; 255 | GCC_C_LANGUAGE_STANDARD = gnu11; 256 | GCC_NO_COMMON_BLOCKS = YES; 257 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 258 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 259 | GCC_WARN_UNDECLARED_SELECTOR = YES; 260 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 261 | GCC_WARN_UNUSED_FUNCTION = YES; 262 | GCC_WARN_UNUSED_VARIABLE = YES; 263 | MTL_ENABLE_DEBUG_INFO = NO; 264 | MTL_FAST_MATH = YES; 265 | SWIFT_COMPILATION_MODE = wholemodule; 266 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 267 | }; 268 | name = Release; 269 | }; 270 | 844E8A7529C383E4008C5AC8 /* Debug */ = { 271 | isa = XCBuildConfiguration; 272 | buildSettings = { 273 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 274 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 275 | CODE_SIGN_ENTITLEMENTS = WhatTheErrorCodeExample/WhatTheErrorCodeExample.entitlements; 276 | CODE_SIGN_STYLE = Automatic; 277 | CURRENT_PROJECT_VERSION = 1; 278 | DEVELOPMENT_ASSET_PATHS = "\"WhatTheErrorCodeExample/Preview Content\""; 279 | DEVELOPMENT_TEAM = 4QMDKC8VLJ; 280 | ENABLE_HARDENED_RUNTIME = YES; 281 | ENABLE_PREVIEWS = YES; 282 | GENERATE_INFOPLIST_FILE = YES; 283 | "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; 284 | "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES; 285 | "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES; 286 | "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES; 287 | "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES; 288 | "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES; 289 | "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault; 290 | "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; 291 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 292 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 293 | IPHONEOS_DEPLOYMENT_TARGET = 16.2; 294 | LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; 295 | "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; 296 | MACOSX_DEPLOYMENT_TARGET = 13.1; 297 | MARKETING_VERSION = 1.0; 298 | PRODUCT_BUNDLE_IDENTIFIER = com.swiftlee.WhatTheErrorCodeExample; 299 | PRODUCT_NAME = "$(TARGET_NAME)"; 300 | SDKROOT = auto; 301 | SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; 302 | SWIFT_EMIT_LOC_STRINGS = YES; 303 | SWIFT_VERSION = 5.0; 304 | TARGETED_DEVICE_FAMILY = "1,2"; 305 | }; 306 | name = Debug; 307 | }; 308 | 844E8A7629C383E4008C5AC8 /* Release */ = { 309 | isa = XCBuildConfiguration; 310 | buildSettings = { 311 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 312 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 313 | CODE_SIGN_ENTITLEMENTS = WhatTheErrorCodeExample/WhatTheErrorCodeExample.entitlements; 314 | CODE_SIGN_STYLE = Automatic; 315 | CURRENT_PROJECT_VERSION = 1; 316 | DEVELOPMENT_ASSET_PATHS = "\"WhatTheErrorCodeExample/Preview Content\""; 317 | DEVELOPMENT_TEAM = 4QMDKC8VLJ; 318 | ENABLE_HARDENED_RUNTIME = YES; 319 | ENABLE_PREVIEWS = YES; 320 | GENERATE_INFOPLIST_FILE = YES; 321 | "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; 322 | "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES; 323 | "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES; 324 | "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES; 325 | "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES; 326 | "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES; 327 | "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault; 328 | "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; 329 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 330 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 331 | IPHONEOS_DEPLOYMENT_TARGET = 16.2; 332 | LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; 333 | "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; 334 | MACOSX_DEPLOYMENT_TARGET = 13.1; 335 | MARKETING_VERSION = 1.0; 336 | PRODUCT_BUNDLE_IDENTIFIER = com.swiftlee.WhatTheErrorCodeExample; 337 | PRODUCT_NAME = "$(TARGET_NAME)"; 338 | SDKROOT = auto; 339 | SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; 340 | SWIFT_EMIT_LOC_STRINGS = YES; 341 | SWIFT_VERSION = 5.0; 342 | TARGETED_DEVICE_FAMILY = "1,2"; 343 | }; 344 | name = Release; 345 | }; 346 | /* End XCBuildConfiguration section */ 347 | 348 | /* Begin XCConfigurationList section */ 349 | 844E8A4A29C383E3008C5AC8 /* Build configuration list for PBXProject "WhatTheErrorCodeExample" */ = { 350 | isa = XCConfigurationList; 351 | buildConfigurations = ( 352 | 844E8A7229C383E4008C5AC8 /* Debug */, 353 | 844E8A7329C383E4008C5AC8 /* Release */, 354 | ); 355 | defaultConfigurationIsVisible = 0; 356 | defaultConfigurationName = Release; 357 | }; 358 | 844E8A7429C383E4008C5AC8 /* Build configuration list for PBXNativeTarget "WhatTheErrorCodeExample" */ = { 359 | isa = XCConfigurationList; 360 | buildConfigurations = ( 361 | 844E8A7529C383E4008C5AC8 /* Debug */, 362 | 844E8A7629C383E4008C5AC8 /* Release */, 363 | ); 364 | defaultConfigurationIsVisible = 0; 365 | defaultConfigurationName = Release; 366 | }; 367 | /* End XCConfigurationList section */ 368 | 369 | /* Begin XCSwiftPackageProductDependency section */ 370 | 8475826429C38DDA00682924 /* WhatTheErrorCode */ = { 371 | isa = XCSwiftPackageProductDependency; 372 | productName = WhatTheErrorCode; 373 | }; 374 | /* End XCSwiftPackageProductDependency section */ 375 | }; 376 | rootObject = 844E8A4729C383E3008C5AC8 /* Project object */; 377 | } 378 | -------------------------------------------------------------------------------- /WhatTheErrorCodeExample/WhatTheErrorCodeExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WhatTheErrorCodeExample/WhatTheErrorCodeExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /WhatTheErrorCodeExample/WhatTheErrorCodeExample/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WhatTheErrorCodeExample/WhatTheErrorCodeExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "platform" : "ios", 6 | "size" : "1024x1024" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "scale" : "1x", 11 | "size" : "16x16" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "scale" : "2x", 16 | "size" : "16x16" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "scale" : "1x", 21 | "size" : "32x32" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "scale" : "2x", 26 | "size" : "32x32" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "scale" : "1x", 31 | "size" : "128x128" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "scale" : "2x", 36 | "size" : "128x128" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "scale" : "1x", 41 | "size" : "256x256" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "scale" : "2x", 46 | "size" : "256x256" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "scale" : "1x", 51 | "size" : "512x512" 52 | }, 53 | { 54 | "idiom" : "mac", 55 | "scale" : "2x", 56 | "size" : "512x512" 57 | } 58 | ], 59 | "info" : { 60 | "author" : "xcode", 61 | "version" : 1 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /WhatTheErrorCodeExample/WhatTheErrorCodeExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /WhatTheErrorCodeExample/WhatTheErrorCodeExample/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /WhatTheErrorCodeExample/WhatTheErrorCodeExample/WhatTheErrorCodeExample.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /WhatTheErrorCodeExample/WhatTheErrorCodeExample/WhatTheErrorCodeExampleApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WhatTheErrorCodeExampleApp.swift 3 | // WhatTheErrorCodeExample 4 | // 5 | // Created by Antoine van der Lee on 16/03/2023. 6 | // 7 | 8 | import SwiftUI 9 | import WhatTheErrorCode 10 | 11 | @main 12 | struct WhatTheErrorCodeExampleApp: App { 13 | var body: some Scene { 14 | WindowGroup { 15 | WhatTheErrorCodeInputView() 16 | } 17 | } 18 | } 19 | --------------------------------------------------------------------------------