Error is:
error build: Command CompileSwift failed with a nonzero exit code
Code:
I have changed Struct type to Class type.
class ViewModel: Identifiable {
enum Error: Swift.Error {
case missingIdentifier
case missingChildren
case missingKey
case missingValue
case missingMessage
case missingOperator
}
let id = UUID()
class Element: Identifiable {
let id: String
let pointer: String?
let type: String
init(){
}
}
}
When I add class keyword to ViewModel working fine.
At same time if I added class to Element I am getting error.
error build: Command CompileSwift failed with a nonzero exit code
The error message “Command CompileSwift failed with a nonzero exit code” isn’t the real error message. That message says there was an error in your code, but it doesn’t tell you the real errors.
Use Xcode’s issue navigator to see the real error messages. Press Cmd-5 to show the issue navigator. Update your question with the error messages from the issue navigator. That will help people solve your problem.
Are the enum and the Element class inside the ViewModel class? If so, why are they inside the ViewModel class?
One more suggestion. Place the whole code listing in a code block. Your current listing has only 5 lines of the code listing in a code block. Notice how the properties of the Element class are indented? If you place the whole listing in a code block, the code will be indented and easier for people to read.