Skip to content

Commit 69363ec

Browse files
committed
v1.1.1
1 parent 9443995 commit 69363ec

16 files changed

+288
-64
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ Carthage/Checkouts
3535

3636
#Other IDEs
3737
.idea/
38+
39+
# ObjectBox model backups
40+
*.json.bak

Example/Podfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
#source 'https://github.com/objectbox/objectbox-swift-spec-staging'
2+
13
use_frameworks!
24

35
target 'NotesExample-iOS' do
46
platform :ios, :deployment_target => '11.0'
5-
pod 'ObjectBox', '1.1'
7+
pod 'ObjectBox'
68
end
79

810
target 'NotesExample-macOS' do
911
platform :osx, :deployment_target => '10.10'
10-
pod 'ObjectBox', '1.1'
12+
pod 'ObjectBox'
1113
end

Example/model-NotesExample-iOS.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"lastRelationId": "0:0",
7171
"lastSequenceId": "0:0",
7272
"modelVersion": 5,
73-
"modelVersionParserMinimum": 5,
73+
"modelVersionParserMinimum": 4,
7474
"retiredEntityUids": [],
7575
"retiredIndexUids": [],
7676
"retiredPropertyUids": [],

Example/model-NotesExample-macOS.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"lastRelationId": "0:0",
7171
"lastSequenceId": "0:0",
7272
"modelVersion": 5,
73-
"modelVersionParserMinimum": 5,
73+
"modelVersionParserMinimum": 4,
7474
"retiredEntityUids": [],
7575
"retiredIndexUids": [],
7676
"retiredPropertyUids": [],

Source/README.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,15 @@ Repository Contents
1717
Setup
1818
-----
1919

20-
* Install Xcode 11.2+ (Swift 5.1+) with command line tools prepared to build from the shell
21-
* Run `git submodule update --init --recursive` to get external dependencies
22-
* Run `make build_swiftlint` to build the build SwiftLint from source into its `external/SwiftLint/.build` directory.
23-
* The Sourcery submodule contains a `_build.command` script that you can double-click to build a release-ready version of the code generator.
24-
* Build the framework using the `ObjectBox.xcodeproj`
20+
* Install latest Xcode (Swift 5.1+) with command line tools prepared to build from the shell
21+
* Ensure you have homebrew (e.g. setup.sh uses it to install [Carthage](https://github.com/Carthage/Carthage))
22+
* Run `./setup.sh` (see the [setup.sh](setup.sh) file for more comments if you want)
23+
* Open Xcode project in ios-framework/ObjectBox.xcodeproj
2524

2625
To build the project for release:
2726

28-
* Install [Carthage][], e.g. using Homebrew: `brew install carthage`
2927
* Run `cd ios-framework/; make all` to build the frameworks from source with Carthage
30-
* The `ios-framework/cocoapod/make_podspec_and_zip.command` script can be double-clicked to build a release-ready archive and Podspec file.
31-
32-
[Carthage]: https://github.com/Carthage/Carthage
28+
* The `ios-framework/cocoapod/make-release.command` script can be double-clicked to build a release-ready archive and Podspec file.
3329

3430
### Generate the Documentation
3531

@@ -46,7 +42,7 @@ Distributing the Framework
4642

4743
Distribution of the framework as closed source works across these channels:
4844

49-
- **CocoaPods**, by setting the `.podspec`'s `vendored_frameworks` to point to the build products of the macOS and iOS framework targets. (The `make_podspec_and_zip.command` script takes care of this)
45+
- **CocoaPods**, by setting the `.podspec`'s `vendored_frameworks` to point to the build products of the macOS and iOS framework targets. (The `make-release.command` script takes care of this)
5046
- **Carthage**, by uploading a `.zip` of the frameworks as binary attachments to a GitHub's release.
5147

5248
## Build with Carthage
@@ -103,7 +99,7 @@ You look at and build the framework itself via `ios-framework/ObjectBox.xcodepro
10399
Caveats
104100
-------
105101

106-
To make to-one relations and their backlinks work, the `Entity` protocol was extended to require (1) an `EntityType` typealias, and (2) an `_id` property. The former was needed to disambiguate which concrete entity we're talking about when all we have is the protocol type, and this in turn is needed to specify the generic type requirement of `EntityId<T>`. Since the `Entity` protocol itself is intended to be no more than a convenient code annotation (which Sourcery can filter on), it's advised to get rid of this as soon as possible and find a different way to get the data needed for associations in Swift, for example using an `IdGetter<T>` like we do in Java and injecting it into `EntityInfo` from generated code.
102+
To make to-one relations and their backlinks work, the `Entity` protocol was extended to require (1) an `EntityType` typealias, and (2) an `_id` property. The former was needed to disambiguate which concrete entity we're talking about when all we have is the protocol type, and this in turn is needed to specify the generic type requirement of `Id<T>`. Since the `Entity` protocol itself is intended to be no more than a convenient code annotation (which Sourcery can filter on), it's advised to get rid of this as soon as possible and find a different way to get the data needed for associations in Swift, for example using an `IdGetter<T>` like we do in Java and injecting it into `EntityInfo` from generated code.
107103

108104
How to Use the Framework
109105
------------------------
@@ -117,7 +113,7 @@ Define entities:
117113

118114
import ObjectBox
119115
final class Person: Entity {
120-
var id: Id = 0
116+
var id: Id<Person> = 0
121117
var age: Int
122118
var name: String
123119
var birthdate: Date
@@ -136,7 +132,7 @@ Run the code generator. This will configure a `ModelBuilder` and get the `Data`
136132
Create and set up the ObjectBox types:
137133

138134
let directory: String = "/path/to/the/store"
139-
let store: Store = try Store(directoryPath: directory)
135+
let store: Store = try! Store(directoryPath: directory)
140136
let personBox: Box<Person> = store.box(for: Person.self)
141137

142138
This will call into the the generated (!) initializer that uses the private model builder's `modelBytes()` automatically.
@@ -150,10 +146,10 @@ Then you're all set to use entities with ObjectBox:
150146
assert(person.id == personId) // ID is set after put
151147

152148
// Get by ID
153-
assert(try personBox.get(personId) != nil)
149+
assert(personBox.get(personId) != nil)
154150

155151
// Get collections of entities
156-
_ = try personBox.all()
157-
_ = try personBox.query({ Person.name == "Fry" }).build().find()
152+
_ = personBox.all()
153+
_ = personBox.query({ Person.name == "Fry" }).build().find()
158154

159155
That's it, it works now!

Source/download_dependencies.command

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,27 @@
88

99
set -e
1010

11-
version=1.1
12-
core_version=0.7.2
11+
# macOS does not have realpath and readlink does not have -f option, so do this instead:
12+
my_dir=$( cd "$(dirname "$0")" ; pwd -P )
1313

14-
my_dir=`dirname "$0"`
15-
my_dir=`realpath "${my_dir}"`
16-
17-
cd $my_dir
14+
cd "$my_dir"
1815
code_dir="${my_dir}/external/objectbox/"
1916
dest_dir="${my_dir}/external/objectbox-static/"
20-
archive_path="${my_dir}/external/objectbox-static.zip"
21-
OBXLIB_URL_apple_static="https://github.com/objectbox/objectbox-swift/releases/download/v${version}/ObjectBoxCore-static-${core_version}.zip"
2217

18+
# Build?
2319
if [ -d "$code_dir" ]; then
2420
echo "Have repository, building."
2521
"$code_dir/xcode/build_objectbox_core.command" "$dest_dir" release
2622
exit
2723
fi
2824

25+
# Nothing to build, so download instead
2926
if [ ! -d "${dest_dir}" ] || [ ! -e "${dest_dir}/libObjectBoxCore-iOS.a" ]; then
27+
version=1.1
28+
core_version=0.7.2
29+
archive_path="${my_dir}/external/objectbox-static.zip"
30+
OBXLIB_URL_apple_static="https://github.com/objectbox/objectbox-swift/releases/download/v${version}/ObjectBoxCore-static-${core_version}.zip"
31+
3032
mkdir -p "${dest_dir}"
3133

3234
curl -L --fail "${OBXLIB_URL_apple_static}" --output "${archive_path}"

Source/ios-framework/CodeGenTests/ConvertToolTests.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
#!/bin/bash
22

3-
# RunToolTests.sh
4-
# ObjectBox Swift
5-
#
6-
# Created by Uli Kusterer on 07.12.18.
7-
#
8-
93
echo -n "note: Starting tests at "
104
date
115

12-
mydir=`dirname "$0"`
6+
# macOS does not have realpath and readlink does not have -f option, so do this instead:
7+
mydir=$( cd "$(dirname "$0")" ; pwd -P )
8+
cd "${mydir}"
9+
1310
itestdir="$mydir/../IntegrationTests/"
1411

1512
test_target_num () {

Source/ios-framework/CommonSource/Combine.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ extension BoxPublisher {
133133
extension Query {
134134
/// Return a Combine publisher for this query that you can subscribe to.
135135
public var publisher: QueryPublisher<EntityType> {
136-
return store.lazyAttachedObject(key: "QueryPublisher<\(EntityType.self)>\(Unmanaged.passUnretained(self).toOpaque())") {
136+
let keyString = "QueryPublisher<\(EntityType.self)>\(Unmanaged.passUnretained(self).toOpaque())"
137+
return store.lazyAttachedObject(key: keyString) {
137138
return QueryPublisher<EntityType>(query: self)
138139
}
139140
}

Source/ios-framework/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ integration_tests: download_statics
2323
../external/objectbox-swift-generator/_build.command
2424
xcodebuild $(XCOPTIONS) build -project ObjectBox.xcodeproj -scheme CodeGenTests -destination 'platform=OS X,arch=x86_64'
2525

26+
# Note: If ObjectBox core repo is present, it won't download but build it instead
2627
download_statics:
27-
@echo "$(BLUE)Downloading static libraries...$(NC)"
28+
@echo "$(BLUE)Building/Downloading static libraries...$(NC)"
2829
@../download_dependencies.command
2930

3031
build_framework: download_statics

Source/ios-framework/ObjectBox.xcodeproj/project.pbxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,7 @@
771771
hasScannedForEncodings = 0;
772772
knownRegions = (
773773
en,
774+
Base,
774775
);
775776
mainGroup = CB3B3F2720AB4B4B00418618;
776777
productRefGroup = CB3B3F3220AB4B4B00418618 /* Products */;

0 commit comments

Comments
 (0)