Skip to content

Commit 2ce1312

Browse files
ObjectBox Swift database 4.0.0
1 parent a502b40 commit 2ce1312

File tree

92 files changed

+2920
-407
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2920
-407
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
url = https://github.com/realm/SwiftLint.git
44
[submodule "Source/external/objectbox-swift-generator"]
55
path = Source/external/objectbox-swift-generator
6-
url=https://github.com/objectbox/objectbox-swift-generator.git
6+
url = https://github.com/objectbox/objectbox-swift-generator.git

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ let package = Package(
1616
targets: [
1717
.binaryTarget(
1818
name: "ObjectBox",
19-
url: "https://github.com/objectbox/objectbox-swift/releases/download/v2.0.0/ObjectBox-xcframework-2.0.0.zip",
20-
checksum: "20766ccf880bd66c4246f55536fbd3f33f1e8bb7adf55101a3dd06a8ee043116"
19+
url: "https://github.com/objectbox/objectbox-swift/releases/download/v4.0.0/ObjectBox-xcframework-4.0.0.zip",
20+
checksum: "2bed7b8b87dd46dda64fa1f5e7a0b1df87908a783690fda09c6dc943a01a32e5"
2121
)
2222
]
2323
)

Source/Gemfile.lock

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
CFPropertyList (3.0.6)
4+
CFPropertyList (3.0.7)
5+
base64
6+
nkf
57
rexml
6-
activesupport (7.1.2)
8+
activesupport (7.1.3.4)
79
base64
810
bigdecimal
911
concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -13,21 +15,21 @@ GEM
1315
minitest (>= 5.1)
1416
mutex_m
1517
tzinfo (~> 2.0)
16-
addressable (2.8.5)
17-
public_suffix (>= 2.0.2, < 6.0)
18+
addressable (2.8.7)
19+
public_suffix (>= 2.0.2, < 7.0)
1820
algoliasearch (1.27.5)
1921
httpclient (~> 2.8, >= 2.8.3)
2022
json (>= 1.5.1)
2123
atomos (0.1.3)
2224
base64 (0.2.0)
23-
bigdecimal (3.1.4)
25+
bigdecimal (3.1.8)
2426
claide (1.1.0)
25-
cocoapods (1.14.2)
27+
cocoapods (1.15.2)
2628
addressable (~> 2.8)
2729
claide (>= 1.0.2, < 2.0)
28-
cocoapods-core (= 1.14.2)
30+
cocoapods-core (= 1.15.2)
2931
cocoapods-deintegrate (>= 1.0.3, < 2.0)
30-
cocoapods-downloader (>= 2.0)
32+
cocoapods-downloader (>= 2.1, < 3.0)
3133
cocoapods-plugins (>= 1.0.0, < 2.0)
3234
cocoapods-search (>= 1.0.0, < 2.0)
3335
cocoapods-trunk (>= 1.6.0, < 2.0)
@@ -40,7 +42,7 @@ GEM
4042
nap (~> 1.0)
4143
ruby-macho (>= 2.3.0, < 3.0)
4244
xcodeproj (>= 1.23.0, < 2.0)
43-
cocoapods-core (1.14.2)
45+
cocoapods-core (1.15.2)
4446
activesupport (>= 5.0, < 8)
4547
addressable (~> 2.8)
4648
algoliasearch (~> 1.0)
@@ -51,7 +53,7 @@ GEM
5153
public_suffix (~> 4.0)
5254
typhoeus (~> 1.0)
5355
cocoapods-deintegrate (1.0.5)
54-
cocoapods-downloader (2.0)
56+
cocoapods-downloader (2.1)
5557
cocoapods-plugins (1.0.0)
5658
nap
5759
cocoapods-search (1.0.1)
@@ -60,58 +62,59 @@ GEM
6062
netrc (~> 0.11)
6163
cocoapods-try (1.2.0)
6264
colored2 (3.1.2)
63-
concurrent-ruby (1.2.2)
65+
concurrent-ruby (1.3.3)
6466
connection_pool (2.4.1)
65-
drb (2.2.0)
66-
ruby2_keywords
67+
drb (2.2.1)
6768
escape (0.0.4)
6869
ethon (0.16.0)
6970
ffi (>= 1.15.0)
70-
ffi (1.16.3)
71+
ffi (1.17.0)
7172
fourflusher (2.3.1)
7273
fuzzy_match (2.0.4)
7374
gh_inspector (1.1.3)
7475
httpclient (2.8.3)
75-
i18n (1.14.1)
76+
i18n (1.14.5)
7677
concurrent-ruby (~> 1.0)
77-
jazzy (0.14.4)
78+
jazzy (0.15.1)
7879
cocoapods (~> 1.5)
7980
mustache (~> 1.1)
8081
open4 (~> 1.3)
8182
redcarpet (~> 3.4)
82-
rexml (~> 3.2)
83+
rexml (>= 3.2.7, < 4.0)
8384
rouge (>= 2.0.6, < 5.0)
8485
sassc (~> 2.1)
8586
sqlite3 (~> 1.3)
8687
xcinvoke (~> 0.3.0)
87-
json (2.6.3)
88+
json (2.7.2)
8889
liferaft (0.0.6)
89-
mini_portile2 (2.8.5)
90-
minitest (5.20.0)
90+
mini_portile2 (2.8.7)
91+
minitest (5.24.1)
9192
molinillo (0.8.0)
9293
mustache (1.1.1)
9394
mutex_m (0.2.0)
9495
nanaimo (0.3.0)
9596
nap (1.1.0)
9697
netrc (0.11.0)
98+
nkf (0.2.0)
9799
open4 (1.3.4)
98100
public_suffix (4.0.7)
99101
redcarpet (3.6.0)
100-
rexml (3.2.6)
101-
rouge (4.2.0)
102+
rexml (3.2.9)
103+
strscan
104+
rouge (4.3.0)
102105
ruby-macho (2.5.1)
103-
ruby2_keywords (0.0.5)
104106
sassc (2.4.0)
105107
ffi (~> 1.9)
106-
sqlite3 (1.6.8)
108+
sqlite3 (1.7.3)
107109
mini_portile2 (~> 2.8.0)
108-
typhoeus (1.4.0)
110+
strscan (3.1.0)
111+
typhoeus (1.4.1)
109112
ethon (>= 0.9.0)
110113
tzinfo (2.0.6)
111114
concurrent-ruby (~> 1.0)
112115
xcinvoke (0.3.0)
113116
liferaft (~> 0.0.6)
114-
xcodeproj (1.23.0)
117+
xcodeproj (1.24.0)
115118
CFPropertyList (>= 2.3.3, < 4.0)
116119
atomos (~> 0.1.3)
117120
claide (>= 1.0.2, < 2.0)

Source/fetch_dependencies.command

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ set -e
1010

1111
# objectbox-swift release version on GitHub:
1212
# https://github.com/objectbox/objectbox-swift/releases/download/v${version}
13-
version=2.0.0
13+
version=4.0.0
1414

1515
# C library version attached to the GitHub release:
1616
# ObjectBoxCore-static-${c_version}.zip
17-
c_version=4.0.0
17+
c_version=4.0.1
1818

1919
# Params supported by apple-build-static-libs.sh
2020
build_params=""
@@ -115,6 +115,10 @@ if [ -d "$code_dir" ] && [ "$staging_repo" != "true" ]; then # Do we have an exi
115115
fi
116116

117117
# Build
118+
# Temporary: ld warns that static library is not built for 10.15 (but macOS.cmake sets CMAKE_OSX_DEPLOYMENT_TARGET),
119+
# to resolve set MACOSX_DEPLOYMENT_TARGET here until core build scripts are updated.
120+
# Internal issue: objectbox/objectbox-swift#274
121+
export MACOSX_DEPLOYMENT_TARGET="10.15"
118122
"$code_dir/scripts/apple-build-static-libs.sh" $build_params "$dest_dir" release
119123

120124
if [ "$git_clean" = true ] ; then # clean before?

Source/ios-framework/.swiftlint-macOS.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

Source/ios-framework/.swiftlint.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1-
identifier_name:
2-
excluded: # Object IDs are splendid!
3-
- id
4-
1+
included:
2+
- CommonSource
3+
- CommonTests
4+
- ObjectBox-macOS/ObjectBox
5+
- ObjectBox-macOS/ObjectBoxTests
6+
excluded:
7+
# Exclude some generated code
8+
- CommonSource/ConfigFlags.swift
9+
- CommonSource/Entities/EntityFlags.swift
10+
- CommonSource/Entities/PropertyType.swift
11+
- CommonSource/Entities/HnswParams.swift
12+
- CommonSource/Query/OrderFlags.swift
13+
- CommonTests/Test Entities/RelatedEntities.swift
14+
line_length: 120
15+
reporter: "xcode"
16+
disabled_rules:
17+
- comment_spacing # Devs are good at this, sometimes no space if not a comment
18+
- file_length
19+
- identifier_name # Allow anything that Swift allows
20+
- trailing_whitespace
21+
- todo
22+
- type_body_length # Best practice, do not enforce
23+
- vertical_whitespace
24+
type_name:
25+
excluded:
26+
- Id
27+
- __EntityRelatable # TODO check this one; can we remove it altogether?

Source/ios-framework/CodeGenTests/README.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,35 @@ These tests require a copy of ObjectBox Swift Code Generator in a known location
1818

1919
Adding a test case requires the following steps:
2020

21-
1. Add a new command line tool target
22-
2. Name it ToolTestProject`N` (where `N` is the next number)
23-
3. Go to the bottom of `RunToolTests.sh` and add `test_target_num "Test Name" N || FAIL=1` where "Test Name" is the name you want to have used in the log messages for this test, and `N` is again, the number of the test target.
24-
4. Add `-framework ObjectBox` to the "Other Linker Flags"
25-
5. Add `@executable_path/../../../` and `$(TOOLCHAIN_DIR)/usr/lib/swift/macosx` to the "Runpath Search Paths"
26-
6. Add a `ToolTestProjectN.swift` source file (`N` again is the number of the target) containing a `main(_ args: [String]) -> Int32` that does the actual test and returns 0 on success, something else > 0 on failure.
27-
7. Add the `main.swift` file to your target, it calls the main() function for you.
28-
29-
The `RunToolTests.sh` script will run the code generator and pass you the "Test Name" as your first parameter. It will also check the code generator output against a file named `Entity.generatedN.swift`, the model file against a `modelN.json` and such.
21+
1. Open `ToolTestProject.xcodeproj` in Xcode.
22+
2. Duplicate one of the `ToolTestProjectN` command line tool targets and increase to next highest number `N`.
23+
3. In `RunToolTests.sh` at the bottom add a command to run the test (replace `<N>` with the chosen number):
24+
```bash
25+
# If the code generator should succeed
26+
test_target_num "Test Name" <N> || ((FAIL++))
27+
# If the code generator should fail
28+
fail_codegen_target_num "Test Name" <N> || ((FAIL++))
29+
```
30+
4. Add a `ToolTestProjectN.swift` source file (replace `N` again) to the command line tool target. It should look like:
31+
```swift
32+
import ObjectBox
33+
34+
// TODO Add entity classes
35+
36+
func main(_ args: [String]) throws -> Int32 {
37+
// TODO Add test code, may print on error or throw
38+
39+
return 0 // on success
40+
return 1 // or any value > 0 on failure (make sure to print error details)
41+
}
42+
```
43+
5. If the code generator should succeed, add the generated `EntityInfo.generatedN.swift` to the `ToolTestProjectN`
44+
command line tool target as well (so it's verified it compiles).
45+
46+
The `RunToolTests.sh` script will run the code generator and pass the "Test Name" as the first parameter. It will also check the code generator output against a file named `Entity.generatedN.swift`, the model file against a `modelN.json` and such.
47+
48+
### Command line tool target settings
49+
For reference, all of the command line targets have these settings:
50+
- Add `-framework ObjectBox` to the "Other Linker Flags"
51+
- Add `@executable_path/../../../` and `$(TOOLCHAIN_DIR)/usr/lib/swift/macosx` to the "Runpath Search Paths"
52+
- Add the `main.swift` file to the Compile sources build phase, it calls the main() function of the `ToolTestProjectN.swift` file.

Source/ios-framework/CodeGenTests/RunToolTests.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if [ -z ${PROJECT_DIR} ]; then
1818
exit 1
1919
fi
2020

21-
MYDIR="${PROJECT_DIR}/CodeGenTests/" # Xcode copies our script into DerivedData before running it, so hard-code our path.
21+
MYDIR="${PROJECT_DIR}/CodeGenTests" # Xcode copies our script into DerivedData before running it, so hard-code our path.
2222

2323
SOURCERY_APP="${PROJECT_DIR}/../external/objectbox-swift-generator/bin/Sourcery.app"
2424
SOURCERY="${SOURCERY_APP}/Contents/MacOS/Sourcery"
@@ -29,6 +29,11 @@ MYOUTPUTDIR="${MYDIR}/generated/"
2929

3030
mkdir -p $MYOUTPUTDIR
3131

32+
echo ""
33+
echo "====="
34+
echo "Test projects are written to: $MYOUTPUTDIR"
35+
echo "====="
36+
3237
cd ${BUILT_PRODUCTS_DIR}
3338

3439
test_target_num () {
@@ -168,7 +173,7 @@ fail_codegen_target_num () {
168173
echo "note: ******************** $2: $1 ********************"
169174

170175
MODEL_FILE_EXPECTED="${EXPECTED_DIR}/model/model${2}.json"
171-
ORIGINALMESSAGESFILE="${EXPECTED_DIR}/model/messages${2}.log"
176+
ORIGINALMESSAGESFILE="${EXPECTED_DIR}/messages/messages${2}.log"
172177
MODEL_FILE_BEFORE="${EXPECTED_DIR}/model/model${2}.before.json"
173178
MODEL_FILE_ACTUAL="${BUILT_PRODUCTS_DIR}/model${2}.json"
174179
TESTMESSAGESFILE="${BUILT_PRODUCTS_DIR}/messages${2}.log"
@@ -339,6 +344,9 @@ test_target_num "ToMany Backlink ensure applyToDb is needed" 55 || ((FAIL++))
339344
test_target_num "Swift Property Wrappers are treated as wrapped type" 56 || ((FAIL++))
340345
test_target_num "Optional Template Syntax recognized as optional" 57 || ((FAIL++))
341346

347+
fail_codegen_target_num "HNSW index not on float array" 58 || ((FAIL++))
348+
test_target_num "HNSW index" 59 || ((FAIL++))
349+
342350
echo "note: Finished tests with $FAIL failures"
343351

344352
exit $FAIL

0 commit comments

Comments
 (0)