Skip to content

Commit a1db7f7

Browse files
Merge branch 'update-readme-and-files'
2 parents e9429df + 2d10de5 commit a1db7f7

File tree

2 files changed

+63
-43
lines changed

2 files changed

+63
-43
lines changed

Source/Makefile

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

Source/README.md

Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,46 @@ These Swift classes internally use [ObjectBox's C API](https://github.com/object
77
## Repository Contents
88

99
- `ios-framework/`: The ObjectBox Swift framework. Uses a special static ObjectBox C library for macOS/iOS, see `fetch_dependencies.command` below.
10+
- `docs/swift_output/`: The generated framework documentation.
1011
- `external/`: git submodule and/or pre-built binary container.
1112
This contains the ObjectBoxCore static libraries and the [ObjectBox Swift code generator](https://github.com/objectbox/objectbox-swift-generator).
1213

1314
**Scripts** and how they depend on each other (subject to future simplifications):
1415

15-
- `ios-framework/Makefile`: combines `fetch_dependencies.command` and a Carthage build to create the Swift framework.
1616
- `fetch_dependencies.command`: populates `external/objectbox-static` with libObjectBoxCore.
1717
libObjectBoxCore is a crucial requirement build the Swift framework.
18+
- `ios-framework/Makefile`: combines `fetch_dependencies.command` and a Carthage build to create the Swift framework.
1819
- `create-xcframework.sh`: builds the multi-platform archive containing binaries for multiple platforms and architectures.
1920

2021
### Tests
2122

2223
ObjectBox comes with a couple of tests of different categories:
2324

2425
* Unit tests: `ios-framework/CommonTests`, based on XCTestCase
25-
* Integration tests "CodeGen": `ios-framework/CodeGenTests` run via script (for now only via Xcode/xcodebuild);
26-
uses a separate Xcode project and an ObjectBox generator executable to generate actual binding classes.
27-
[README](ios-framework/CodeGenTests/README.md)
28-
* Integration tests "IntegrationTests": `ios-framework/IntegrationTests`, currently not maintained, run via script;
29-
somewhat similar to CodeGen; subject to a general clean up; see also its [README](ios-framework/IntegrationTests/Readme.md)
26+
* Integration tests (see [README](ios-framework/CodeGenTests/README.md)): `ios-framework/CodeGenTests` are run by building the CodenGenTests target with Xcode/xcodebuild (which runs a script that must be launched by Xcode/xcodebuild);
27+
uses a separate Xcode project and an ObjectBox generator executable to generate actual binding classes and assert the generator and database operations.
28+
* (Outdated) Integration tests "IntegrationTests": `ios-framework/IntegrationTests`, currently not maintained, run via script;
29+
somewhat similar to CodeGen; subject to a general clean up; see [README](ios-framework/IntegrationTests/Readme.md)
3030
* External integration test project: https://github.com/objectbox/objectbox-swift-integration-test
3131
runs "real projects" with "full ObjectBox round-trip" on internal CI and CircleCI
3232

33+
### Xcode Project Organization
34+
35+
You look at and build the framework itself via `ios-framework/ObjectBox.xcodeproj`.
36+
37+
* `ObjectBox.xcproject` targets
38+
* `ObjectBox-macOS`, `ObjectBox-iOS` and `ObjectBox-iOS Simulator` build the `ObjectBox.framework` for each platform
39+
* `ObjectBoxTests-macOS`, `ObjectBoxTests-iOS` and `ObjectBoxTests-iOS Simulator` build unit tests for each platforms framework
40+
* `iOS-Fat-Framework` builds a universal binary of the iOS framework needed for distribution, with code both for device and simulator
41+
* `CodeGenTests` runs a script that runs generator and integration tests, see notes for tests above
42+
* `ObjectBox.xcproject` main groups and directories
43+
* `CommonSource` contains all code to be shared by the framework of the macOS and iOS platforms.
44+
* `ObjectBox.h` is the framework umbrella header where all public C and ObjC header files are listed. These are either intended for use by app developers, or required to be visible for the Swift extensions.
45+
* `objectbox-c.h` and `objectbox-c-sync.h` are modified copies of the C API's header files created by the `fetch_dependencies.command` script so they can be imported into Swift and do not collide with `ObjectBox.h` on case-insensitive file systems.
46+
* The directory itself contains general purpose types like `Store` and `Box`. The important sub-groups are `Entities`, `Relation`, and `Query`.
47+
* `CommonTests` contains all code to be shared by tests for the macOS and iOS platforms, see notes on tests above
48+
* `ObjectBox-macOS`, `ObjectBox-iOS` and `ObjectBox-iOS Simulator` contain platform-specific files, including the framework's Info.plist
49+
3350
## Development
3451

3552
* Ensure the latest Xcode is installed (Swift 5.3+, command line tools should be included).
@@ -39,7 +56,7 @@ ObjectBox comes with a couple of tests of different categories:
3956
* Runs `brew bundle` to install or update basic build tools including [Carthage](https://github.com/Carthage/Carthage) (see [Brewfile](Brewfile)).
4057
* Runs `bundle install` to install or update cocoapods and jazzy (see [Gemfile](Gemfile)).
4158

42-
Open the Xcode project in `ios-framework/ObjectBox.xcodeproj`. See section below on how it is organized.
59+
Open the Xcode project in `ios-framework/ObjectBox.xcodeproj`.
4360

4461
From the command line:
4562

@@ -59,6 +76,20 @@ make unit_tests
5976
make integration_tests
6077
```
6178

79+
**To execute a specific test** change the last argument to specify your test. You can also execute a group/class by removing the last one/two parts of the filter.
80+
Note: `xcpretty` cleans up the output so you won't see all the compiler calls but it also hides failed tests output. So once you see a failure, run without `xcpretty` to read the error.
81+
```shell script
82+
xcodebuild -derivedDataPath ./DerivedData test -project ObjectBox.xcodeproj -scheme ObjectBox-macOS -destination 'platform=OS X,arch=x86_64' -only-testing ObjectBoxTests-macOS/StoreTests/test32vs64BitForOs | xcpretty
83+
xcodebuild -derivedDataPath ./DerivedData test -project ObjectBox.xcodeproj -scheme ObjectBox-iOS -destination 'platform=iOS Simulator,name=iPhone 11' -only-testing ObjectBoxTests-iOS/StoreTests/test32vs64BitForOs | xcpretty
84+
```
85+
86+
**To run tests with an in-memory database** set the following environment variable before running an xcodebuild command:
87+
```
88+
export OBX_IN_MEMORY=true
89+
make u_tests
90+
```
91+
In Xcode, set this by editing the scheme: under Test look for Arguments.
92+
6293
### Generate the Documentation
6394

6495
Inside `ios-framework/` jazzy is configured inside [Makefile](ios-framework/Makefile):
@@ -72,30 +103,36 @@ Jazzy uses the [README.md](ios-framework/README.md) as a front page.
72103

73104
The result is stored inside `ios-framework/docs/swift_output/`.
74105

75-
### Xcode Project Organization
106+
### Ruby version
76107

77-
You look at and build the framework itself via `ios-framework/ObjectBox.xcodeproj`.
108+
The Ruby version on macOS is outdated, e.g. Cocoapods may have a problem.
109+
Use [rbenv](https://github.com/rbenv/rbenv) to install the required version:
78110

79-
* `ObjectBox.xcproject` targets
80-
* `ObjectBox-macOS` builds the `ObjectBox.framework` for the macOS platform
81-
* `ObjectBoxTests-macOS` builds the unit tests for the macOS framework
82-
* `ObjectBox-iOS` builds the `ObjectBox.framework` for the iOS platform
83-
* `ObjectBoxTests-iOS` builds the unit tests for the iOS framework
84-
* `iOS-Fat-Framework` builds a universal binary of the iOS framework needed for distribution, with code both for device and simulator
85-
* `CodeGenTests` Runs a shell script that performs integration tests for various features. This will run the Sourcery code generator over files and then compile the result against the framework.
86-
* `ObjectBox.xcproject` main groups and directories
87-
* `CommonSource` contains all code to be shared by the framework of the macOS and iOS platforms.
88-
* `ObjectBox.h` is the framework umbrella header where all public C and ObjC header files are listed. These are either intended for use by app developers, or required to be visible for the Swift extensions.
89-
* `ObjectBoxC.h` is a modified version of the C API's `objectbox.h` header generated by the `generate_ObjectBoxC_header.rb` script so it can be imported into Swift and doesn't have a name collision with `ObjectBox.h` on case-insensitive file systems.
90-
* The directory itself contains general purpose types like `Store` and `Box`. The important sub-groups are `Entities`, `Relation`, and `Query`.
91-
* `CommonTests` contains all code to be shared by tests for the macOS and iOS platforms
92-
* `ObjectBox-macOS` contains macOS-specific files, including the framework's Info.plist
93-
* `ObjectBox-iOS` contains iOS-specific files, including the framework's Info.plist
111+
# Print current version
112+
ruby -v
113+
# Install rbenv and build plugin to install ruby versions
114+
brew update && brew install rbenv ruby-build
115+
# Print the version configured in .ruby-version
116+
rbenv local
117+
# Install that version, e.g.
118+
rbenv install 3.0.5
119+
# Ensure it is the expected version
120+
ruby -v
121+
122+
To change the required ruby version, see https://www.ruby-lang.org/en/downloads/releases/ and set
123+
it with e.g. `rbenv local 3.0.5`. This will update the `.ruby-version` file. Then install
124+
it with rbenv like above.
125+
126+
### Updating gems: CocoaPods, Jazzy
127+
128+
If needed, change the allowed version in [Gemfile](Gemfile).
129+
130+
Run `bundle update` and commit the changed [lock file](Gemfile.lock).
94131

95132
### Build notes
96133

97-
* SwiftLint (macOS build only): calls `swiftlint lint --config .swiftlint-macOS.yml`
98-
* Edit .swiftlint-macOS.yml file to customize (e.g. "id" is OK despite less than 3 chars)
134+
* SwiftLint: target `ObjectBox-macOS` has a build phase that runs `swiftlint lint --config .swiftlint.yml`
135+
* Edit `.swiftlint.yml` file to customize
99136

100137
## Caveats
101138

0 commit comments

Comments
 (0)