Skip to content

Commit f37e420

Browse files
ObjectBoxCommand: only warn on Xcode input file fail objectbox-swift#310
1 parent e12b0cd commit f37e420

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

Plugins/GeneratorCommand/ObjectBoxCommand.swift

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,23 +185,25 @@ struct GeneratorCommand: CommandPlugin {
185185
}
186186
}
187187

188+
// This is some additional validation that the Xcode target has Swift source files.
189+
// However, this appears to not work for all Xcode targets, so just print warnings
190+
// and continue anyhow as the generator might still find source files (it looks based on the directory).
188191
if inputFiles == nil {
189192
// File list can be empty, but should never be nil
190-
Diagnostics.error("Target \(targetName) has no files\n")
191-
return
192-
}
193-
194-
var swiftSourceFiles: [String] = []
195-
for inputFile in inputFiles! {
196-
if inputFile.path.string.hasSuffix(".swift") {
197-
swiftSourceFiles.append(inputFile.path.string)
193+
Diagnostics.warning("Target \(targetName) has no files, generator might fail\n")
194+
} else {
195+
var swiftSourceFiles: [String] = []
196+
for inputFile in inputFiles! {
197+
if inputFile.path.string.hasSuffix(".swift") {
198+
swiftSourceFiles.append(inputFile.path.string)
199+
}
198200
}
199-
}
200201

201-
if swiftSourceFiles.isEmpty {
202-
// Only warn in case this is run on a target that has no Swift files
203-
Diagnostics.warning("No Swift files found in Target \(targetName)\n")
204-
return
202+
if swiftSourceFiles.isEmpty {
203+
// Just warn instead of error in case this is run on a target that has no Swift files
204+
Diagnostics.warning(
205+
"No Swift files found in Target \(targetName), model might be empty\n")
206+
}
205207
}
206208

207209
let targetPath = context.xcodeProject.directory

0 commit comments

Comments
 (0)