Skip to content

Commit

Permalink
1.6.0 (using lib 0.15.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
greenrobot committed Feb 21, 2022
1 parent e291c34 commit 607cb54
Show file tree
Hide file tree
Showing 18 changed files with 961 additions and 467 deletions.
2 changes: 1 addition & 1 deletion Source/Gemfile.lock
Expand Up @@ -79,7 +79,7 @@ GEM
nap (1.1.0)
netrc (0.11.0)
open4 (1.3.4)
redcarpet (3.5.1)
redcarpet (3.5.0)
rouge (3.22.0)
ruby-macho (1.4.0)
sassc (2.4.0)
Expand Down
4 changes: 3 additions & 1 deletion Source/README.md
Expand Up @@ -16,6 +16,8 @@ Repository Contents

- `fetch_dependencies.command`: populates `external/objectbox-static` with libObjectBoxCore.
libObjectBoxCore is a crucial requirement build the Swift framework.
- `ios-framework/Makefile`: combines `fetch_dependencies.command` and a Carthage build to create the Swift framework.
- `.gitlab-ci.yml` calls make targets of `ios-framework/Makefile`
- `create-xcframework.sh`: builds the multi-platform archive containing binaries for multiple platforms and architectures.

Tests
Expand Down Expand Up @@ -43,7 +45,7 @@ Setup
To build the project for release:

* Run `cd ios-framework/; make all` to build the frameworks from source with Carthage
* The `ios-framework/cocoapod/make-release.command` script can be double-clicked to build a release-ready archive and Podspec file.
* The `ios-framework/cocoapod/make-release.command` script can be double-clicked to build a release-ready archive and Podspec & SPM files.

### Generate the Documentation

Expand Down
2 changes: 2 additions & 0 deletions Source/create-xcframework.sh
Expand Up @@ -10,6 +10,8 @@ mkdir -p "$dir_build"
derived_data_path=$( mktemp -d )
mkdir -p $derived_data_path

xcodebuild -version

function build() {
echo "************* Building archive for $1 $2 (${3:-$1}) *************"
xcrun xcodebuild build \
Expand Down
29 changes: 22 additions & 7 deletions Source/fetch_dependencies.command
Expand Up @@ -15,6 +15,13 @@ else
verify_only=false
fi

if [ "${1:-}" == "--staging" ]; then
staging_repo=true
shift
else
staging_repo=false
fi

# macOS does not have realpath and readlink does not have -f option, so do this instead:
my_dir=$( cd "$(dirname "$0")" ; pwd -P )

Expand All @@ -26,14 +33,17 @@ if [ "$verify_only" = true ]; then
echo "Skipping fetch, only verifying"
else

if [ -d "$code_dir" ]; then # Do we have an existing code repo?
if [ -d "$code_dir" ] && [ "$staging_repo" != "true" ]; then # Do we have an existing code repo? Then build it...
xcode_version="$(xcodebuild -version | head -n 1 | tr -cd '[a-zA-Z0-9]._-')"
echo "Xcode version: $xcode_version"

pushd "$code_dir" # note: this also "fixed" building into cbuild dir in "our" objectbox-swift dir
build_params="" # must also part of the cache key
build_params="--skip-apple-silicon" # must also part of the cache key
commit_id=$(git rev-parse HEAD)
cache_dir="$HOME/Library/Caches/ObjectBox"
mkdir -p "${cache_dir}"
find "${cache_dir}" -name "objectbox-static-*.zip" -type f -mtime +30 # -delete # TODO enable delete once this looks good
cache_key="${commit_id}"
cache_key="${commit_id}-$xcode_version"
if [ -n "$build_params" ]; then
cache_key="${cache_key}-$(echo "$build_params" | tr -cd '[a-zA-Z0-9]._-')"
fi
Expand All @@ -56,7 +66,7 @@ if [ -d "$code_dir" ]; then # Do we have an existing code repo?
echo "⚪ ObjectBox core is clean but no cache ZIP found for ${cache_key}."
echo "🏗️ Building..."
sleep 0.5
fi
fi
else
git status
echo "🔴 ObjectBox core is not clean, won't use caching. 🏗️ Building..."
Expand All @@ -78,10 +88,15 @@ if [ -d "$code_dir" ]; then # Do we have an existing code repo?
popd
else # Download static public release and unzip into $dest
if [ ! -d "${dest_dir}" ] || [ ! -e "${dest_dir}/libObjectBoxCore-iOS.a" ]; then
version=1.5.0
c_version=0.13.0
version=1.7.0
c_version=0.15.2
archive_path="${my_dir}/external/objectbox-static.zip"
OBXLIB_URL_apple_static="https://github.com/objectbox/objectbox-swift/releases/download/v${version}/ObjectBoxCore-static-${c_version}.zip"
if [ "$staging_repo" == "true" ]; then
release_url_path="https://github.com/objectbox/objectbox-swift-spec-staging/releases/download/v1.x"
else
release_url_path="https://github.com/objectbox/objectbox-swift/releases/download/v${version}"
fi
OBXLIB_URL_apple_static="release_url_path/ObjectBoxCore-static-${c_version}.zip"

mkdir -p "${dest_dir}"

Expand Down
3 changes: 1 addition & 2 deletions Source/ios-framework/CodeGenTests/RunToolTests.sh
Expand Up @@ -3,8 +3,7 @@
# Run this script from Xcode (target & scheme "CodeGenTests"):
# it has a dependency and also relies on variables set by Xcode

echo -n "note: Starting tests at "
date
echo -n "note: Starting tests at $(date)"

if [ -z ${PROJECT_DIR} ]; then
echo "PROJECT_DIR unavailable; please run from Xcode"
Expand Down
Expand Up @@ -28,7 +28,7 @@ extension BusRoute: ObjectBox.EntityInspectable {
fileprivate static func buildEntity(modelBuilder: ObjectBox.ModelBuilder) throws {
let entityBuilder = try modelBuilder.entityBuilder(for: BusRoute.self, id: 1, uid: 5107964062888457216)
try entityBuilder.flags([.syncEnabled, .sharedGlobalIds])
try entityBuilder.addProperty(name: "id", type: EntityId<BusRoute>.entityPropertyType, flags: [.id], id: 1, uid: 7895576389419683840)
try entityBuilder.addProperty(name: "id", type: PropertyType.long, flags: [.id], id: 1, uid: 7895576389419683840)

try entityBuilder.lastProperty(id: 2, uid: 6687926154759915520)
}
Expand Down
4 changes: 4 additions & 0 deletions Source/ios-framework/CommonSource/Errors.swift
Expand Up @@ -72,6 +72,10 @@ public enum ObjectBoxError: Swift.Error {
case filePagesCorrupt(message: String)
/// Attempted to establish a relation to an entity that hasn't been assigned an ID yet.
case cannotRelateToUnsavedEntities(message: String)

/// Typically when there's no open store available at the given directory
case cannotAttachToStore(message: String)

/// Unexpected error, should never occur in practice, but for pragmatic reasons, we cover the case.
/// Used in some cases where ObjectBox e.g. calls a function (which can only say throws and not what it throws)
/// If you encounter this error in your use of ObjectBox, please report it to us, as it's likely a bug in the
Expand Down
4 changes: 2 additions & 2 deletions Source/ios-framework/CommonSource/Internal/Transaction.swift
Expand Up @@ -28,9 +28,9 @@ class Transaction {
init(store: Store, writable: Bool) throws {
isWritable = writable
if isWritable {
cTransaction = obx_txn_write(store.cStore)
cTransaction = obx_txn_write(try store.ensureCStore())
} else {
cTransaction = obx_txn_read(store.cStore)
cTransaction = obx_txn_read(try store.ensureCStore())
}
try checkLastError()
}
Expand Down

0 comments on commit 607cb54

Please sign in to comment.