Unverified Commit a63a755f authored by Zach Knox's avatar Zach Knox
Browse files

improved refresh label and pod updates

parent a48779fa
......@@ -7,11 +7,11 @@ PODS:
- ObjectMapper+Realm (0.6):
- ObjectMapper
- RealmSwift
- Realm (3.6.0):
- Realm/Headers (= 3.6.0)
- Realm/Headers (3.6.0)
- RealmSwift (3.6.0):
- Realm (= 3.6.0)
- Realm (3.7.1):
- Realm/Headers (= 3.7.1)
- Realm/Headers (3.7.1)
- RealmSwift (3.7.1):
- Realm (= 3.7.1)
DEPENDENCIES:
- Crashlytics
......@@ -27,8 +27,8 @@ SPEC CHECKSUMS:
Fabric: bda89e242bce1b7b8ab264248cf3407774ce0095
ObjectMapper: 5cccd2de6f253eda859df8116a5a554d9769e859
ObjectMapper+Realm: 4cf44ed3202a73f08594e21e13eb3f8aa9b5a664
Realm: 08b464b462d4f31bbd4ba5f5a1c8722ef0a700b7
RealmSwift: 973e1499c44ab571f894c2c908e2db450be280c3
Realm: 906be37d52f17f25484ac01643a7f26a9d3bfbd5
RealmSwift: 1c2b6bae3dc55bb87e080ffa96537d71442f6dce
PODFILE CHECKSUM: 999bfe9f7d07d176c0bb5bff060455f38135f947
......
......@@ -7,11 +7,11 @@ PODS:
- ObjectMapper+Realm (0.6):
- ObjectMapper
- RealmSwift
- Realm (3.6.0):
- Realm/Headers (= 3.6.0)
- Realm/Headers (3.6.0)
- RealmSwift (3.6.0):
- Realm (= 3.6.0)
- Realm (3.7.1):
- Realm/Headers (= 3.7.1)
- Realm/Headers (3.7.1)
- RealmSwift (3.7.1):
- Realm (= 3.7.1)
DEPENDENCIES:
- Crashlytics
......@@ -27,8 +27,8 @@ SPEC CHECKSUMS:
Fabric: bda89e242bce1b7b8ab264248cf3407774ce0095
ObjectMapper: 5cccd2de6f253eda859df8116a5a554d9769e859
ObjectMapper+Realm: 4cf44ed3202a73f08594e21e13eb3f8aa9b5a664
Realm: 08b464b462d4f31bbd4ba5f5a1c8722ef0a700b7
RealmSwift: 973e1499c44ab571f894c2c908e2db450be280c3
Realm: 906be37d52f17f25484ac01643a7f26a9d3bfbd5
RealmSwift: 1c2b6bae3dc55bb87e080ffa96537d71442f6dce
PODFILE CHECKSUM: 999bfe9f7d07d176c0bb5bff060455f38135f947
......
......@@ -78,7 +78,7 @@ using namespace realm;
return self.realm.schema;
}
- (void)enumerateObjects:(NSString *)className block:(RLMObjectMigrationBlock)block {
- (void)enumerateObjects:(NSString *)className block:(__attribute__((noescape)) RLMObjectMigrationBlock)block {
RLMResults *objects = [_realm.schema schemaForClassName:className] ? [_realm allObjects:className] : nil;
RLMResults *oldObjects = [_oldRealm.schema schemaForClassName:className] ? [_oldRealm allObjects:className] : nil;
......
......@@ -23,6 +23,7 @@
#import "RLMRealm_Private.hpp"
#import "RLMResults_Private.hpp"
#import "RLMSchema.h"
#import "RLMSyncSession.h"
#import "results.hpp"
#import "sync/partial_sync.hpp"
......@@ -51,4 +52,8 @@ using namespace realm;
partial_sync::register_query(_realm, className.UTF8String, query.UTF8String, std::move(cb));
}
- (RLMSyncSession *)syncSession {
return [RLMSyncSession sessionForRealm:self];
}
@end
......@@ -609,11 +609,11 @@ REALM_NOINLINE static void translateSharedGroupOpenException(RLMRealmConfigurati
}
}
- (void)transactionWithBlock:(void(^)(void))block {
- (void)transactionWithBlock:(__attribute__((noescape)) void(^)(void))block {
[self transactionWithBlock:block error:nil];
}
- (BOOL)transactionWithBlock:(void(^)(void))block error:(NSError **)outError {
- (BOOL)transactionWithBlock:(__attribute__((noescape)) void(^)(void))block error:(NSError **)outError {
[self beginWriteTransaction];
block();
if (_realm->is_in_transaction()) {
......
......@@ -94,7 +94,7 @@ static BOOL isValidRealmURL(NSURL *url) {
return [self.realmURL isEqual:that.realmURL]
&& [self.user isEqual:that.user]
&& self.stopPolicy == that.stopPolicy
&& self.isPartial == that.isPartial;
&& self.fullSynchronization == that.fullSynchronization;
}
- (void)setEnableSSLValidation:(BOOL)enableSSLValidation {
......@@ -113,6 +113,14 @@ static BOOL isValidRealmURL(NSURL *url) {
return (BOOL)_config->is_partial;
}
- (void)setFullSynchronization:(BOOL)fullSynchronization {
_config->is_partial = !(bool)fullSynchronization;
}
- (BOOL)fullSynchronization {
return !(BOOL)_config->is_partial;
}
- (realm::SyncConfig)rawConfiguration {
return *_config;
}
......@@ -158,6 +166,23 @@ static BOOL isValidRealmURL(NSURL *url) {
errorHandler:nullptr];
}
- (instancetype)initWithUser:(RLMSyncUser *)user
realmURL:(NSURL *)url
isPartial:(BOOL)isPartial
urlPrefix:(NSString *)urlPrefix
stopPolicy:(RLMSyncStopPolicy)stopPolicy
enableSSLValidation:(BOOL)enableSSLValidation {
auto config = [self initWithUser:user
realmURL:url
customFileURL:nil
isPartial:isPartial
stopPolicy:stopPolicy
errorHandler:nullptr];
config.urlPrefix = urlPrefix;
config.enableSSLValidation = enableSSLValidation;
return config;
}
- (instancetype)initWithUser:(RLMSyncUser *)user
realmURL:(NSURL *)url
customFileURL:(nullable NSURL *)customFileURL
......
......@@ -24,6 +24,8 @@
#import "RLMRealmConfiguration_Private.hpp"
#import "RLMRealmUtil.hpp"
#import "RLMResults_Private.hpp"
#import "RLMSyncConfiguration.h"
#import "RLMSyncConfiguration_Private.hpp"
#import "RLMSyncManager_Private.h"
#import "RLMSyncPermissionResults.h"
#import "RLMSyncPermission_Private.hpp"
......@@ -156,11 +158,9 @@ PermissionChangeCallback RLMWrapPermissionStatusCallback(RLMPermissionStatusBloc
- (instancetype)initPrivate {
if (self = [super init]) {
_configMaker = std::make_unique<ConfigMaker>([](std::shared_ptr<SyncUser> user, std::string url) {
RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
NSURL *objCUrl = [NSURL URLWithString:@(url.c_str())];
RLMSyncUser *objCUser = [[RLMSyncUser alloc] initWithSyncUser:std::move(user)];
config.syncConfiguration = [[RLMSyncConfiguration alloc] initWithUser:objCUser realmURL:objCUrl];
return [config config];
return [objCUser configurationWithURL:objCUrl fullSynchronization:true].config;
});
return self;
}
......@@ -206,6 +206,44 @@ PermissionChangeCallback RLMWrapPermissionStatusCallback(RLMPermissionStatusBloc
completionBlock:completion];
}
- (RLMRealmConfiguration *)configuration {
return [self configurationWithURL:nil
fullSynchronization:NO
enableSSLValidation:YES
urlPrefix:nil];
}
- (RLMRealmConfiguration *)configurationWithURL:(NSURL *)url {
return [self configurationWithURL:url
fullSynchronization:NO
enableSSLValidation:YES
urlPrefix:nil];
}
- (RLMRealmConfiguration *)configurationWithURL:(NSURL *)url fullSynchronization:(bool)fullSynchronization {
return [self configurationWithURL:url
fullSynchronization:fullSynchronization
enableSSLValidation:YES
urlPrefix:nil];
}
- (RLMRealmConfiguration *)configurationWithURL:(NSURL *)url
fullSynchronization:(bool)fullSynchronization
enableSSLValidation:(bool)enableSSLValidation
urlPrefix:(NSString * _Nullable)urlPrefix {
auto syncConfig = [[RLMSyncConfiguration alloc] initWithUser:self
realmURL:url ?: self.defaultRealmURL
customFileURL:nil
isPartial:!fullSynchronization
stopPolicy:RLMSyncStopPolicyAfterChangesUploaded
errorHandler:nullptr];
syncConfig.urlPrefix = urlPrefix;
syncConfig.enableSSLValidation = enableSSLValidation;
RLMRealmConfiguration *config = [[RLMRealmConfiguration alloc] init];
config.syncConfiguration = syncConfig;
return config;
}
- (void)logOut {
if (!_user) {
return;
......
......@@ -42,7 +42,6 @@ Usage: sh $0 command [argument]
command:
clean: clean up/remove all generated files
download-core: downloads core library (binary version)
download-object-server: downloads and installs the Realm Object Server
download-sync: downloads sync library (binary version, core+sync)
build: builds all iOS and OS X frameworks
ios-static: builds fat iOS static framework
......@@ -124,6 +123,11 @@ xc() {
fi
}
xctest() {
xc "$@" build
xc "$@" test
}
copy_bcsymbolmap() {
find "$1" -name '*.bcsymbolmap' -type f -exec cp {} "$2" \;
}
......@@ -304,26 +308,6 @@ fi
# Downloading
######################################
kill_object_server() {
set +e
# Based on build.sh conventions we always run ROS from a path ending in 'ros/bin/ros'.
pkill -f ros/bin/ros\ start
# 0 = process killed, 1 = no processes running, 2+ = error
local status=$?
if [ $status -gt 1 ]; then
exit $status
fi
set -e
}
download_object_server() {
rm -rf ./test-ros-instance
mkdir -p ./test-ros-instance/ros
chmod 777 ./test-ros-instance
/usr/local/bin/node /usr/local/bin/npm install --scripts-prepend-node-path=auto --prefix ./test-ros-instance/ros \
-g realm-object-server@${REALM_OBJECT_SERVER_VERSION}
}
download_common() {
local download_type=$1 tries_left=3 version url error temp_dir temp_path tar_path
......@@ -421,38 +405,6 @@ case "$COMMAND" in
exit 0
;;
######################################
# Object Server
######################################
"download-object-server")
download_object_server
exit 0
;;
"reset-ros-server-state")
rm -rf "./test-ros-instance/data"
rm -rf "./test-ros-instance/realm-object-server"
exit 0
;;
"reset-ros-client-state")
rm -rf ~/Library/Application\ Support/xctest
rm -rf ~/Library/Application\ Support/io.realm.TestHost
rm -rf ~/Library/Application\ Support/xctest-child
exit 0
;;
"reset-object-server")
kill_object_server
# Add a short delay, so file system doesn't complain about files in use
sleep 1
sh build.sh reset-ros-server-state
sh build.sh reset-ros-client-state
# Add another delay to ensure files are actually gone from file system
sleep 1
exit 0
;;
######################################
# Core
######################################
......@@ -678,7 +630,7 @@ case "$COMMAND" in
else
destination="Apple TV 1080p"
fi
xc "-scheme Realm -configuration $CONFIGURATION -sdk appletvsimulator -destination 'name=$destination' test"
xctest "-scheme Realm -configuration $CONFIGURATION -sdk appletvsimulator -destination 'name=$destination'"
exit $?
;;
......@@ -688,7 +640,7 @@ case "$COMMAND" in
else
destination="Apple TV 1080p"
fi
xc "-scheme RealmSwift -configuration $CONFIGURATION -sdk appletvsimulator -destination 'name=$destination' test"
xctest "-scheme RealmSwift -configuration $CONFIGURATION -sdk appletvsimulator -destination 'name=$destination'"
exit $?
;;
......@@ -701,17 +653,17 @@ case "$COMMAND" in
if [[ "$CONFIGURATION" == "Debug" ]]; then
COVERAGE_PARAMS="GCC_GENERATE_TEST_COVERAGE_FILES=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES"
fi
xc "-scheme Realm -configuration $CONFIGURATION test $COVERAGE_PARAMS"
xctest "-scheme Realm -configuration $CONFIGURATION $COVERAGE_PARAMS"
exit 0
;;
"test-osx-swift")
xc "-scheme RealmSwift -configuration $CONFIGURATION test"
xctest "-scheme RealmSwift -configuration $CONFIGURATION"
exit 0
;;
"test-osx-object-server")
xc "-scheme 'Object Server Tests' -configuration $CONFIGURATION -sdk macosx test"
xctest "-scheme 'Object Server Tests' -configuration $CONFIGURATION -sdk macosx"
exit 0
;;
......@@ -849,9 +801,7 @@ case "$COMMAND" in
;;
"verify-osx-object-server")
sh build.sh download-object-server
sh build.sh test-osx-object-server
sh build.sh reset-object-server
exit 0
;;
......@@ -1079,6 +1029,8 @@ EOM
"ci-pr")
mkdir -p build/reports
export REALM_DISABLE_ANALYTICS=1
export REALM_DISABLE_UPDATE_CHECKER=1
# FIXME: Re-enable once CI can properly unlock the keychain
export REALM_DISABLE_METADATA_ENCRYPTION=1
......@@ -1098,6 +1050,9 @@ EOM
export REALM_EXTRA_BUILD_ARGUMENTS='GCC_GENERATE_DEBUGGING_SYMBOLS=NO REALM_PREFIX_HEADER=Realm/RLMPrefix.h'
sh build.sh prelaunch-simulator
source $(brew --prefix nvm)/nvm.sh
export REALM_NODE_PATH="$(nvm which 8)"
# Reset CoreSimulator.log
mkdir -p ~/Library/Logs/CoreSimulator
echo > ~/Library/Logs/CoreSimulator/CoreSimulator.log
......
......@@ -20,7 +20,7 @@
#import "RLMRealm.h"
@class RLMResults;
@class RLMResults, RLMSyncSession;
/**
A callback used to vend the results of a partial sync fetch.
......@@ -45,6 +45,12 @@ NS_ASSUME_NONNULL_BEGIN
- (void)subscribeToObjects:(Class)type where:(NSString *)query callback:(RLMPartialSyncFetchCallback)callback
__deprecated_msg("Use -[RLMResults subscribe]");
/**
Get the RLMSyncSession used by this Realm. Will be nil if this is not a
synchronized Realm.
*/
@property (nonatomic, nullable, readonly) RLMSyncSession *syncSession;
@end
NS_ASSUME_NONNULL_END
......@@ -54,12 +54,23 @@ NS_ASSUME_NONNULL_BEGIN
except those matching queries that the user explicitly specifies.
@warning Partial synchronization is a tech preview. Its APIs are subject to change.
*/
@property (nonatomic) BOOL isPartial;
*/
@property (nonatomic) BOOL isPartial DEPRECATED_MSG_ATTRIBUTE("Use 'fullSynchronization' instead.");
/**
Whether this Realm should be a fully synchronized Realm.
Synchronized Realms comes in two flavors: Query-based and Fully synchronized.
A fully synchronized Realm will automatically synchronize the entire Realm in
the background while a query-based Realm will only synchronize the data being
subscribed to. Synchronized realms are by default query-based unless this
boolean is set.
*/
@property (nonatomic) BOOL fullSynchronization;
/**
The prefix that is prepended to the path in the HTTP request
that initiates a sync connection. The value specified must match with the server's expectation.
The prefix that is prepended to the path in the HTTP request that initiates a
sync connection. The value specified must match with the server's expectation.
Changing the value of `urlPrefix` should be matched with a corresponding
change of the server's configuration.
If no value is specified here then the default `/realm-sync` path is used.
......@@ -75,21 +86,21 @@ NS_ASSUME_NONNULL_BEGIN
contain the wildcard marker `~`, which will automatically be filled in with
the user identity by the Realm Object Server.
*/
- (instancetype)initWithUser:(RLMSyncUser *)user realmURL:(NSURL *)url;
- (instancetype)initWithUser:(RLMSyncUser *)user realmURL:(NSURL *)url __attribute__((deprecated("Use [RLMSyncUser configurationWithURL] instead")));
/**
Return a Realm configuration for syncing with the default Realm of the currently logged-in sync user.
Partial synchronization is enabled in the returned configuration.
*/
+ (RLMRealmConfiguration *)automaticConfiguration;
+ (RLMRealmConfiguration *)automaticConfiguration __attribute__((deprecated("Use [RLMSyncUser configuration] instead")));
/**
Return a Realm configuration for syncing with the default Realm of the given sync user.
Partial synchronization is enabled in the returned configuration.
*/
+ (RLMRealmConfiguration *)automaticConfigurationForUser:(RLMSyncUser *)user;
+ (RLMRealmConfiguration *)automaticConfigurationForUser:(RLMSyncUser *)user __attribute__((deprecated("Use [RLMSyncUser configuration] instead")));
/// :nodoc:
- (instancetype)init __attribute__((unavailable("This type cannot be created directly")));
......
......@@ -28,6 +28,13 @@ typedef NS_ENUM(NSUInteger, RLMSyncStopPolicy) {
@interface RLMSyncConfiguration ()
- (instancetype)initWithUser:(RLMSyncUser *)user
realmURL:(NSURL *)url
isPartial:(BOOL)isPartial
urlPrefix:(nullable NSString *)urlPrefix
stopPolicy:(RLMSyncStopPolicy)stopPolicy
enableSSLValidation:(BOOL)enableSSLValidation;
@property (nonatomic, readwrite) RLMSyncStopPolicy stopPolicy;
// Internal-only APIs
......
......@@ -18,14 +18,31 @@
#import "RLMSyncConfiguration_Private.h"
#import <functional>
#import <memory>
namespace realm {
class SyncSession;
struct SyncConfig;
struct SyncError;
using SyncSessionErrorHandler = void(std::shared_ptr<SyncSession>, SyncError);
}
NS_ASSUME_NONNULL_BEGIN
@interface RLMSyncConfiguration ()
- (instancetype)initWithUser:(RLMSyncUser *)user
realmURL:(NSURL *)url
customFileURL:(nullable NSURL *)customFileURL
isPartial:(BOOL)isPartial
stopPolicy:(RLMSyncStopPolicy)stopPolicy
errorHandler:(std::function<realm::SyncSessionErrorHandler>)errorHandler;
- (instancetype)initWithRawConfig:(realm::SyncConfig)config;
- (realm::SyncConfig)rawConfiguration;
@end
NS_ASSUME_NONNULL_END
......@@ -18,6 +18,7 @@
#import <Foundation/Foundation.h>
#import "RLMRealmConfiguration.h"
#import "RLMResults.h"
#import "RLMSyncCredentials.h"
#import "RLMSyncPermission.h"
......@@ -145,6 +146,64 @@ NS_ASSUME_NONNULL_BEGIN
onCompletion:(RLMUserCompletionBlock)completion
NS_SWIFT_UNAVAILABLE("Use the full version of this API.");
/**
Returns the default configuration for the user. The default configuration
points to the default query-based Realm on the server the user authenticated against.
*/
- (RLMRealmConfiguration *)configuration NS_REFINED_FOR_SWIFT;
/**
Create a query-based configuration instance for the given url.
@param url The unresolved absolute URL to the Realm on the Realm Object Server,
e.g. "realm://example.org/~/path/to/realm". "Unresolved" means the
path should contain the wildcard marker `~`, which will automatically
be filled in with the user identity by the Realm Object Server.
@return A default configuration object with the sync configuration set to use the given URL.
*/
- (RLMRealmConfiguration *)configurationWithURL:(nullable NSURL *)url NS_REFINED_FOR_SWIFT;
/**
Create a configuration instance for the given url.
@param url The unresolved absolute URL to the Realm on the Realm Object Server,
e.g. "realm://example.org/~/path/to/realm". "Unresolved" means the
path should contain the wildcard marker `~`, which will automatically
be filled in with the user identity by the Realm Object Server.
@param fullSynchronization If YES, all objects in the server Realm are
automatically synchronized, and the query subscription
methods cannot be used.
@return A default configuration object with the sync configuration set to use
the given URL and options.
*/
- (RLMRealmConfiguration *)configurationWithURL:(nullable NSURL *)url
fullSynchronization:(bool)fullSynchronization NS_REFINED_FOR_SWIFT;
/**
Create a configuration instance for the given url.
@param url The unresolved absolute URL to the Realm on the Realm Object Server,
e.g. "realm://example.org/~/path/to/realm". "Unresolved" means the
path should contain the wildcard marker `~`, which will automatically
be filled in with the user identity by the Realm Object Server.
@param fullSynchronization If YES, all objects in the server Realm are
automatically synchronized, and the query subscription
methods cannot be used.
@param enableSSLValidation If NO, invalid SSL certificates for the server will
not be rejected. THIS SHOULD NEVER BE USED IN
PRODUCTION AND EXISTS ONLY FOR TESTING PURPOSES.
@param urlPrefix A prefix which is prepending to URLs constructed for
the server. This should normally be `nil`, and customized only
to match corresponding settings on the server.
@return A default configuration object with the sync configuration set to use
the given URL and options.
*/
- (RLMRealmConfiguration *)configurationWithURL:(nullable NSURL *)url
fullSynchronization:(bool)fullSynchronization
enableSSLValidation:(bool)enableSSLValidation
urlPrefix:(nullable NSString *)urlPrefix NS_REFINED_FOR_SWIFT;
/**
Log a user out, destroying their server state, unregistering them from the SDK,
and removing any synced Realms associated with them from on-disk storage on
......
......@@ -34,7 +34,6 @@ extension Realm {
```
*/
public struct Error {
// swiftlint:disable:next nesting
public typealias Code = RLMError.Code
/// Error thrown by Realm if no other specific error is returned when a realm is opened.
......@@ -84,7 +83,7 @@ extension Realm {
}
/// :nodoc:
public var _nsError: NSError
public let _nsError: NSError
/// :nodoc:
public init(_nsError error: NSError) {
......@@ -105,7 +104,9 @@ extension Realm {
// Provide bridging from errors with domain RLMErrorDomain to Error.
extension Realm.Error: _BridgedStoredNSError {
/// :nodoc:
public static var _nsErrorDomain = RLMErrorDomain
public static let _nsErrorDomain = RLMErrorDomain
/// :nodoc:
public static let errorDomain = RLMErrorDomain
}
// MARK: Equatable
......
......@@ -481,6 +481,24 @@ extension List: RealmCollection {
return RLMIterator(collection: _rlmArray)
}
#if swift(>=4)
/**
Replace the given `subRange` of elements with `newElements`.
- parameter subrange: The range of elements to be replaced.
- parameter newElements: The new elements to be inserted into the List.
*/
public func replaceSubrange<C: Collection, R>(_ subrange: R, with newElements: C)
where C.Iterator.Element == Element, R: RangeExpression, List<Element>.Index == R.Bound {
let subrange = subrange.relative(to: self)
for _ in subrange.lowerBound..<subrange.upperBound {
remove(at: subrange.lowerBound)
}
for x in newElements.reversed() {
insert(x, at: subrange.lowerBound)
}