You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Source/README.md
+12-16Lines changed: 12 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,19 +17,15 @@ Repository Contents
17
17
Setup
18
18
-----
19
19
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
25
24
26
25
To build the project for release:
27
26
28
-
* Install [Carthage][], e.g. using Homebrew: `brew install carthage`
29
27
* 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.
33
29
34
30
### Generate the Documentation
35
31
@@ -46,7 +42,7 @@ Distributing the Framework
46
42
47
43
Distribution of the framework as closed source works across these channels:
48
44
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)
50
46
-**Carthage**, by uploading a `.zip` of the frameworks as binary attachments to a GitHub's release.
51
47
52
48
## Build with Carthage
@@ -103,7 +99,7 @@ You look at and build the framework itself via `ios-framework/ObjectBox.xcodepro
103
99
Caveats
104
100
-------
105
101
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.
107
103
108
104
How to Use the Framework
109
105
------------------------
@@ -117,7 +113,7 @@ Define entities:
117
113
118
114
import ObjectBox
119
115
final class Person: Entity {
120
-
var id: Id = 0
116
+
var id: Id<Person> = 0
121
117
var age: Int
122
118
var name: String
123
119
var birthdate: Date
@@ -136,7 +132,7 @@ Run the code generator. This will configure a `ModelBuilder` and get the `Data`
136
132
Create and set up the ObjectBox types:
137
133
138
134
let directory: String = "/path/to/the/store"
139
-
let store: Store = try Store(directoryPath: directory)
135
+
let store: Store = try! Store(directoryPath: directory)
140
136
let personBox: Box<Person> = store.box(for: Person.self)
141
137
142
138
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:
150
146
assert(person.id == personId) // ID is set after put
0 commit comments