Skip to content

Commit a68e89d

Browse files
committed
1.4.0 collected changes
1 parent c14f758 commit a68e89d

File tree

182 files changed

+3082
-1638
lines changed

Some content is hidden

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

182 files changed

+3082
-1638
lines changed

Source/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@ These Swift classes internally use [ObjectBox's C API](https://github.com/object
77

88
Repository Contents
99
-------------------
10-
1110
- `ios-framework/`: The Cocoa Swift framework.
1211
- `docs/swift_output/`: The generated framework documentation.
1312
- `external/`: git submodule and pre-built binary container. This contains the ObjectBoxCore static libraries and our code generator.
14-
- `download_dependencies.command`: Script for downloading libObjectBoxCore into `externals`. You must run this script before you can build the framework.
13+
- `fetch_dependencies.command`: Script for downloading libObjectBoxCore into `externals`. You must run this script before you can build the framework.
1514
- `docs/`: Documentation and discussion of concepts, ideas, and approaches to bring ObjectBox to Swift.
1615

1716
Setup
1817
-----
19-
2018
* Install latest Xcode (Swift 5.2+) with command line tools prepared to build from the shell
2119
* Note: After Xcode updates, you may have to reinstall the CLI tools via `xcode-select --install`
2220
* Ensure you have homebrew (e.g. setup.sh uses it to install [Carthage](https://github.com/Carthage/Carthage))
@@ -79,7 +77,6 @@ This is essentially what comes for free with Carthage. Xcode 10 changed the buil
7977

8078
Swift Framework Project Organization
8179
------------------------------------
82-
8380
You look at and build the framework itself via `ios-framework/ObjectBox.xcodeproj`.
8481

8582
* `ObjectBox.xcproject` targets
@@ -98,14 +95,20 @@ You look at and build the framework itself via `ios-framework/ObjectBox.xcodepro
9895
* `ObjectBox-macOS` contains macOS-specific files, including the framework's Info.plist
9996
* `ObjectBox-iOS` contains iOS-specific files, including the framework's Info.plist
10097

98+
Build notes
99+
-----------
100+
* Build phases; check Xcode project
101+
* "Rename C Header": takes the standard C objectbox.h and augments it with some Swift specifics into ObjectBoxC.h
102+
(TODO: Can we do this differently, e.g. use the standard objectbox.h and then have a second .h for Swift specifics?)
103+
* SwiftLint (macOS build only): calls `swiftlint lint --config .swiftlint-macOS.yml`
104+
* Edit .swiftlint-macOS.yml file to customize (e.g. "id" is OK despite less than 3 chars)
105+
101106
Caveats
102107
-------
103-
104108
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.
105109

106110
How to Use the Framework
107111
------------------------
108-
109112
- The example project in this repository is a good starting point to see how to interact with the framework.
110113
- Have a look at the `ios-framework/CommonTests/Test Entities/RelatedEntities.swift` file to see how self-contained entity code & generated cursor code look. You should be able to copy and paste the contents into a test app if you want. This should also help in case you cannot get the code generator running in 2024 :)
111114

Source/download_dependencies.command

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

Source/fetch_dependencies.command

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
3+
# Script that is used by CI to build the static libs, or by external users to download a build from
4+
# Github. Will do nothing if there already is a copy of the static libs in external.
5+
#
6+
# Adjust the 'version' variable as needed to get the right version for the current code.
7+
#
8+
9+
set -e
10+
11+
if [ "${1:-}" == "--verify-only" ]; then
12+
verify_only=true
13+
shift
14+
else
15+
verify_only=false
16+
fi
17+
18+
# macOS does not have realpath and readlink does not have -f option, so do this instead:
19+
my_dir=$( cd "$(dirname "$0")" ; pwd -P )
20+
21+
cd "$my_dir"
22+
code_dir="${my_dir}/external/objectbox"
23+
dest_dir="${my_dir}/external/objectbox-static"
24+
25+
if [ "$verify_only" = true ]; then
26+
echo "Skipping fetch, only verifying"
27+
else
28+
29+
if [ -d "$code_dir" ]; then # Do we have an existing code repo?
30+
cd "$code_dir" # todo fix this workaround for building into cbuild dir in "our" objectbox-swift dir
31+
echo "Have repository, building."
32+
"$code_dir/scripts/apple-build-static-libs.sh" "$dest_dir" release
33+
exit
34+
else # Download static public release and unzip into $dest
35+
if [ ! -d "${dest_dir}" ] || [ ! -e "${dest_dir}/libObjectBoxCore-iOS.a" ]; then
36+
version=1.4.0
37+
c_version=0.10.0
38+
archive_path="${my_dir}/external/objectbox-static.zip"
39+
OBXLIB_URL_apple_static="https://github.com/objectbox/objectbox-swift/releases/download/v${version}/ObjectBoxCore-static-${c_version}.zip"
40+
41+
mkdir -p "${dest_dir}"
42+
43+
curl -L --fail "${OBXLIB_URL_apple_static}" --output "${archive_path}"
44+
45+
cd "${dest_dir}"
46+
unzip "${archive_path}"
47+
48+
if [ -d "${dest_dir}/build-artifacts/" ]; then
49+
mv "${dest_dir}/build-artifacts/"* "${dest_dir}/"
50+
rm -r "${dest_dir}/build-artifacts/"
51+
fi
52+
53+
rm "${archive_path}"
54+
fi
55+
fi
56+
fi # verify_only
57+
58+
# Print versions for allow verification of built libs (is it the one we expect?)
59+
echo "============================================================================================"
60+
echo "Please check that the found libs are available (macOS, iOS) and contain the expected symbols"
61+
echo "Available libs in '$dest_dir':"
62+
cd ${dest_dir}
63+
for filename in ./*.a; do
64+
echo ""
65+
ls -lha "$filename"
66+
# Match our version/date pattern like "2.6.1-2020-06-09"
67+
obx_version=$(strings "$filename" | grep "[0-9]\.[0-9]\.[0-9]-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]")
68+
echo " >> Version found: $obx_version"
69+
obx_symbols=$(nm -gj "$filename" | grep -c obx_ || true)
70+
obx_sync_symbols=$(nm -gj "$filename" | grep -c obx_sync_ || true)
71+
echo " >> Symbols found: $obx_symbols obx, $obx_sync_symbols obx_sync"
72+
done

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ disabled_rules:
1010
- trailing_whitespace
1111
- todo
1212
- vertical_whitespace
13+
identifier_name:
14+
excluded:
15+
- id
16+
- ok
17+
- tx

Source/ios-framework/CodeGenTests/EntityInfo.generated19.swift

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

0 commit comments

Comments
 (0)