Skip to content

Commit 01fdb75

Browse files
Merge branch 'release-4.1.0-beta.2' into 'main'
Release 4.1.0-beta.2 objectbox-swift#298 See merge request objectbox/objectbox-swift-spm!2
2 parents 7e3348a + bc6e5f1 commit 01fdb75

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

Package.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ let package = Package(
2121
.binaryTarget(
2222
name: "ObjectBoxGenerator",
2323
url:
24-
"https://github.com/objectbox/objectbox-swift-spec-staging/releases/download/v4.0.2-rc1/ObjectBoxGenerator.artifactbundle.zip",
25-
checksum: "a2942a8bedb5790956e4961be773270cfcf02b6a277f3eae00477bd056cb0187"
24+
"https://github.com/objectbox/objectbox-swift-spec-staging/releases/download/v4.0.2-rc2/ObjectBoxGenerator.artifactbundle.zip",
25+
checksum: "003d51095ded2e025fbed2b8eebe516f8a65b73cd2120a9cd56e04988cc19a22"
2626
),
2727
.binaryTarget(
2828
name: "ObjectBox.xcframework",
2929
url:
30-
"https://github.com/objectbox/objectbox-swift-spec-staging/releases/download/v4.0.2-rc1/ObjectBox.xcframework.zip",
31-
checksum: "b369a4b4fc57c8f7c7620f275ed1b0f62970cf612e68f47382d44ce311d52c11"
30+
"https://github.com/objectbox/objectbox-swift-spec-staging/releases/download/v4.0.2-rc2/ObjectBox.xcframework.zip",
31+
checksum: "faf3be62eefe3081d5bc507f22bc13a9b826d42849ac1971545fbecbb5d0286d"
3232
),
3333

3434
/// MARK: - Plugin implementations

Plugins/GeneratorCommand/ObjectBoxCommand.swift

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ struct GeneratorCommand: CommandPlugin {
109109

110110
// keep for now as a reminder to check if args are processed, or not
111111
let tool = try context.tool(named: "objectbox-generator")
112-
print("Processing arguments:: \(arguments)")
112+
print("Processing arguments: \(arguments)")
113113
if arguments.count == 1 {
114114
if arguments[0] == "context" {
115115
dump(context)
@@ -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\nPlease select specify one target by using the `--target name` option\nAvailable target names: \(availableTargetNames)"
134+
"Multiple targets found\nPlease select specify one target by using the `--target <name>` option\nAvailable target names: \(availableTargetNames)"
135135
)
136136
return
137137
} else if targets.isEmpty {
@@ -170,37 +170,40 @@ 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

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).
187191
if inputFiles == nil {
188-
Diagnostics.warning("Target \(targetName) has no files")
189-
return
190-
}
191-
192-
var sourcesArgs: [String] = []
193-
for inputFile in inputFiles! {
194-
if inputFile.path.string.hasSuffix(".swift") {
195-
sourcesArgs.append("--sources")
196-
sourcesArgs.append(inputFile.path.string)
192+
// File list can be empty, but should never be nil
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+
}
197200
}
198-
}
199201

200-
if sourcesArgs.isEmpty {
201-
// TODO probably error
202-
Diagnostics.warning("No Swift files found in Target \(targetName) ")
203-
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+
}
204207
}
205208

206209
let targetPath = context.xcodeProject.directory
@@ -213,10 +216,10 @@ struct GeneratorCommand: CommandPlugin {
213216

214217
// TODO Add the generated files to the Xcode project
215218
Diagnostics.remark(
216-
"! Add the generated source file in '\(codeFilePath)' to the project and version control"
219+
"! Add the generated source file in '\(codeFilePath)' to the project and version control\n"
217220
)
218221
Diagnostics.remark(
219-
"! Add the generated model file in '\(modelFilePath)' to version control, this is important for ObjectBox model generation"
222+
"! Add the generated model file in '\(modelFilePath)' to version control, this is important for ObjectBox model generation\n"
220223
)
221224

222225
}

0 commit comments

Comments
 (0)