@@ -131,7 +131,7 @@ struct GeneratorCommand: CommandPlugin {
131131 if targets. count > 1 {
132132 let availableTargetNames = targets. map { $0. name } . joined ( separator: " , " )
133133 Diagnostics . error (
134- " Multiple targets found \n Please select specify one target by using the `--target name` option \n Available target names: \( availableTargetNames) "
134+ " Multiple targets found \n Please select specify one target by using the `--target < name> ` option \n Available target names: \( availableTargetNames) "
135135 )
136136 return
137137 } else if targets. isEmpty {
@@ -170,36 +170,37 @@ struct GeneratorCommand: CommandPlugin {
170170 Diagnostics . error (
171171 """
172172 \( targetNames. count) target names given: \( targetNames)
173- Please select exact 1 target
173+ Please select exactly 1 target
174174 """ )
175+ return
175176 }
176177
177178 let targetName = targetNames [ 0 ]
178179
179180 var inputFiles : PackagePlugin . FileList ?
180181 for target in context. xcodeProject. targets {
181182 if target. product? . name == targetName {
182- Diagnostics . remark ( " Found target \( targetName) " )
183+ Diagnostics . remark ( " Found target \( targetName) \n " )
183184 inputFiles = target. inputFiles
184185 }
185186 }
186187
187188 if inputFiles == nil {
188- Diagnostics . warning ( " Target \( targetName) has no files " )
189+ // File list can be empty, but should never be nil
190+ Diagnostics . error ( " Target \( targetName) has no files \n " )
189191 return
190192 }
191193
192- var sourcesArgs : [ String ] = [ ]
194+ var swiftSourceFiles : [ String ] = [ ]
193195 for inputFile in inputFiles! {
194196 if inputFile. path. string. hasSuffix ( " .swift " ) {
195- sourcesArgs. append ( " --sources " )
196- sourcesArgs. append ( inputFile. path. string)
197+ swiftSourceFiles. append ( inputFile. path. string)
197198 }
198199 }
199200
200- if sourcesArgs . isEmpty {
201- // TODO probably error
202- Diagnostics . warning ( " No Swift files found in Target \( targetName) " )
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 " )
203204 return
204205 }
205206
@@ -213,10 +214,10 @@ struct GeneratorCommand: CommandPlugin {
213214
214215 // TODO Add the generated files to the Xcode project
215216 Diagnostics . remark (
216- " ! Add the generated source file in ' \( codeFilePath) ' to the project and version control "
217+ " ! Add the generated source file in ' \( codeFilePath) ' to the project and version control \n "
217218 )
218219 Diagnostics . remark (
219- " ! Add the generated model file in ' \( modelFilePath) ' to version control, this is important for ObjectBox model generation "
220+ " ! Add the generated model file in ' \( modelFilePath) ' to version control, this is important for ObjectBox model generation \n "
220221 )
221222
222223 }
0 commit comments