diff --git a/.gitignore b/.gitignore index b69af7f495..db59c57734 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ xcuserdata/ project.xcworkspace *.xccheckout DerivedData +/.build # AppCode .idea/ @@ -111,3 +112,7 @@ examples/ios/objc/Draw/Constants.h ## Sync testing test-ros-instance Realm/ObjectServerTests/node_modules + +## Swiftpm +.swiftpm +.build diff --git a/.jenkins.yml b/.jenkins.yml index 8f4655f0ed..666b732450 100644 --- a/.jenkins.yml +++ b/.jenkins.yml @@ -23,6 +23,7 @@ target: - tvos - osx-encryption - osx-object-server + - swiftpm # These are disabled because the machinen with the devices attached is currently offline # - ios-device-objc-ios8 @@ -38,26 +39,26 @@ configuration: # Combinations have to be excluded in a way that's hard to read. # This table shows which jobs will run: -# +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -# | Configuration Matrix | osx | docs | ios-static | ios-dynamic | ios-swift | osx-swift | watchos | cocoapods-ios | cocoapods-osx | cocoapods-watchos | swiftlint | tvos | osx-encryption | osx-object-server | ios-device-objc-ios8 | ios-device-swift-ios8 | ios-device-objc-ios10 | ios-device-swift-ios10 | tvos-device | -# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- | -# | 9.2 | Debug | X | | X | | | | | | | | | | | | | | | | | -# | 9.2 | Release | X | | X | X | X | X | X | X | X | X | | X | X | X | X | | X | | | -# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- | -# | 9.3 | Debug | X | | | | | | | | | | | | | | | | | | | -# | 9.3 | Release | X | | X | X | X | X | X | X | X | X | | X | | | | | | | | -# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- | -# | 9.4 | Debug | X | | | | | | | | | | | | | | | | | | | -# | 9.4 | Release | X | | X | X | X | X | X | X | X | X | | X | | | | | | | | -# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- | -# | 10.0 | Debug | X | | | | | | | | | | | | | | | | | | | -# | 10.0 | Release | X | | X | X | X | X | X | X | X | X | | X | | | | | | | | -# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- | -# | 10.1 | Debug | X | | | | | | | | | | | | | | | | | | | -# | 10.1 | Release | X | | X | X | X | X | X | X | X | X | | X | | | | | | | | -# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- | -# | 10.2.1| Debug | X | | | X | X | X | X | | | | | X | | | | | | | | -# | 10.2.1| Release | X | X | X | X | X | X | X | X | X | X | X | X | X | X | | | X | | X | +# +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +# | Configuration Matrix | osx | docs | ios-static | ios-dynamic | ios-swift | osx-swift | watchos | cocoapods-ios | cocoapods-osx | cocoapods-watchos | swiftlint | swiftpm | tvos | osx-encryption | osx-object-server | ios-device-objc-ios8 | ios-device-swift-ios8 | ios-device-objc-ios10 | ios-device-swift-ios10 | tvos-device | +# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- | +# | 9.2 | Debug | X | | X | | | | | | | | | | | | | | | | | | +# | 9.2 | Release | X | | X | X | X | X | X | X | X | X | | | X | X | X | X | | X | | | +# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- | +# | 9.3 | Debug | X | | | | | | | | | | | | | | | | | | | | +# | 9.3 | Release | X | | X | X | X | X | X | X | X | X | | | X | | | | | | | | +# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- | +# | 9.4 | Debug | X | | | | | | | | | | | | | | | | | | | | +# | 9.4 | Release | X | | X | X | X | X | X | X | X | X | | | X | | | | | | | | +# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- | +# | 10.0 | Debug | X | | | | | | | | | | | | | | | | | | | | +# | 10.0 | Release | X | | X | X | X | X | X | X | X | X | | | X | | | | | | | | +# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- | +# | 10.1 | Debug | X | | | | | | | | | | | | | | | | | | | | +# | 10.1 | Release | X | | X | X | X | X | X | X | X | X | | | X | | | | | | | | +# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- | +# | 10.2.1| Debug | X | | | X | X | X | X | | | | | | X | | | | | | | | +# | 10.2.1| Release | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | | | X | | X | # +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ exclude: @@ -206,6 +207,23 @@ exclude: - target: swiftlint configuration: Debug + ################ + # swiftpm + ################ + # Just run on 10.2 Release + - xcode_version: 9.2 + target: swiftpm + - xcode_version: 9.3 + target: swiftpm + - xcode_version: 9.4 + target: swiftpm + - xcode_version: 10.0 + target: swiftpm + - xcode_version: 10.1 + target: swiftpm + - target: swiftpm + configuration: Debug + ################ # tvos ################ diff --git a/CHANGELOG.md b/CHANGELOG.md index ee56bb8565..3a549a6a3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ x.y.z Release notes (yyyy-MM-dd) ============================================================= ### Enhancements -* None. +* Add support for including Realm via Swift Package Manager. ### Fixed * ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?) diff --git a/Configuration/Realm/Tests iOS static.xcconfig b/Configuration/Realm/Tests iOS static.xcconfig index bf077eab02..c9351017ab 100644 --- a/Configuration/Realm/Tests iOS static.xcconfig +++ b/Configuration/Realm/Tests iOS static.xcconfig @@ -1,6 +1,7 @@ #include "Tests.xcconfig" CONFIGURATION_BUILD_DIR = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)-static; +CONFIGURATION_TEMP_DIR = $(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)-static; IPHONEOS_DEPLOYMENT_TARGET = 8.0; -TEST_HOST[sdk=iphone*] = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/TestHost.app/TestHost; +TEST_HOST[sdk=iphone*] = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)-static/TestHost static.app/TestHost static; diff --git a/Configuration/TestHost-static.xcconfig b/Configuration/TestHost-static.xcconfig new file mode 100644 index 0000000000..210e047a9d --- /dev/null +++ b/Configuration/TestHost-static.xcconfig @@ -0,0 +1,4 @@ +#include "TestHost.xcconfig" + +CONFIGURATION_BUILD_DIR = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)-static; +CONFIGURATION_TEMP_DIR = $(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)-static; diff --git a/Configuration/TestHost.xcconfig b/Configuration/TestHost.xcconfig index 6b69c0580a..d8b905a3b6 100644 --- a/Configuration/TestHost.xcconfig +++ b/Configuration/TestHost.xcconfig @@ -1,5 +1,6 @@ SUPPORTED_PLATFORMS = macosx iphonesimulator iphoneos appletvos appletvsimulator; +CODE_SIGN_IDENTITY = "-"; COPY_PHASE_STRIP = NO; LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/Frameworks; INFOPLIST_FILE = Realm/Tests/TestHost/Info.plist; diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000000..adfc0224a8 --- /dev/null +++ b/Package.swift @@ -0,0 +1,132 @@ +// swift-tools-version:5.0 + +import PackageDescription +import Foundation + +let coreVersionStr = "5.20.0" +let cocoaVersionStr = "3.16.2" + +let coreVersionPieces = coreVersionStr.split(separator: ".") +let cxxSettings: [CXXSetting] = [ + .headerSearchPath("."), + .headerSearchPath("include"), + .headerSearchPath("Realm/ObjectStore/src"), + .define("REALM_SPM", to: "1"), + .define("REALM_COCOA_VERSION", to: "@\"\(cocoaVersionStr)\""), + .define("REALM_VERSION", to: "\"\(coreVersionStr)\""), + + .define("REALM_NO_CONFIG"), + .define("REALM_INSTALL_LIBEXECDIR", to: ""), + .define("REALM_ENABLE_ASSERTIONS", to: "1"), + .define("REALM_ENABLE_ENCRYPTION", to: "1"), + + .define("REALM_VERSION_MAJOR", to: String(coreVersionPieces[0])), + .define("REALM_VERSION_MINOR", to: String(coreVersionPieces[1])), + .define("REALM_VERSION_PATCH", to: String(coreVersionPieces[2])), + .define("REALM_VERSION_EXTRA", to: "\"\""), + .define("REALM_VERSION_STRING", to: "\"\(coreVersionStr)\""), +] + +let package = Package( + name: "Realm", + products: [ + .library( + name: "Realm", + targets: ["Realm"]), + .library( + name: "RealmSwift", + targets: ["Realm", "RealmSwift"]), + ], + dependencies: [ + .package(url: "https://github.com/realm/realm-core", .branch("master")), + ], + targets: [ + .target( + name: "Realm", + dependencies: ["RealmCore"], + path: ".", + exclude: [ + "Realm/NSError+RLMSync.m", + "Realm/RLMJSONModels.m", + "Realm/RLMNetworkClient.mm", + "Realm/RLMRealm+Sync.mm", + "Realm/RLMRealmConfiguration+Sync.mm", + "Realm/RLMSyncConfiguration.mm", + "Realm/RLMSyncCredentials.m", + "Realm/RLMSyncManager.mm", + "Realm/RLMSyncPermission.mm", + "Realm/RLMSyncPermissionResults.mm", + "Realm/RLMSyncSession.mm", + "Realm/RLMSyncSessionRefreshHandle.mm", + "Realm/RLMSyncSubscription.mm", + "Realm/RLMSyncUser.mm", + "Realm/RLMSyncUtil.mm", + + "Realm/ObjectServerTests", + "Realm/Swift", + "Realm/Tests", + "Realm/TestUtils", + "Realm/ObjectStore/external", + "Realm/ObjectStore/tests", + "Realm/ObjectStore/src/server", + "Realm/ObjectStore/src/sync", + "Realm/ObjectStore/src/impl/generic", + "Realm/ObjectStore/src/impl/epoll", + "Realm/ObjectStore/src/impl/android", + "Realm/ObjectStore/src/impl/windows", + ], + sources: ["Realm"], + publicHeadersPath: "include", + cxxSettings: cxxSettings + ), + .target( + name: "RealmSwift", + dependencies: ["Realm"], + path: "RealmSwift", + exclude: [ + "Sync.swift", + "ObjectiveCSupport+Sync.swift", + "Tests", + ] + ), + .target( + name: "RealmTestSupport", + dependencies: ["Realm"], + path: "Realm/TestUtils", + cxxSettings: cxxSettings + [ + // Command-line `swift build` resolves header search paths + // relative to the package root, while Xcode resolves them + // relative to the target root, so we need both. + .headerSearchPath("Realm"), + .headerSearchPath(".."), + ] + ), + .testTarget( + name: "RealmTests", + dependencies: ["Realm", "RealmTestSupport"], + path: "Realm/Tests", + exclude: [ + "Swift", + "TestHost", + "PrimitiveArrayPropertyTests.tpl.m", + ], + cxxSettings: cxxSettings + [ + .headerSearchPath("Realm"), + .headerSearchPath(".."), + .headerSearchPath("../ObjectStore/src"), + ] + ), + .testTarget( + name: "RealmObjcSwiftTests", + dependencies: ["Realm", "RealmTestSupport"], + path: "Realm/Tests/Swift" + ), + .testTarget( + name: "RealmSwiftTests", + dependencies: ["RealmSwift", "RealmTestSupport"], + path: "RealmSwift/Tests", + exclude: ["TestUtils.mm"] + ) + ], + cxxLanguageStandard: .cxx14 +) diff --git a/Realm.xcodeproj/project.pbxproj b/Realm.xcodeproj/project.pbxproj index a7b80dfc48..bc5335c57b 100644 --- a/Realm.xcodeproj/project.pbxproj +++ b/Realm.xcodeproj/project.pbxproj @@ -42,9 +42,6 @@ 021A88361AAFB5CD00EEAC84 /* ObjectSchemaTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 021A88301AAFB5BE00EEAC84 /* ObjectSchemaTests.m */; }; 021A88371AAFB5CE00EEAC84 /* ObjectSchemaTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 021A88301AAFB5BE00EEAC84 /* ObjectSchemaTests.m */; }; 027A4D2C1AB1012500AA46F9 /* InterprocessTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 027A4D291AB1012500AA46F9 /* InterprocessTests.m */; }; - 027A4D2D1AB1012500AA46F9 /* RLMMultiProcessTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 027A4D2B1AB1012500AA46F9 /* RLMMultiProcessTestCase.m */; }; - 028481CB19CCFC9C0097A416 /* RLMTestObjects.m in Sources */ = {isa = PBXBuildFile; fileRef = E81A1FC71955FE0100FDED82 /* RLMTestObjects.m */; }; - 028481EF19CD032C0097A416 /* RLMTestObjects.m in Sources */ = {isa = PBXBuildFile; fileRef = E81A1FC71955FE0100FDED82 /* RLMTestObjects.m */; }; 02AFB4631A80343600E11938 /* PropertyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 02AFB4611A80343600E11938 /* PropertyTests.m */; }; 02AFB4641A80343600E11938 /* PropertyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 02AFB4611A80343600E11938 /* PropertyTests.m */; }; 02AFB4671A80343600E11938 /* ResultsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 02AFB4621A80343600E11938 /* ResultsTests.m */; }; @@ -68,7 +65,6 @@ 1A1536761DB0464F00C0EC93 /* sync_file.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A15366D1DB0464800C0EC93 /* sync_file.cpp */; }; 1A1536771DB0465400C0EC93 /* sync_metadata.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A15366F1DB0464800C0EC93 /* sync_metadata.cpp */; }; 1A2713D71E3BBAC8001F6BFC /* RLMAncillaryObjectServerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A2713D51E3BBAC4001F6BFC /* RLMAncillaryObjectServerTests.m */; }; - 1A2D7A521DA5BCEC006AD7D6 /* RLMMultiProcessTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 027A4D2B1AB1012500AA46F9 /* RLMMultiProcessTestCase.m */; }; 1A33C4301DAEE445001E87AA /* RLMSyncSessionRefreshHandle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A33C42D1DAEE445001E87AA /* RLMSyncSessionRefreshHandle.mm */; }; 1A33C4311DAEE445001E87AA /* RLMSyncSessionRefreshHandle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A33C42D1DAEE445001E87AA /* RLMSyncSessionRefreshHandle.mm */; }; 1A3623681D8384BA00945A54 /* RLMSyncConfiguration.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A3623661D8384BA00945A54 /* RLMSyncConfiguration.mm */; }; @@ -127,7 +123,6 @@ 1AFEF8431D52D2C900495005 /* Sync.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A7DE7021D38460B0029F0AE /* Sync.swift */; }; 2973CCF91C175AB400FEA0FA /* fileformat-pre-null.realm in Resources */ = {isa = PBXBuildFile; fileRef = 29B7FDF71C0DE76B0023224E /* fileformat-pre-null.realm */; }; 297FBEFB1C19F696009D1118 /* RLMTestCaseUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297FBEFA1C19F696009D1118 /* RLMTestCaseUtils.swift */; }; - 297FBEFF1C19F844009D1118 /* TestUtils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 297FBEFE1C19F844009D1118 /* TestUtils.mm */; }; 29B7FDF61C0DA6560023224E /* Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29B7FDF51C0DA6560023224E /* Error.swift */; }; 29B7FDFB1C0DE8100023224E /* fileformat-pre-null.realm in Resources */ = {isa = PBXBuildFile; fileRef = 29B7FDF71C0DE76B0023224E /* fileformat-pre-null.realm */; }; 29B7FDFC1C0DE8110023224E /* fileformat-pre-null.realm in Resources */ = {isa = PBXBuildFile; fileRef = 29B7FDF71C0DE76B0023224E /* fileformat-pre-null.realm */; }; @@ -143,7 +138,22 @@ 3F336E8A1DA2FA14006CB5A0 /* RLMSyncConfiguration_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A36236A1D83868F00945A54 /* RLMSyncConfiguration_Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3F336E8B1DA2FA15006CB5A0 /* RLMSyncConfiguration_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A36236A1D83868F00945A54 /* RLMSyncConfiguration_Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3F4657371F27F2EF00456B07 /* RLMTestCaseUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297FBEFA1C19F696009D1118 /* RLMTestCaseUtils.swift */; }; - 3F4657381F27F35600456B07 /* TestUtils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 297FBEFE1C19F844009D1118 /* TestUtils.mm */; }; + 3F558C8722C29A03002F0F30 /* TestUtils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C7E22C29A02002F0F30 /* TestUtils.mm */; }; + 3F558C8822C29A03002F0F30 /* TestUtils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C7E22C29A02002F0F30 /* TestUtils.mm */; }; + 3F558C8922C29A03002F0F30 /* TestUtils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C7E22C29A02002F0F30 /* TestUtils.mm */; }; + 3F558C8A22C29A03002F0F30 /* TestUtils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C7E22C29A02002F0F30 /* TestUtils.mm */; }; + 3F558C8B22C29A03002F0F30 /* RLMTestObjects.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C8222C29A02002F0F30 /* RLMTestObjects.m */; }; + 3F558C8C22C29A03002F0F30 /* RLMTestObjects.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C8222C29A02002F0F30 /* RLMTestObjects.m */; }; + 3F558C8D22C29A03002F0F30 /* RLMTestObjects.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C8222C29A02002F0F30 /* RLMTestObjects.m */; }; + 3F558C8E22C29A03002F0F30 /* RLMTestObjects.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C8222C29A02002F0F30 /* RLMTestObjects.m */; }; + 3F558C8F22C29A03002F0F30 /* RLMTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C8322C29A02002F0F30 /* RLMTestCase.m */; }; + 3F558C9022C29A03002F0F30 /* RLMTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C8322C29A02002F0F30 /* RLMTestCase.m */; }; + 3F558C9122C29A03002F0F30 /* RLMTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C8322C29A02002F0F30 /* RLMTestCase.m */; }; + 3F558C9222C29A03002F0F30 /* RLMTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C8322C29A02002F0F30 /* RLMTestCase.m */; }; + 3F558C9322C29A03002F0F30 /* RLMMultiProcessTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C8522C29A03002F0F30 /* RLMMultiProcessTestCase.m */; }; + 3F558C9422C29A03002F0F30 /* RLMMultiProcessTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C8522C29A03002F0F30 /* RLMMultiProcessTestCase.m */; }; + 3F558C9622C29A03002F0F30 /* RLMMultiProcessTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C8522C29A03002F0F30 /* RLMMultiProcessTestCase.m */; }; + 3F558CA022C29CAF002F0F30 /* RealmTestSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F558C9E22C29CAF002F0F30 /* RealmTestSupport.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3F572C941F2BDAAB00F6C9AB /* ThreadSafeReferenceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F572C911F2BDA9F00F6C9AB /* ThreadSafeReferenceTests.m */; }; 3F572C951F2BDAAC00F6C9AB /* ThreadSafeReferenceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F572C911F2BDA9F00F6C9AB /* ThreadSafeReferenceTests.m */; }; 3F572C961F2BDAB100F6C9AB /* PrimitiveArrayPropertyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F572C901F2BDA9F00F6C9AB /* PrimitiveArrayPropertyTests.m */; }; @@ -233,9 +243,11 @@ 3FB60BAD2040999300583735 /* SwiftPermissionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FB60BAC2040999300583735 /* SwiftPermissionsTests.swift */; }; 3FBEF67B1C63D66100F6935B /* RLMCollection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3FBEF6791C63D66100F6935B /* RLMCollection.mm */; }; 3FBEF67C1C63D66400F6935B /* RLMCollection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3FBEF6791C63D66100F6935B /* RLMCollection.mm */; }; - 3FC767071BB9FE7500FE0AFC /* RLMMultiProcessTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 027A4D2B1AB1012500AA46F9 /* RLMMultiProcessTestCase.m */; }; 3FDCFEB619F6A8D3005E414A /* RLMSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = E88C36FF19745E5500C9963D /* RLMSupport.swift */; }; 3FDE338D19C39A87003B7DBA /* RLMSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = E88C36FF19745E5500C9963D /* RLMSupport.swift */; }; + 3FE5818622C2B4B900BA10E7 /* ObjectiveCSupport+Sync.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FE5818422C2B4B900BA10E7 /* ObjectiveCSupport+Sync.swift */; }; + 3FE5818A22C2CA2E00BA10E7 /* RealmTestSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F558C9E22C29CAF002F0F30 /* RealmTestSupport.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3FE5819622C2CCA700BA10E7 /* RLMMultiProcessTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F558C8522C29A03002F0F30 /* RLMMultiProcessTestCase.m */; }; 3FEB383F1E70AC8800F22712 /* ObjectCreationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3FEB383C1E70AC6900F22712 /* ObjectCreationTests.mm */; }; 3FEB38401E70AC8800F22712 /* ObjectCreationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3FEB383C1E70AC6900F22712 /* ObjectCreationTests.mm */; }; 3FEC4A3F1BBB18D400F009C3 /* SwiftSchemaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FEC4A3D1BBB188B00F009C3 /* SwiftSchemaTests.swift */; }; @@ -342,7 +354,6 @@ 5D6610161BE98D880021E04F /* ListTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D6610001BE98D880021E04F /* ListTests.swift */; }; 5D6610251BE98D880021E04F /* SwiftTestObjects.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D6610101BE98D880021E04F /* SwiftTestObjects.swift */; }; 5D6610271BE98D880021E04F /* TestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D6610121BE98D880021E04F /* TestCase.swift */; }; - 5D6610281BE98D880021E04F /* TestUtils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5D6610141BE98D880021E04F /* TestUtils.mm */; }; 5D66102A1BE98DD00021E04F /* Realm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D659ED91BE04556006515A0 /* Realm.framework */; }; 5D66102E1BE98E500021E04F /* Realm.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 5D659ED91BE04556006515A0 /* Realm.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 5D66102F1BE98E540021E04F /* RealmSwift.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 5D660FCC1BE98C560021E04F /* RealmSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -432,7 +443,6 @@ E81A1FE31955FE0100FDED82 /* ObjectTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E81A1FBF1955FE0100FDED82 /* ObjectTests.m */; settings = {COMPILER_FLAGS = "-fobjc-arc-exceptions"; }; }; E81A1FE71955FE0100FDED82 /* QueryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E81A1FC11955FE0100FDED82 /* QueryTests.m */; }; E81A1FEB1955FE0100FDED82 /* RealmTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = E81A1FC31955FE0100FDED82 /* RealmTests.mm */; }; - E81A1FEE1955FE0100FDED82 /* RLMTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = E81A1FC51955FE0100FDED82 /* RLMTestCase.m */; }; E81A20021955FE0100FDED82 /* TransactionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E81A1FD11955FE0100FDED82 /* TransactionTests.m */; }; E8267FE31D90B79000E001C7 /* Realm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D659ED91BE04556006515A0 /* Realm.framework */; }; E8267FE51D90B79000E001C7 /* Realm.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 5D659ED91BE04556006515A0 /* Realm.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -446,8 +456,6 @@ E856D21B195615A900FB2FCF /* ObjectTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E81A1FBF1955FE0100FDED82 /* ObjectTests.m */; }; E856D21D195615A900FB2FCF /* QueryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E81A1FC11955FE0100FDED82 /* QueryTests.m */; }; E856D21E195615A900FB2FCF /* RealmTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = E81A1FC31955FE0100FDED82 /* RealmTests.mm */; }; - E856D21F195615B100FB2FCF /* RLMTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = E81A1FC51955FE0100FDED82 /* RLMTestCase.m */; }; - E86E61241D91E4E200DC2419 /* RLMTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = E81A1FC51955FE0100FDED82 /* RLMTestCase.m */; }; E8917598197A1B350068ACC6 /* UnicodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E8917597197A1B350068ACC6 /* UnicodeTests.m */; }; E8917599197A1B350068ACC6 /* UnicodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E8917597197A1B350068ACC6 /* UnicodeTests.m */; }; E8AE7C261EA436F800CDFF9A /* CompactionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8AE7C251EA436F800CDFF9A /* CompactionTests.swift */; }; @@ -462,6 +470,20 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 3F558CA422C29DA6002F0F30 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = E8D89B8F1955FC6D00CF2B9A /* Project object */; + proxyType = 1; + remoteGlobalIDString = 3F558C9B22C29CAF002F0F30; + remoteInfo = RealmTestSupport; + }; + 3F558CA822C29DC5002F0F30 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = E8D89B8F1955FC6D00CF2B9A /* Project object */; + proxyType = 1; + remoteGlobalIDString = 3F558C9B22C29CAF002F0F30; + remoteInfo = RealmTestSupport; + }; 3F8F3578212B6FAE0035E7B8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = E8D89B8F1955FC6D00CF2B9A /* Project object */; @@ -497,6 +519,13 @@ remoteGlobalIDString = 3F1A5E711992EB7400F45F4C; remoteInfo = TestHost; }; + 3FE5819322C2CA6800BA10E7 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = E8D89B8F1955FC6D00CF2B9A /* Project object */; + proxyType = 1; + remoteGlobalIDString = 3FE5818822C2CA2E00BA10E7; + remoteInfo = "RealmTestSupport static"; + }; 5D6157011BE0A3A100A4BD3F /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = E8D89B8F1955FC6D00CF2B9A /* Project object */; @@ -626,8 +655,6 @@ 027A4D211AB100E000AA46F9 /* RLMRealmUtil.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RLMRealmUtil.hpp; sourceTree = ""; }; 027A4D221AB100E000AA46F9 /* RLMRealmUtil.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RLMRealmUtil.mm; sourceTree = ""; }; 027A4D291AB1012500AA46F9 /* InterprocessTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InterprocessTests.m; sourceTree = ""; }; - 027A4D2A1AB1012500AA46F9 /* RLMMultiProcessTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RLMMultiProcessTestCase.h; sourceTree = ""; }; - 027A4D2B1AB1012500AA46F9 /* RLMMultiProcessTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RLMMultiProcessTestCase.m; sourceTree = ""; }; 02AFB4611A80343600E11938 /* PropertyTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PropertyTests.m; sourceTree = ""; }; 02AFB4621A80343600E11938 /* ResultsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ResultsTests.m; sourceTree = ""; }; 02B8EF5819E601D80045A93D /* RLMResults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RLMResults.h; sourceTree = ""; }; @@ -709,8 +736,6 @@ 1AF7EA9A1D340E700001A9B5 /* RLMNetworkClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RLMNetworkClient.mm; sourceTree = ""; }; 26F3CA681986CC86004623E1 /* SwiftPropertyTypeTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftPropertyTypeTest.swift; sourceTree = ""; }; 297FBEFA1C19F696009D1118 /* RLMTestCaseUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RLMTestCaseUtils.swift; sourceTree = ""; }; - 297FBEFD1C19F844009D1118 /* TestUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestUtils.h; path = Realm/Tests/TestUtils.h; sourceTree = SOURCE_ROOT; }; - 297FBEFE1C19F844009D1118 /* TestUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestUtils.mm; path = Realm/Tests/TestUtils.mm; sourceTree = SOURCE_ROOT; }; 29B7FDF51C0DA6560023224E /* Error.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Error.swift; sourceTree = ""; }; 29B7FDF71C0DE76B0023224E /* fileformat-pre-null.realm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "fileformat-pre-null.realm"; sourceTree = ""; }; 29EDB8D71A7703C500458D80 /* RLMObjectStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RLMObjectStore.h; sourceTree = ""; }; @@ -736,9 +761,21 @@ 3F222C4D1E26F51300CA0713 /* ThreadSafeReference.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThreadSafeReference.swift; sourceTree = ""; }; 3F2633C21E9D630000B32D30 /* PrimitiveListTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrimitiveListTests.swift; sourceTree = ""; }; 3F2E66611CA0B9D5004761D5 /* NotificationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NotificationTests.m; sourceTree = ""; }; - 3F44109E19953F5900223146 /* RLMTestObjects.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RLMTestObjects.h; sourceTree = ""; }; + 3F35027722C43C5200FDC1E5 /* TestHost-static.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "TestHost-static.xcconfig"; sourceTree = ""; }; 3F452EC519C2279800AFC154 /* RLMSwiftSupport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RLMSwiftSupport.m; path = Realm/RLMSwiftSupport.m; sourceTree = SOURCE_ROOT; }; 3F4E324B1B98C6C700183A69 /* RLMSchema_Private.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = RLMSchema_Private.hpp; sourceTree = ""; }; + 3F558C7822BC022B002F0F30 /* subscription_state.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = subscription_state.hpp; path = sync/subscription_state.hpp; sourceTree = ""; }; + 3F558C7E22C29A02002F0F30 /* TestUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestUtils.mm; path = Realm/TestUtils/TestUtils.mm; sourceTree = ""; }; + 3F558C7F22C29A02002F0F30 /* RLMTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RLMTestCase.h; path = Realm/TestUtils/include/RLMTestCase.h; sourceTree = ""; }; + 3F558C8022C29A02002F0F30 /* RLMMultiProcessTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RLMMultiProcessTestCase.h; path = Realm/TestUtils/include/RLMMultiProcessTestCase.h; sourceTree = ""; }; + 3F558C8122C29A02002F0F30 /* RLMTestObjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RLMTestObjects.h; path = Realm/TestUtils/include/RLMTestObjects.h; sourceTree = ""; }; + 3F558C8222C29A02002F0F30 /* RLMTestObjects.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RLMTestObjects.m; path = Realm/TestUtils/RLMTestObjects.m; sourceTree = ""; }; + 3F558C8322C29A02002F0F30 /* RLMTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RLMTestCase.m; path = Realm/TestUtils/RLMTestCase.m; sourceTree = ""; }; + 3F558C8422C29A03002F0F30 /* RLMAssertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RLMAssertions.h; path = Realm/TestUtils/include/RLMAssertions.h; sourceTree = ""; }; + 3F558C8522C29A03002F0F30 /* RLMMultiProcessTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RLMMultiProcessTestCase.m; path = Realm/TestUtils/RLMMultiProcessTestCase.m; sourceTree = ""; }; + 3F558C8622C29A03002F0F30 /* TestUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestUtils.h; path = Realm/TestUtils/include/TestUtils.h; sourceTree = ""; }; + 3F558C9C22C29CAF002F0F30 /* RealmTestSupport.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RealmTestSupport.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 3F558C9E22C29CAF002F0F30 /* RealmTestSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RealmTestSupport.h; path = Realm/TestUtils/RealmTestSupport.h; sourceTree = ""; }; 3F572C901F2BDA9F00F6C9AB /* PrimitiveArrayPropertyTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrimitiveArrayPropertyTests.m; sourceTree = ""; }; 3F572C911F2BDA9F00F6C9AB /* ThreadSafeReferenceTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ThreadSafeReferenceTests.m; sourceTree = ""; }; 3F5B5D2E1E84230B00953B33 /* binding_callback_thread_observer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = binding_callback_thread_observer.cpp; sourceTree = ""; }; @@ -784,7 +821,6 @@ 3F9863B91D36876B00641C98 /* RLMClassInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RLMClassInfo.mm; sourceTree = ""; }; 3F9863BA1D36876B00641C98 /* RLMClassInfo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RLMClassInfo.hpp; sourceTree = ""; }; 3F9D91872152D42F00474F09 /* TestHost static.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "TestHost static.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - 3F9D91882152D42F00474F09 /* TestHost copy-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "TestHost copy-Info.plist"; path = "/src/realm-cocoa/TestHost copy-Info.plist"; sourceTree = ""; }; 3FAB08411E1EC382001BC8DA /* execution_context_id.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = execution_context_id.hpp; sourceTree = ""; }; 3FAB08421E1EC382001BC8DA /* object_accessor.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = object_accessor.hpp; sourceTree = ""; }; 3FAB08431E1EC382001BC8DA /* object.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = object.hpp; sourceTree = ""; }; @@ -807,6 +843,9 @@ 3FBEF6791C63D66100F6935B /* RLMCollection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RLMCollection.mm; sourceTree = ""; }; 3FE556421B9A43E5002A1129 /* schema.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = schema.cpp; sourceTree = ""; }; 3FE556431B9A43E5002A1129 /* schema.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = schema.hpp; sourceTree = ""; }; + 3FE5818322C2B4B900BA10E7 /* Nonsync.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Nonsync.swift; sourceTree = ""; }; + 3FE5818422C2B4B900BA10E7 /* ObjectiveCSupport+Sync.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ObjectiveCSupport+Sync.swift"; sourceTree = ""; }; + 3FE5819122C2CA2E00BA10E7 /* RealmTestSupport.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RealmTestSupport.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 3FE79FF719BA6A5900780C9A /* RLMSwiftSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RLMSwiftSupport.h; sourceTree = ""; }; 3FEB383C1E70AC6900F22712 /* ObjectCreationTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ObjectCreationTests.mm; sourceTree = ""; }; 3FEC4A3D1BBB188B00F009C3 /* SwiftSchemaTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftSchemaTests.swift; sourceTree = ""; }; @@ -871,8 +910,6 @@ 5D6610101BE98D880021E04F /* SwiftTestObjects.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftTestObjects.swift; sourceTree = ""; }; 5D6610111BE98D880021E04F /* SwiftUnicodeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftUnicodeTests.swift; sourceTree = ""; }; 5D6610121BE98D880021E04F /* TestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestCase.swift; sourceTree = ""; }; - 5D6610131BE98D880021E04F /* TestUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestUtils.h; sourceTree = ""; }; - 5D6610141BE98D880021E04F /* TestUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestUtils.mm; sourceTree = ""; }; 5DAD37231F73220C00EECA8E /* sync-1.x.realm */ = {isa = PBXFileReference; lastKnownFileType = file; name = "sync-1.x.realm"; path = "Realm/ObjectServerTests/sync-1.x.realm"; sourceTree = ""; }; 5DAD372D1F7485BB00EECA8E /* sync_config.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sync_config.cpp; path = sync/sync_config.cpp; sourceTree = ""; }; 5DB591A61D063DF8001D8F93 /* atomic_shared_ptr.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = atomic_shared_ptr.hpp; sourceTree = ""; }; @@ -889,7 +926,6 @@ C0D2DD051B6BDEA1004E8919 /* RLMRealmConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RLMRealmConfiguration.h; sourceTree = ""; }; C0D2DD061B6BDEA1004E8919 /* RLMRealmConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RLMRealmConfiguration.mm; sourceTree = ""; }; C0D2DD0F1B6BE0DD004E8919 /* RLMRealmConfiguration_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RLMRealmConfiguration_Private.h; sourceTree = ""; }; - C0D6E4101AFBFAF7001F3027 /* RLMAssertions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RLMAssertions.h; sourceTree = ""; }; C281E9241E8A9C930015BA4A /* network_reachability_observer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = network_reachability_observer.cpp; sourceTree = ""; }; C281E9251E8A9C930015BA4A /* network_reachability_observer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = network_reachability_observer.hpp; sourceTree = ""; }; C2CAAE721E9642FF0025454C /* network_reachability.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = network_reachability.hpp; path = sync/impl/network_reachability.hpp; sourceTree = ""; }; @@ -935,9 +971,6 @@ E81A1FC11955FE0100FDED82 /* QueryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QueryTests.m; sourceTree = ""; }; E81A1FC21955FE0100FDED82 /* RealmTests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "RealmTests-Info.plist"; sourceTree = ""; }; E81A1FC31955FE0100FDED82 /* RealmTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RealmTests.mm; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; - E81A1FC41955FE0100FDED82 /* RLMTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RLMTestCase.h; sourceTree = ""; }; - E81A1FC51955FE0100FDED82 /* RLMTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RLMTestCase.m; sourceTree = ""; }; - E81A1FC71955FE0100FDED82 /* RLMTestObjects.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RLMTestObjects.m; sourceTree = ""; }; E81A1FD01955FE0100FDED82 /* SwiftRealmTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftRealmTests.swift; sourceTree = ""; }; E81A1FD11955FE0100FDED82 /* TransactionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TransactionTests.m; sourceTree = ""; }; E81C393E1AE5CE6A00F03B56 /* strip-frameworks.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "strip-frameworks.sh"; path = "scripts/strip-frameworks.sh"; sourceTree = SOURCE_ROOT; }; @@ -983,6 +1016,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 3F558C9922C29CAF002F0F30 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 3F9D91832152D42F00474F09 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -990,6 +1030,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 3FE5818C22C2CA2E00BA10E7 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 5D660FC81BE98C560021E04F /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -1078,6 +1125,7 @@ 1A15366B1DB0460F00C0EC93 /* impl */, 1AD397D21F73032A002AA897 /* partial_sync.cpp */, 1AD397D31F73032A002AA897 /* partial_sync.hpp */, + 3F558C7822BC022B002F0F30 /* subscription_state.hpp */, 5DAD372D1F7485BB00EECA8E /* sync_config.cpp */, 1A15364A1DB045B500C0EC93 /* sync_config.hpp */, 1A15364D1DB045B500C0EC93 /* sync_manager.cpp */, @@ -1205,6 +1253,23 @@ path = apple; sourceTree = ""; }; + 3F558C7D22C299DB002F0F30 /* Test Utils */ = { + isa = PBXGroup; + children = ( + 3F558C9E22C29CAF002F0F30 /* RealmTestSupport.h */, + 3F558C8422C29A03002F0F30 /* RLMAssertions.h */, + 3F558C8022C29A02002F0F30 /* RLMMultiProcessTestCase.h */, + 3F558C8522C29A03002F0F30 /* RLMMultiProcessTestCase.m */, + 3F558C7F22C29A02002F0F30 /* RLMTestCase.h */, + 3F558C8322C29A02002F0F30 /* RLMTestCase.m */, + 3F558C8122C29A02002F0F30 /* RLMTestObjects.h */, + 3F558C8222C29A02002F0F30 /* RLMTestObjects.m */, + 3F558C8622C29A03002F0F30 /* TestUtils.h */, + 3F558C7E22C29A02002F0F30 /* TestUtils.mm */, + ); + name = "Test Utils"; + sourceTree = ""; + }; 3FF0B0A31BA861F200E74157 /* impl */ = { isa = PBXGroup; children = ( @@ -1260,6 +1325,7 @@ 5D659E6D1BE0398E006515A0 /* Base.xcconfig */, 5D659E6E1BE0398E006515A0 /* Debug.xcconfig */, 5D659E6F1BE0398E006515A0 /* Release.xcconfig */, + 3F35027722C43C5200FDC1E5 /* TestHost-static.xcconfig */, 5D6156F71BE07B6B00A4BD3F /* TestHost.xcconfig */, ); path = Configuration; @@ -1282,7 +1348,9 @@ 5D1534B71CCFF545008976D7 /* LinkingObjects.swift */, 5D660FE41BE98D670021E04F /* List.swift */, 5D660FE51BE98D670021E04F /* Migration.swift */, + 3FE5818322C2B4B900BA10E7 /* Nonsync.swift */, 5D660FE61BE98D670021E04F /* Object.swift */, + 3FE5818422C2B4B900BA10E7 /* ObjectiveCSupport+Sync.swift */, 5B77EACD1DCC5614006AB51D /* ObjectiveCSupport.swift */, 5D660FE71BE98D670021E04F /* ObjectSchema.swift */, 5D660FE81BE98D670021E04F /* Optional.swift */, @@ -1327,8 +1395,6 @@ 5D6610101BE98D880021E04F /* SwiftTestObjects.swift */, 5D6610111BE98D880021E04F /* SwiftUnicodeTests.swift */, 5D6610121BE98D880021E04F /* TestCase.swift */, - 5D6610131BE98D880021E04F /* TestUtils.h */, - 5D6610141BE98D880021E04F /* TestUtils.mm */, 3F73BC841E3A870F00FE80B6 /* ThreadSafeReferenceTests.swift */, ); name = "RealmSwift Tests"; @@ -1387,8 +1453,6 @@ 3FEC4A3D1BBB188B00F009C3 /* SwiftSchemaTests.swift */, E8F8D90B196CB8DD00475368 /* SwiftTestObjects.swift */, E891759A197A1B600068ACC6 /* SwiftUnicodeTests.swift */, - 297FBEFD1C19F844009D1118 /* TestUtils.h */, - 297FBEFE1C19F844009D1118 /* TestUtils.mm */, ); path = Swift; sourceTree = ""; @@ -1420,13 +1484,6 @@ C042A48C1B7522A900771ED2 /* RealmConfigurationTests.mm */, E81A1FC31955FE0100FDED82 /* RealmTests.mm */, 02AFB4621A80343600E11938 /* ResultsTests.m */, - C0D6E4101AFBFAF7001F3027 /* RLMAssertions.h */, - 027A4D2A1AB1012500AA46F9 /* RLMMultiProcessTestCase.h */, - 027A4D2B1AB1012500AA46F9 /* RLMMultiProcessTestCase.m */, - E81A1FC41955FE0100FDED82 /* RLMTestCase.h */, - E81A1FC51955FE0100FDED82 /* RLMTestCase.m */, - 3F44109E19953F5900223146 /* RLMTestObjects.h */, - E81A1FC71955FE0100FDED82 /* RLMTestObjects.m */, 0207AB86195DFA15007EFB12 /* SchemaTests.mm */, 3F572C911F2BDA9F00F6C9AB /* ThreadSafeReferenceTests.m */, E81A1FD11955FE0100FDED82 /* TransactionTests.m */, @@ -1481,8 +1538,8 @@ E8D89BA71955FC6D00CF2B9A /* Realm Tests */, 5D660FCD1BE98C560021E04F /* RealmSwift */, 5D660FD91BE98C7C0021E04F /* RealmSwift Tests */, + 3F558C7D22C299DB002F0F30 /* Test Utils */, E81A1FB31955FCE000FDED82 /* CHANGELOG.md */, - 3F9D91882152D42F00474F09 /* TestHost copy-Info.plist */, ); indentWidth = 4; sourceTree = ""; @@ -1497,6 +1554,8 @@ 5DD755CF1BE056DE002800DA /* Realm.framework */, 5D660FD81BE98C7C0021E04F /* RealmSwift Tests.xctest */, 5D660FCC1BE98C560021E04F /* RealmSwift.framework */, + 3F558C9C22C29CAF002F0F30 /* RealmTestSupport.framework */, + 3FE5819122C2CA2E00BA10E7 /* RealmTestSupport.framework */, 3F9D91872152D42F00474F09 /* TestHost static.app */, 3F1A5E721992EB7400F45F4C /* TestHost.app */, E8D89BA31955FC6D00CF2B9A /* Tests.xctest */, @@ -1633,6 +1692,22 @@ /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ + 3F558C9722C29CAF002F0F30 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 3F558CA022C29CAF002F0F30 /* RealmTestSupport.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3FE5818922C2CA2E00BA10E7 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 3FE5818A22C2CA2E00BA10E7 /* RealmTestSupport.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 5D659E9F1BE04556006515A0 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -1773,6 +1848,24 @@ productReference = 3F1A5E721992EB7400F45F4C /* TestHost.app */; productType = "com.apple.product-type.application"; }; + 3F558C9B22C29CAF002F0F30 /* RealmTestSupport */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3F558CA322C29CAF002F0F30 /* Build configuration list for PBXNativeTarget "RealmTestSupport" */; + buildPhases = ( + 3F558C9722C29CAF002F0F30 /* Headers */, + 3F558C9822C29CAF002F0F30 /* Sources */, + 3F558C9922C29CAF002F0F30 /* Frameworks */, + 3F558C9A22C29CAF002F0F30 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = RealmTestSupport; + productName = RealmTestSupport; + productReference = 3F558C9C22C29CAF002F0F30 /* RealmTestSupport.framework */; + productType = "com.apple.product-type.framework"; + }; 3F9D91802152D42F00474F09 /* TestHost static */ = { isa = PBXNativeTarget; buildConfigurationList = 3F9D91842152D42F00474F09 /* Build configuration list for PBXNativeTarget "TestHost static" */; @@ -1789,6 +1882,24 @@ productReference = 3F9D91872152D42F00474F09 /* TestHost static.app */; productType = "com.apple.product-type.application"; }; + 3FE5818822C2CA2E00BA10E7 /* RealmTestSupport static */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3FE5818E22C2CA2E00BA10E7 /* Build configuration list for PBXNativeTarget "RealmTestSupport static" */; + buildPhases = ( + 3FE5818922C2CA2E00BA10E7 /* Headers */, + 3FE5818B22C2CA2E00BA10E7 /* Sources */, + 3FE5818C22C2CA2E00BA10E7 /* Frameworks */, + 3FE5818D22C2CA2E00BA10E7 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "RealmTestSupport static"; + productName = RealmTestSupport; + productReference = 3FE5819122C2CA2E00BA10E7 /* RealmTestSupport.framework */; + productType = "com.apple.product-type.framework"; + }; 5D659E7D1BE04556006515A0 /* Realm */ = { isa = PBXNativeTarget; buildConfigurationList = 5D659ED61BE04556006515A0 /* Build configuration list for PBXNativeTarget "Realm" */; @@ -1841,6 +1952,7 @@ buildRules = ( ); dependencies = ( + 3F558CA922C29DC5002F0F30 /* PBXTargetDependency */, 3FC8BF35212B79F4001C2025 /* PBXTargetDependency */, 5D660FDF1BE98C7C0021E04F /* PBXTargetDependency */, ); @@ -1906,6 +2018,7 @@ 5DD755D41BE0582A002800DA /* PBXTargetDependency */, 3F9D917F2152D41A00474F09 /* PBXTargetDependency */, 3F9D918A2152D47B00474F09 /* PBXTargetDependency */, + 3FE5819422C2CA6800BA10E7 /* PBXTargetDependency */, ); name = "iOS static tests"; productName = iOSTests; @@ -1925,6 +2038,7 @@ buildRules = ( ); dependencies = ( + 3F558CA522C29DA6002F0F30 /* PBXTargetDependency */, 5DD755DF1BE05B26002800DA /* PBXTargetDependency */, 5DD755D21BE05828002800DA /* PBXTargetDependency */, 5D6157021BE0A3A100A4BD3F /* PBXTargetDependency */, @@ -1948,11 +2062,17 @@ TargetAttributes = { 3F1A5E711992EB7400F45F4C = { CreatedOnToolsVersion = 6.0; - DevelopmentTeam = QX5CR2FTN2; - DevelopmentTeamName = "Realm ApS"; LastSwiftMigration = 0900; ProvisioningStyle = Automatic; }; + 3F558C9B22C29CAF002F0F30 = { + CreatedOnToolsVersion = 10.2; + ProvisioningStyle = Automatic; + }; + 3F9D91802152D42F00474F09 = { + DevelopmentTeam = QX5CR2FTN2; + ProvisioningStyle = Automatic; + }; 5D659E7D1BE04556006515A0 = { LastSwiftMigration = 0900; ProvisioningStyle = Automatic; @@ -1964,8 +2084,6 @@ }; 5D660FD71BE98C7C0021E04F = { CreatedOnToolsVersion = 7.1; - DevelopmentTeam = QX5CR2FTN2; - DevelopmentTeamName = "Realm ApS"; LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; @@ -1984,15 +2102,12 @@ }; E856D1DE195614A400FB2FCF = { CreatedOnToolsVersion = 6.0; - DevelopmentTeam = QX5CR2FTN2; - DevelopmentTeamName = "Realm ApS"; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; TestTargetID = 3F9D91802152D42F00474F09; }; E8D89BA21955FC6D00CF2B9A = { CreatedOnToolsVersion = 6.0; - DevelopmentTeam = QX5CR2FTN2; - DevelopmentTeamName = "Realm ApS"; LastSwiftMigration = 1020; ProvisioningStyle = Automatic; TestTargetID = E8D89B971955FC6D00CF2B9A; @@ -2014,15 +2129,17 @@ targets = ( 5D659E7D1BE04556006515A0 /* Realm */, 5DD7557B1BE056DE002800DA /* Realm iOS static */, + 5D660FCB1BE98C560021E04F /* RealmSwift */, E8D89BA21955FC6D00CF2B9A /* Tests */, + 5D660FD71BE98C7C0021E04F /* RealmSwift Tests */, E8267FB11D90B79000E001C7 /* ObjectServerTests */, E856D1DE195614A400FB2FCF /* iOS static tests */, - 3F1A5E711992EB7400F45F4C /* TestHost */, C04B4BD71B55C47600FAE58E /* Download Core Library */, - 5D660FCB1BE98C560021E04F /* RealmSwift */, - 5D660FD71BE98C7C0021E04F /* RealmSwift Tests */, E83EAC791BED3D880085CCD2 /* SwiftLint */, + 3F1A5E711992EB7400F45F4C /* TestHost */, 3F9D91802152D42F00474F09 /* TestHost static */, + 3F558C9B22C29CAF002F0F30 /* RealmTestSupport */, + 3FE5818822C2CA2E00BA10E7 /* RealmTestSupport static */, ); }; /* End PBXProject section */ @@ -2056,6 +2173,20 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 3F558C9A22C29CAF002F0F30 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3FE5818D22C2CA2E00BA10E7 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 5D659ECE1BE04556006515A0 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -2221,6 +2352,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 3F558C9822C29CAF002F0F30 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 3F9D91812152D42F00474F09 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -2229,6 +2367,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 3FE5818B22C2CA2E00BA10E7 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 5D659E801BE04556006515A0 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -2323,6 +2468,7 @@ 5D660FF21BE98D670021E04F /* List.swift in Sources */, 5D660FF31BE98D670021E04F /* Migration.swift in Sources */, 5D660FF41BE98D670021E04F /* Object.swift in Sources */, + 3FE5818622C2B4B900BA10E7 /* ObjectiveCSupport+Sync.swift in Sources */, 5B77EACE1DCC5614006AB51D /* ObjectiveCSupport.swift in Sources */, 5D660FF51BE98D670021E04F /* ObjectSchema.swift in Sources */, 5D660FF61BE98D670021E04F /* Optional.swift in Sources */, @@ -2360,13 +2506,16 @@ 3F8825061E5E335000586B35 /* RealmCollectionTypeTests.swift in Sources */, 3F8825071E5E335000586B35 /* RealmConfigurationTests.swift in Sources */, 3F8825081E5E335000586B35 /* RealmTests.swift in Sources */, + 3F558C9622C29A03002F0F30 /* RLMMultiProcessTestCase.m in Sources */, + 3F558C9222C29A03002F0F30 /* RLMTestCase.m in Sources */, + 3F558C8E22C29A03002F0F30 /* RLMTestObjects.m in Sources */, 3F8825091E5E335000586B35 /* SchemaTests.swift in Sources */, 3F88250A1E5E335000586B35 /* SortDescriptorTests.swift in Sources */, 3F88250B1E5E335000586B35 /* SwiftLinkTests.swift in Sources */, 5D6610251BE98D880021E04F /* SwiftTestObjects.swift in Sources */, 3F88250C1E5E335000586B35 /* SwiftUnicodeTests.swift in Sources */, 5D6610271BE98D880021E04F /* TestCase.swift in Sources */, - 5D6610281BE98D880021E04F /* TestUtils.mm in Sources */, + 3F558C8A22C29A03002F0F30 /* TestUtils.mm in Sources */, 3F88250D1E5E335000586B35 /* ThreadSafeReferenceTests.swift in Sources */, 5DBEC9B11F719A9D001233EC /* Util.swift in Sources */, ); @@ -2461,19 +2610,21 @@ buildActionMask = 2147483647; files = ( 1A2713D71E3BBAC8001F6BFC /* RLMAncillaryObjectServerTests.m in Sources */, - 1A2D7A521DA5BCEC006AD7D6 /* RLMMultiProcessTestCase.m in Sources */, + 3F558C9422C29A03002F0F30 /* RLMMultiProcessTestCase.m in Sources */, E8267FF11D90B8E700E001C7 /* RLMObjectServerTests.mm in Sources */, 3FB60BAB204095B500583735 /* RLMPermissionsTests.mm in Sources */, 1AF64DCF1DA3042B0081EB15 /* RLMSyncManager+ObjectServerTests.m in Sources */, 3F73BC911E3A877300FE80B6 /* RLMSyncSessionRefreshHandle+ObjectServerTests.m in Sources */, 1AA5AE9C1D98A68E00ED8C27 /* RLMSyncTestCase.mm in Sources */, 1A1536481DB0408A00C0EC93 /* RLMSyncUser+ObjectServerTests.mm in Sources */, - E86E61241D91E4E200DC2419 /* RLMTestCase.m in Sources */, + 3F558C9022C29A03002F0F30 /* RLMTestCase.m in Sources */, + 3F558C8C22C29A03002F0F30 /* RLMTestObjects.m in Sources */, 3F73BC921E3A877300FE80B6 /* RLMTestUtils.m in Sources */, 1AA5AEA11D98C99800ED8C27 /* SwiftObjectServerTests.swift in Sources */, 3FAF8D02227A05BD005F1DB6 /* SwiftPartialSyncTests.swift in Sources */, 3FB60BAD2040999300583735 /* SwiftPermissionsTests.swift in Sources */, 1AA5AE981D989BE400ED8C27 /* SwiftSyncTestCase.swift in Sources */, + 3F558C8822C29A03002F0F30 /* TestUtils.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2504,11 +2655,11 @@ C042A48E1B7522A900771ED2 /* RealmConfigurationTests.mm in Sources */, E856D21E195615A900FB2FCF /* RealmTests.mm in Sources */, 02AFB4681A80343600E11938 /* ResultsTests.m in Sources */, - 3FC767071BB9FE7500FE0AFC /* RLMMultiProcessTestCase.m in Sources */, + 3FE5819622C2CCA700BA10E7 /* RLMMultiProcessTestCase.m in Sources */, 3FDE338D19C39A87003B7DBA /* RLMSupport.swift in Sources */, - E856D21F195615B100FB2FCF /* RLMTestCase.m in Sources */, + 3F558C9122C29A03002F0F30 /* RLMTestCase.m in Sources */, 3F4657371F27F2EF00456B07 /* RLMTestCaseUtils.swift in Sources */, - 028481CB19CCFC9C0097A416 /* RLMTestObjects.m in Sources */, + 3F558C8D22C29A03002F0F30 /* RLMTestObjects.m in Sources */, 0207AB8A195DFA15007EFB12 /* SchemaTests.mm in Sources */, 3F8DCA7619930FCB0008BD7F /* SwiftArrayPropertyTests.swift in Sources */, 3F8DCA7719930FCB0008BD7F /* SwiftArrayTests.swift in Sources */, @@ -2519,7 +2670,7 @@ 3F8DCA7D19930FCB0008BD7F /* SwiftRealmTests.swift in Sources */, 3F8DCA7519930FCB0008BD7F /* SwiftTestObjects.swift in Sources */, 3F8DCA7E19930FCB0008BD7F /* SwiftUnicodeTests.swift in Sources */, - 3F4657381F27F35600456B07 /* TestUtils.mm in Sources */, + 3F558C8922C29A03002F0F30 /* TestUtils.mm in Sources */, 3F572C951F2BDAAC00F6C9AB /* ThreadSafeReferenceTests.m in Sources */, E856D213195615A900FB2FCF /* TransactionTests.m in Sources */, E8917599197A1B350068ACC6 /* UnicodeTests.m in Sources */, @@ -2554,11 +2705,11 @@ C042A48D1B7522A900771ED2 /* RealmConfigurationTests.mm in Sources */, E81A1FEB1955FE0100FDED82 /* RealmTests.mm in Sources */, 02AFB4671A80343600E11938 /* ResultsTests.m in Sources */, - 027A4D2D1AB1012500AA46F9 /* RLMMultiProcessTestCase.m in Sources */, + 3F558C9322C29A03002F0F30 /* RLMMultiProcessTestCase.m in Sources */, 3FDCFEB619F6A8D3005E414A /* RLMSupport.swift in Sources */, - E81A1FEE1955FE0100FDED82 /* RLMTestCase.m in Sources */, + 3F558C8F22C29A03002F0F30 /* RLMTestCase.m in Sources */, 297FBEFB1C19F696009D1118 /* RLMTestCaseUtils.swift in Sources */, - 028481EF19CD032C0097A416 /* RLMTestObjects.m in Sources */, + 3F558C8B22C29A03002F0F30 /* RLMTestObjects.m in Sources */, 0207AB89195DFA15007EFB12 /* SchemaTests.mm in Sources */, 3FB4FA1819F5D2740020D53B /* SwiftArrayPropertyTests.swift in Sources */, 3FB4FA1919F5D2740020D53B /* SwiftArrayTests.swift in Sources */, @@ -2570,7 +2721,7 @@ 3FEC4A3F1BBB18D400F009C3 /* SwiftSchemaTests.swift in Sources */, 3FB4FA1719F5D2740020D53B /* SwiftTestObjects.swift in Sources */, 3FB4FA2019F5D2740020D53B /* SwiftUnicodeTests.swift in Sources */, - 297FBEFF1C19F844009D1118 /* TestUtils.mm in Sources */, + 3F558C8722C29A03002F0F30 /* TestUtils.mm in Sources */, 3F572C941F2BDAAB00F6C9AB /* ThreadSafeReferenceTests.m in Sources */, E81A20021955FE0100FDED82 /* TransactionTests.m in Sources */, E8917598197A1B350068ACC6 /* UnicodeTests.m in Sources */, @@ -2581,6 +2732,16 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 3F558CA522C29DA6002F0F30 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 3F558C9B22C29CAF002F0F30 /* RealmTestSupport */; + targetProxy = 3F558CA422C29DA6002F0F30 /* PBXContainerItemProxy */; + }; + 3F558CA922C29DC5002F0F30 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 3F558C9B22C29CAF002F0F30 /* RealmTestSupport */; + targetProxy = 3F558CA822C29DC5002F0F30 /* PBXContainerItemProxy */; + }; 3F8F3579212B6FAE0035E7B8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = C04B4BD71B55C47600FAE58E /* Download Core Library */; @@ -2606,6 +2767,11 @@ target = 3F1A5E711992EB7400F45F4C /* TestHost */; targetProxy = 3FC8BF34212B79F4001C2025 /* PBXContainerItemProxy */; }; + 3FE5819422C2CA6800BA10E7 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 3FE5818822C2CA2E00BA10E7 /* RealmTestSupport static */; + targetProxy = 3FE5819322C2CA6800BA10E7 /* PBXContainerItemProxy */; + }; 5D6157021BE0A3A100A4BD3F /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 3F1A5E711992EB7400F45F4C /* TestHost */; @@ -2663,7 +2829,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 5D6156F71BE07B6B00A4BD3F /* TestHost.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = ""; }; name = Debug; }; @@ -2671,32 +2837,84 @@ isa = XCBuildConfiguration; baseConfigurationReference = 5D6156F71BE07B6B00A4BD3F /* TestHost.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = ""; + }; + name = Release; + }; + 3F558CA122C29CAF002F0F30 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5D660FC01BE98BEF0021E04F /* Tests.xcconfig */; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + DEFINES_MODULE = YES; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 3F558CA222C29CAF002F0F30 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5D660FC01BE98BEF0021E04F /* Tests.xcconfig */; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + DEFINES_MODULE = YES; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; }; name = Release; }; 3F9D91852152D42F00474F09 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5D6156F71BE07B6B00A4BD3F /* TestHost.xcconfig */; + baseConfigurationReference = 3F35027722C43C5200FDC1E5 /* TestHost-static.xcconfig */; buildSettings = { - INFOPLIST_FILE = "TestHost copy-Info.plist"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = iphoneos; + CODE_SIGN_IDENTITY = "Mac Developer"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = QX5CR2FTN2; + PROVISIONING_PROFILE_SPECIFIER = ""; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; }; name = Debug; }; 3F9D91862152D42F00474F09 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5D6156F71BE07B6B00A4BD3F /* TestHost.xcconfig */; + baseConfigurationReference = 3F35027722C43C5200FDC1E5 /* TestHost-static.xcconfig */; buildSettings = { - INFOPLIST_FILE = "TestHost copy-Info.plist"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = iphoneos; + CODE_SIGN_IDENTITY = "Mac Developer"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = QX5CR2FTN2; + PROVISIONING_PROFILE_SPECIFIER = ""; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; }; name = Release; }; + 3FE5818F22C2CA2E00BA10E7 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5DD755E31BE05EA1002800DA /* Tests iOS static.xcconfig */; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + DEFINES_MODULE = YES; + INFOPLIST_FILE = "$(SRCROOT)/Realm/Tests/RealmTests-Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.Realm.RealmTestSupport; + PRODUCT_MODULE_NAME = RealmTestSupport; + PRODUCT_NAME = RealmTestSupport; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 3FE5819022C2CA2E00BA10E7 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5DD755E31BE05EA1002800DA /* Tests iOS static.xcconfig */; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + DEFINES_MODULE = YES; + INFOPLIST_FILE = "$(SRCROOT)/Realm/Tests/RealmTests-Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.Realm.RealmTestSupport; + PRODUCT_MODULE_NAME = RealmTestSupport; + PRODUCT_NAME = RealmTestSupport; + }; + name = Release; + }; 5D659ED71BE04556006515A0 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 5D659E761BE03E0D006515A0 /* Realm.xcconfig */; @@ -2739,7 +2957,11 @@ baseConfigurationReference = 5D660FC01BE98BEF0021E04F /* Tests.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CLANG_ENABLE_MODULES = YES; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; OTHER_SWIFT_FLAGS = "-D BUILDING_REALM_SWIFT_TESTS"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -2748,7 +2970,10 @@ baseConfigurationReference = 5D660FC01BE98BEF0021E04F /* Tests.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CLANG_ENABLE_MODULES = YES; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; OTHER_SWIFT_FLAGS = "-D BUILDING_REALM_SWIFT_TESTS"; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -2824,9 +3049,9 @@ isa = XCBuildConfiguration; baseConfigurationReference = 5DD755E31BE05EA1002800DA /* Tests iOS static.xcconfig */; buildSettings = { + PRODUCT_MODULE_NAME = Tests; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestHost static.app/TestHost static"; }; name = Debug; }; @@ -2834,9 +3059,9 @@ isa = XCBuildConfiguration; baseConfigurationReference = 5DD755E31BE05EA1002800DA /* Tests iOS static.xcconfig */; buildSettings = { + PRODUCT_MODULE_NAME = Tests; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestHost static.app/TestHost static"; }; name = Release; }; @@ -2882,6 +3107,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 3F558CA322C29CAF002F0F30 /* Build configuration list for PBXNativeTarget "RealmTestSupport" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3F558CA122C29CAF002F0F30 /* Debug */, + 3F558CA222C29CAF002F0F30 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 3F9D91842152D42F00474F09 /* Build configuration list for PBXNativeTarget "TestHost static" */ = { isa = XCConfigurationList; buildConfigurations = ( @@ -2891,6 +3125,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 3FE5818E22C2CA2E00BA10E7 /* Build configuration list for PBXNativeTarget "RealmTestSupport static" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3FE5818F22C2CA2E00BA10E7 /* Debug */, + 3FE5819022C2CA2E00BA10E7 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 5D659ED61BE04556006515A0 /* Build configuration list for PBXNativeTarget "Realm" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Realm/ObjectServerTests/RLMObjectServerTests.mm b/Realm/ObjectServerTests/RLMObjectServerTests.mm index 4299c3bb1b..c3d02d78a2 100644 --- a/Realm/ObjectServerTests/RLMObjectServerTests.mm +++ b/Realm/ObjectServerTests/RLMObjectServerTests.mm @@ -63,12 +63,6 @@ + (instancetype)objectWithNumber:(NSInteger)number firstString:(NSString *)first } @end -@implementation PersonObject -+ (NSDictionary *)linkingObjectsProperties { - return @{@"parents": [RLMPropertyDescriptor descriptorWithClass:PersonObject.class propertyName:@"children"]}; -} -@end - @interface RLMObjectServerTests : RLMSyncTestCase @end diff --git a/Realm/ObjectServerTests/RLMSyncUser+ObjectServerTests.h b/Realm/ObjectServerTests/RLMSyncUser+ObjectServerTests.h index 0bf20cb7b6..5bef0185fa 100644 --- a/Realm/ObjectServerTests/RLMSyncUser+ObjectServerTests.h +++ b/Realm/ObjectServerTests/RLMSyncUser+ObjectServerTests.h @@ -29,6 +29,4 @@ NS_ASSUME_NONNULL_BEGIN @end -FOUNDATION_EXTERN bool RLMHasCachedRealmForPath(NSString *path); - NS_ASSUME_NONNULL_END diff --git a/Realm/ObjectServerTests/RLMSyncUser+ObjectServerTests.mm b/Realm/ObjectServerTests/RLMSyncUser+ObjectServerTests.mm index 4322e94cd2..98da958ae1 100644 --- a/Realm/ObjectServerTests/RLMSyncUser+ObjectServerTests.mm +++ b/Realm/ObjectServerTests/RLMSyncUser+ObjectServerTests.mm @@ -70,7 +70,3 @@ - (void)simulateClientResetErrorForSession:(NSURL *)url { } @end - -bool RLMHasCachedRealmForPath(NSString *path) { - return RLMGetAnyCachedRealmForPath(path.UTF8String); -} diff --git a/Realm/RLMAnalytics.mm b/Realm/RLMAnalytics.mm index b6d750ac48..b1cd5ac43a 100644 --- a/Realm/RLMAnalytics.mm +++ b/Realm/RLMAnalytics.mm @@ -72,7 +72,9 @@ #import "RLMVersion.h" #endif +#if REALM_ENABLE_SYNC #import +#endif // Declared for RealmSwiftObjectUtil @interface NSObject (SwiftVersion) @@ -199,7 +201,9 @@ static auto RLMSysCtl(int *mib, u_int mibSize, size_t *bufferSize) { @"Binding": @"cocoa", @"Language": isSwift ? @"swift" : @"objc", @"Realm Version": REALM_COCOA_VERSION, +#if REALM_ENABLE_SYNC @"Sync Version": @(REALM_SYNC_VER_STRING), +#endif #if TARGET_OS_WATCH @"Target OS Type": @"watchos", #elif TARGET_OS_TV diff --git a/Realm/RLMObjectSchema.mm b/Realm/RLMObjectSchema.mm index 91d86f50cb..52327595e2 100644 --- a/Realm/RLMObjectSchema.mm +++ b/Realm/RLMObjectSchema.mm @@ -328,7 +328,12 @@ + (void)addSwiftProperties:(NSMutableArray *)propArray // or it might be a String?, Data?, Date? or object field with // a nil default value else if (md.kind == RLMSwiftPropertyKindNilLiteralOptional) { - propArray[existing].optional = true; + RLMProperty *prop = propArray[existing]; + // RLMLinkingObjects properties on RLMObjects are allowed + // to be optional as they'll be `nil` for unmanaged objects + if (prop.type != RLMPropertyTypeLinkingObjects) { + prop.optional = true; + } } // or it may be some non-optional property which may have been // previously marked as optional due to that being the default diff --git a/Realm/RLMObjectStore.mm b/Realm/RLMObjectStore.mm index 3982b3e296..c5ff5c321c 100644 --- a/Realm/RLMObjectStore.mm +++ b/Realm/RLMObjectStore.mm @@ -36,6 +36,8 @@ #import "results.hpp" #import "shared_realm.hpp" +#import + #import using namespace realm; diff --git a/Realm/RLMRealm.mm b/Realm/RLMRealm.mm index 9bd776b82c..d5bfe79893 100644 --- a/Realm/RLMRealm.mm +++ b/Realm/RLMRealm.mm @@ -32,8 +32,6 @@ #import "RLMRealmConfiguration_Private.hpp" #import "RLMRealmUtil.hpp" #import "RLMSchema_Private.hpp" -#import "RLMSyncManager_Private.h" -#import "RLMSyncUtil_Private.hpp" #import "RLMThreadSafeReference_Private.hpp" #import "RLMUpdateChecker.hpp" #import "RLMUtil.hpp" @@ -47,7 +45,12 @@ #include #include +#if REALM_ENABLE_SYNC +#import "RLMSyncManager_Private.h" +#import "RLMSyncUtil_Private.hpp" + #import "sync/sync_session.hpp" +#endif using namespace realm; using util::File; @@ -189,6 +192,7 @@ + (instancetype)realmWithURL:(NSURL *)fileURL { // causes issues for asyncOpen because it means that when our download completes // we don't actually have the full Realm state yet. static void waitForPartialSyncSubscriptions(Realm::Config const& config) { +#if REALM_ENABLE_SYNC auto realm = Realm::get_shared_realm(config); auto table = ObjectStore::table_for_object_type(realm->read_group(), "__ResultSets"); @@ -216,6 +220,9 @@ static void waitForPartialSyncSubscriptions(Realm::Config const& config) { }); }); CFRunLoopRun(); +#else + static_cast(config); +#endif } + (void)asyncOpenWithConfiguration:(RLMRealmConfiguration *)configuration @@ -886,6 +893,7 @@ - (BOOL)writeCopyToURL:(NSURL *)fileURL encryptionKey:(NSData *)key error:(NSErr return NO; } +#if REALM_ENABLE_SYNC using Privilege = realm::ComputedPrivileges; static bool hasPrivilege(realm::ComputedPrivileges actual, realm::ComputedPrivileges expected) { return (static_cast(actual) & static_cast(expected)) == static_cast(expected); @@ -929,6 +937,7 @@ - (RLMClassPrivileges)privilegesForClassNamed:(NSString *)className { .create = hasPrivilege(p, Privilege::Create), }; } +#endif - (void)registerEnumerator:(RLMFastEnumerator *)enumerator { if (!_collectionEnumerators) { diff --git a/Realm/RLMRealmConfiguration.mm b/Realm/RLMRealmConfiguration.mm index 3635f819b7..114b8d6b39 100644 --- a/Realm/RLMRealmConfiguration.mm +++ b/Realm/RLMRealmConfiguration.mm @@ -25,7 +25,12 @@ #import "schema.hpp" #import "shared_realm.hpp" + +#if REALM_ENABLE_SYNC #import "sync/sync_config.hpp" +#else +@class RLMSyncConfiguration; +#endif static NSString *const c_RLMRealmConfigurationProperties[] = { @"fileURL", @@ -190,16 +195,20 @@ - (void)setEncryptionKey:(NSData * __nullable)encryptionKey { if (NSData *key = RLMRealmValidatedEncryptionKey(encryptionKey)) { auto bytes = static_cast(key.bytes); _config.encryption_key.assign(bytes, bytes + key.length); +#if REALM_ENABLE_SYNC if (_config.sync_config) { auto& sync_encryption_key = self.config.sync_config->realm_encryption_key; sync_encryption_key = std::array(); std::copy_n(_config.encryption_key.begin(), 64, sync_encryption_key->begin()); } +#endif } else { _config.encryption_key.clear(); +#if REALM_ENABLE_SYNC if (_config.sync_config) _config.sync_config->realm_encryption_key = realm::util::none; +#endif } } @@ -300,4 +309,10 @@ - (void)setCustomSchemaWithoutCopying:(RLMSchema *)schema { _customSchema = schema; } +#if !REALM_ENABLE_SYNC +- (RLMSyncConfiguration *)syncConfiguration { + return nil; +} +#endif + @end diff --git a/Realm/Swift/RLMSupport.swift b/Realm/Swift/RLMSupport.swift index 41eafb0c01..5a98047342 100644 --- a/Realm/Swift/RLMSupport.swift +++ b/Realm/Swift/RLMSupport.swift @@ -81,6 +81,7 @@ extension RLMCollection { // MARK: - Sync-related +#if REALM_ENABLE_SYNC extension RLMSyncManager { public static var shared: RLMSyncManager { return __shared() @@ -135,6 +136,7 @@ extension RLMSyncSession { block: block) } } +#endif extension RLMNotificationToken { @available(*, unavailable, renamed: "invalidate()") diff --git a/Realm/Tests/RLMMultiProcessTestCase.m b/Realm/TestUtils/RLMMultiProcessTestCase.m similarity index 97% rename from Realm/Tests/RLMMultiProcessTestCase.m rename to Realm/TestUtils/RLMMultiProcessTestCase.m index 2161dedd76..05840b873b 100644 --- a/Realm/Tests/RLMMultiProcessTestCase.m +++ b/Realm/TestUtils/RLMMultiProcessTestCase.m @@ -93,14 +93,15 @@ + (void)preintializeSchema { } - (NSString *)locateXCTest { - NSString *pathString = [NSProcessInfo processInfo].environment[@"PATH"]; + NSProcessInfo *info = [NSProcessInfo processInfo]; + NSString *pathString = info.environment[@"PATH"]; NSFileManager *fileManager = [NSFileManager defaultManager]; for (NSString *directory in [pathString componentsSeparatedByString:@":"]) { NSString *candidatePath = [directory stringByAppendingPathComponent:@"xctest"]; if ([fileManager isExecutableFileAtPath:candidatePath]) return candidatePath; } - return nil; + return info.arguments[0]; } #if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR diff --git a/Realm/Tests/RLMTestCase.m b/Realm/TestUtils/RLMTestCase.m similarity index 97% rename from Realm/Tests/RLMTestCase.m rename to Realm/TestUtils/RLMTestCase.m index 3fee741231..23bc680368 100644 --- a/Realm/Tests/RLMTestCase.m +++ b/Realm/TestUtils/RLMTestCase.m @@ -71,10 +71,7 @@ static BOOL encryptTests() { return encryptAll; } -@implementation RLMTestCase { - dispatch_queue_t _bgQueue; -} - +@implementation RLMTestCaseBase + (void)setUp { [super setUp]; #if DEBUG || !TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR @@ -105,6 +102,16 @@ + (void)preinitializeSchema { [RLMSchema sharedSchema]; } +// A hook point for subclasses to override the cleanup +- (void)resetRealmState { + [RLMRealm resetRealmState]; +} +@end + +@implementation RLMTestCase { + dispatch_queue_t _bgQueue; +} + - (void)deleteFiles { // Clear cache [self resetRealmState]; @@ -114,12 +121,7 @@ - (void)deleteFiles { [self deleteRealmFileAtURL:RLMTestRealmURL()]; } -- (void)resetRealmState { - [RLMRealm resetRealmState]; -} - -- (void)deleteRealmFileAtURL:(NSURL *)fileURL -{ +- (void)deleteRealmFileAtURL:(NSURL *)fileURL { deleteOrThrow(fileURL); deleteOrThrow([fileURL URLByAppendingPathExtension:@"lock"]); deleteOrThrow([fileURL URLByAppendingPathExtension:@"note"]); @@ -146,8 +148,7 @@ - (void)invokeTest { } } -- (RLMRealm *)realmWithTestPath -{ +- (RLMRealm *)realmWithTestPath { return [RLMRealm realmWithURL:RLMTestRealmURL()]; } @@ -214,8 +215,7 @@ - (void)dispatchAsyncAndWait:(dispatch_block_t)block { dispatch_sync(_bgQueue, ^{}); } -- (id)nonLiteralNil -{ +- (id)nonLiteralNil { return nil; } diff --git a/Realm/Tests/RLMTestObjects.m b/Realm/TestUtils/RLMTestObjects.m similarity index 99% rename from Realm/Tests/RLMTestObjects.m rename to Realm/TestUtils/RLMTestObjects.m index 93fffabdfc..5f71d46dd6 100644 --- a/Realm/Tests/RLMTestObjects.m +++ b/Realm/TestUtils/RLMTestObjects.m @@ -199,9 +199,9 @@ @implementation CircleArrayObject @implementation ArrayPropertyObject @end -#pragma mark DynamicObject +#pragma mark DynamicTestObject -@implementation DynamicObject +@implementation DynamicTestObject @end #pragma mark AggregateObject diff --git a/Realm/TestUtils/RealmTestSupport.h b/Realm/TestUtils/RealmTestSupport.h new file mode 100644 index 0000000000..ff463008a4 --- /dev/null +++ b/Realm/TestUtils/RealmTestSupport.h @@ -0,0 +1 @@ +// A dummy module header to let us import RealmTestSupport in non-swiftpm builds diff --git a/RealmSwift/Tests/TestUtils.mm b/Realm/TestUtils/TestUtils.mm similarity index 61% rename from RealmSwift/Tests/TestUtils.mm rename to Realm/TestUtils/TestUtils.mm index 4a14c6110b..43de8c8a43 100644 --- a/RealmSwift/Tests/TestUtils.mm +++ b/Realm/TestUtils/TestUtils.mm @@ -17,18 +17,36 @@ //////////////////////////////////////////////////////////////////////////// #import "TestUtils.h" +#import "RLMAssertions.h" #import #import #import "RLMRealmUtil.hpp" -// This ensures the shared schema is initialized outside of of a test case, -// so if an exception is thrown, it will kill the test process rather than -// allowing hundreds of test cases to fail in strange ways -__attribute((constructor)) -static void initializeSharedSchema() { - [RLMSchema sharedSchema]; +void RLMAssertThrowsWithReasonMatchingSwift(XCTestCase *self, + __attribute__((noescape)) dispatch_block_t block, + NSString *regexString, NSString *message, + NSString *fileName, NSUInteger lineNumber) { + BOOL didThrow = NO; + @try { + block(); + } + @catch (NSException *e) { + didThrow = YES; + NSString *reason = e.reason; + NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regexString options:(NSRegularExpressionOptions)0 error:nil]; + if ([regex numberOfMatchesInString:reason options:(NSMatchingOptions)0 range:NSMakeRange(0, reason.length)] == 0) { + NSString *msg = [NSString stringWithFormat:@"The given expression threw an exception with reason '%@', but expected to match '%@'", + reason, regexString]; + [self recordFailureWithDescription:msg inFile:fileName atLine:lineNumber expected:NO]; + } + } + if (!didThrow) { + NSString *prefix = @"The given expression failed to throw an exception"; + message = message ? [NSString stringWithFormat:@"%@ (%@)", prefix, message] : prefix; + [self recordFailureWithDescription:message inFile:fileName atLine:lineNumber expected:NO]; + } } static void assertThrows(XCTestCase *self, dispatch_block_t block, NSString *message, @@ -47,8 +65,8 @@ static void assertThrows(XCTestCase *self, dispatch_block_t block, NSString *mes } } -void RLMAssertThrowsWithName(XCTestCase *self, __attribute__((noescape)) dispatch_block_t block, - NSString *name, NSString *message, NSString *fileName, NSUInteger lineNumber) { +void (RLMAssertThrowsWithName)(XCTestCase *self, __attribute__((noescape)) dispatch_block_t block, + NSString *name, NSString *message, NSString *fileName, NSUInteger lineNumber) { assertThrows(self, block, message, fileName, lineNumber, ^NSString *(NSException *e) { if ([name isEqualToString:e.name]) { return nil; @@ -58,8 +76,8 @@ void RLMAssertThrowsWithName(XCTestCase *self, __attribute__((noescape)) dispatc }); } -void RLMAssertThrowsWithReason(XCTestCase *self, __attribute__((noescape)) dispatch_block_t block, - NSString *expected, NSString *message, NSString *fileName, NSUInteger lineNumber) { +void (RLMAssertThrowsWithReason)(XCTestCase *self, __attribute__((noescape)) dispatch_block_t block, + NSString *expected, NSString *message, NSString *fileName, NSUInteger lineNumber) { assertThrows(self, block, message, fileName, lineNumber, ^NSString *(NSException *e) { if ([e.reason rangeOfString:expected].location != NSNotFound) { return nil; @@ -69,9 +87,9 @@ void RLMAssertThrowsWithReason(XCTestCase *self, __attribute__((noescape)) dispa }); } -void RLMAssertThrowsWithReasonMatching(XCTestCase *self, __attribute__((noescape)) dispatch_block_t block, - NSString *regexString, NSString *message, - NSString *fileName, NSUInteger lineNumber) { +void (RLMAssertThrowsWithReasonMatching)(XCTestCase *self, __attribute__((noescape)) dispatch_block_t block, + NSString *regexString, NSString *message, + NSString *fileName, NSUInteger lineNumber) { auto regex = [NSRegularExpression regularExpressionWithPattern:regexString options:(NSRegularExpressionOptions)0 error:nil]; assertThrows(self, block, message, fileName, lineNumber, ^NSString *(NSException *e) { @@ -84,8 +102,8 @@ void RLMAssertThrowsWithReasonMatching(XCTestCase *self, __attribute__((noescape } -void RLMAssertMatches(XCTestCase *self, __attribute__((noescape)) NSString *(^block)(), - NSString *regexString, NSString *message, NSString *fileName, NSUInteger lineNumber) { +void (RLMAssertMatches)(XCTestCase *self, __attribute__((noescape)) NSString *(^block)(), + NSString *regexString, NSString *message, NSString *fileName, NSUInteger lineNumber) { NSString *result = block(); NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regexString options:(NSRegularExpressionOptions)0 error:nil]; if ([regex numberOfMatchesInString:result options:(NSMatchingOptions)0 range:NSMakeRange(0, result.length)] == 0) { diff --git a/Realm/Tests/RLMAssertions.h b/Realm/TestUtils/include/RLMAssertions.h similarity index 80% rename from Realm/Tests/RLMAssertions.h rename to Realm/TestUtils/include/RLMAssertions.h index 59b386be37..863f904f1a 100644 --- a/Realm/Tests/RLMAssertions.h +++ b/Realm/TestUtils/include/RLMAssertions.h @@ -18,6 +18,37 @@ #import +FOUNDATION_EXTERN +void RLMAssertThrowsWithReasonMatchingSwift(XCTestCase *self, + __attribute__((noescape)) dispatch_block_t block, + NSString *regexString, NSString *message, + NSString *fileName, NSUInteger lineNumber); + +FOUNDATION_EXTERN +void RLMAssertThrowsWithName(XCTestCase *self, __attribute__((noescape)) dispatch_block_t block, + NSString *name, NSString *message, NSString *fileName, + NSUInteger lineNumber); + + +FOUNDATION_EXTERN +void RLMAssertThrowsWithReasonMatching(XCTestCase *self, + __attribute__((noescape)) dispatch_block_t block, + NSString *regexString, NSString *message, + NSString *fileName, NSUInteger lineNumber); + +FOUNDATION_EXTERN +void RLMAssertMatches(XCTestCase *self, __attribute__((noescape)) NSString *(^block)(void), + NSString *regexString, NSString *message, NSString *fileName, + NSUInteger lineNumber); + +FOUNDATION_EXTERN +void RLMAssertThrowsWithReason(XCTestCase *self, + __attribute__((noescape)) dispatch_block_t block, + NSString *regexString, NSString *message, + NSString *fileName, NSUInteger lineNumber); + +FOUNDATION_EXTERN bool RLMHasCachedRealmForPath(NSString *path); + #define RLMAssertThrows(expression, ...) \ RLMPrimitiveAssertThrows(self, expression, __VA_ARGS__) diff --git a/Realm/Tests/RLMMultiProcessTestCase.h b/Realm/TestUtils/include/RLMMultiProcessTestCase.h similarity index 100% rename from Realm/Tests/RLMMultiProcessTestCase.h rename to Realm/TestUtils/include/RLMMultiProcessTestCase.h diff --git a/Realm/Tests/RLMTestCase.h b/Realm/TestUtils/include/RLMTestCase.h similarity index 93% rename from Realm/Tests/RLMTestCase.h rename to Realm/TestUtils/include/RLMTestCase.h index a2baab6aa2..e1fdd26744 100644 --- a/Realm/Tests/RLMTestCase.h +++ b/Realm/TestUtils/include/RLMTestCase.h @@ -33,7 +33,11 @@ NSData *RLMGenerateKey(void); } #endif -@interface RLMTestCase : XCTestCase +@interface RLMTestCaseBase : XCTestCase +- (void)resetRealmState; +@end + +@interface RLMTestCase : RLMTestCaseBase - (RLMRealm *)realmWithTestPath; - (RLMRealm *)realmWithTestPathAndSchema:(nullable RLMSchema *)schema; diff --git a/Realm/Tests/RLMTestObjects.h b/Realm/TestUtils/include/RLMTestObjects.h similarity index 99% rename from Realm/Tests/RLMTestObjects.h rename to Realm/TestUtils/include/RLMTestObjects.h index 0f8981b001..9b2c5a101f 100644 --- a/Realm/Tests/RLMTestObjects.h +++ b/Realm/TestUtils/include/RLMTestObjects.h @@ -291,7 +291,7 @@ RLM_ARRAY_TYPE(CircleObject); #pragma mark DynamicObject -@interface DynamicObject : RLMObject +@interface DynamicTestObject : RLMObject @property NSString *stringCol; @property int intCol; diff --git a/Realm/Tests/TestUtils.h b/Realm/TestUtils/include/TestUtils.h similarity index 100% rename from Realm/Tests/TestUtils.h rename to Realm/TestUtils/include/TestUtils.h diff --git a/Realm/Tests/DynamicTests.m b/Realm/Tests/DynamicTests.m index 843d9dc617..f5e522dcb7 100644 --- a/Realm/Tests/DynamicTests.m +++ b/Realm/Tests/DynamicTests.m @@ -35,8 +35,8 @@ - (void)testDynamicRealmExists { // open realm in autoreleasepool to create tables and then dispose RLMRealm *realm = [RLMRealm realmWithURL:RLMTestRealmURL()]; [realm beginWriteTransaction]; - [DynamicObject createInRealm:realm withValue:@[@"column1", @1]]; - [DynamicObject createInRealm:realm withValue:@[@"column2", @2]]; + [DynamicTestObject createInRealm:realm withValue:@[@"column1", @1]]; + [DynamicTestObject createInRealm:realm withValue:@[@"column2", @2]]; [realm commitWriteTransaction]; } @@ -44,16 +44,16 @@ - (void)testDynamicRealmExists { XCTAssertNotNil(dyrealm, @"realm should not be nil"); // verify schema - RLMObjectSchema *dynSchema = dyrealm.schema[@"DynamicObject"]; + RLMObjectSchema *dynSchema = dyrealm.schema[@"DynamicTestObject"]; XCTAssertNotNil(dynSchema, @"Should be able to get object schema dynamically"); - XCTAssertEqual(dynSchema.properties.count, (NSUInteger)2, @"DynamicObject should have 2 properties"); + XCTAssertEqual(dynSchema.properties.count, (NSUInteger)2, @"DynamicTestObject should have 2 properties"); XCTAssertEqualObjects([dynSchema.properties[0] name], @"stringCol", @"Invalid property name"); XCTAssertEqual([(RLMProperty *)dynSchema.properties[1] type], RLMPropertyTypeInt, @"Invalid type"); // verify object type - RLMResults *results = [dyrealm allObjects:@"DynamicObject"]; + RLMResults *results = [dyrealm allObjects:@"DynamicTestObject"]; XCTAssertEqual(results.count, (NSUInteger)2, @"Array should have 2 elements"); - XCTAssertNotEqual(results.objectClassName, DynamicObject.className, + XCTAssertNotEqual(results.objectClassName, DynamicTestObject.className, @"Array class should by a dynamic object class"); } @@ -133,14 +133,14 @@ - (void)testDynamicProperties { // open realm in autoreleasepool to create tables and then dispose RLMRealm *realm = [RLMRealm realmWithURL:RLMTestRealmURL()]; [realm beginWriteTransaction]; - [DynamicObject createInRealm:realm withValue:@[@"column1", @1]]; - [DynamicObject createInRealm:realm withValue:@[@"column2", @2]]; + [DynamicTestObject createInRealm:realm withValue:@[@"column1", @1]]; + [DynamicTestObject createInRealm:realm withValue:@[@"column2", @2]]; [realm commitWriteTransaction]; } // verify properties RLMRealm *dyrealm = [self realmWithTestPathAndSchema:nil]; - RLMResults *results = [dyrealm allObjects:@"DynamicObject"]; + RLMResults *results = [dyrealm allObjects:@"DynamicTestObject"]; RLMObject *o1 = results[0], *o2 = results[1]; XCTAssertEqualObjects(o1[@"intCol"], @1); diff --git a/Realm/Tests/InterprocessTests.m b/Realm/Tests/InterprocessTests.m index 8257916ac5..f5392de87f 100644 --- a/Realm/Tests/InterprocessTests.m +++ b/Realm/Tests/InterprocessTests.m @@ -65,7 +65,7 @@ - (void)testCompactOnLaunchSuccessful { @autoreleasepool { RLMRealm *realm = RLMRealm.defaultRealm; [realm transactionWithBlock:^{ - for (int i = 0; i < 100; ++i) { + for (int i = 0; i < 1000; ++i) { [IntObject createInRealm:realm withValue:@[@(i)]]; } }]; diff --git a/Realm/Tests/MigrationTests.mm b/Realm/Tests/MigrationTests.mm index 26d184108d..ebcc55831f 100644 --- a/Realm/Tests/MigrationTests.mm +++ b/Realm/Tests/MigrationTests.mm @@ -51,13 +51,13 @@ static void RLMAssertRealmSchemaMatchesTable(id self, RLMRealm *realm) { } } -@interface MigrationObject : RLMObject +@interface MigrationTestObject : RLMObject @property int intCol; @property NSString *stringCol; @end -RLM_ARRAY_TYPE(MigrationObject); +RLM_ARRAY_TYPE(MigrationTestObject); -@implementation MigrationObject +@implementation MigrationTestObject @end @interface MigrationPrimaryKeyObject : RLMObject @@ -80,13 +80,13 @@ + (NSString *)primaryKey { } @end -@interface ThreeFieldMigrationObject : RLMObject +@interface ThreeFieldMigrationTestObject : RLMObject @property int col1; @property int col2; @property int col3; @end -@implementation ThreeFieldMigrationObject +@implementation ThreeFieldMigrationTestObject @end @interface MigrationTwoStringObject : RLMObject @@ -98,8 +98,8 @@ @implementation MigrationTwoStringObject @end @interface MigrationLinkObject : RLMObject -@property MigrationObject *object; -@property RLMArray *array; +@property MigrationTestObject *object; +@property RLMArray *array; @end @implementation MigrationLinkObject @@ -345,19 +345,19 @@ - (void)testDifferentSchemaVersionsAtDifferentPaths { - (void)testAddingClassDoesNotRequireMigration { RLMRealmConfiguration *config = [RLMRealmConfiguration new]; - config.objectClasses = @[MigrationObject.class]; + config.objectClasses = @[MigrationTestObject.class]; @autoreleasepool { [RLMRealm realmWithConfiguration:config error:nil]; } - config.objectClasses = @[MigrationObject.class, ThreeFieldMigrationObject.class]; + config.objectClasses = @[MigrationTestObject.class, ThreeFieldMigrationTestObject.class]; XCTAssertNoThrow([RLMRealm realmWithConfiguration:config error:nil]); } - (void)testRemovingClassDoesNotRequireMigration { RLMRealmConfiguration *config = [RLMRealmConfiguration new]; - config.objectClasses = @[MigrationObject.class, ThreeFieldMigrationObject.class]; + config.objectClasses = @[MigrationTestObject.class, ThreeFieldMigrationTestObject.class]; @autoreleasepool { [RLMRealm realmWithConfiguration:config error:nil]; } - config.objectClasses = @[MigrationObject.class]; + config.objectClasses = @[MigrationTestObject.class]; XCTAssertNoThrow([RLMRealm realmWithConfiguration:config error:nil]); } @@ -453,7 +453,7 @@ - (void)testMakingPropertyNonOptionalRequiresMigration { } - (void)testChangingLinkTargetRequiresMigration { - NSArray *linkTargets = @[[RLMObjectSchema schemaForObjectClass:MigrationObject.class], + NSArray *linkTargets = @[[RLMObjectSchema schemaForObjectClass:MigrationTestObject.class], [RLMObjectSchema schemaForObjectClass:MigrationTwoStringObject.class]]; RLMObjectSchema *from = [RLMObjectSchema schemaForObjectClass:MigrationLinkObject.class]; @@ -465,7 +465,7 @@ - (void)testChangingLinkTargetRequiresMigration { } - (void)testChangingLinkListTargetRequiresMigration { - NSArray *linkTargets = @[[RLMObjectSchema schemaForObjectClass:MigrationObject.class], + NSArray *linkTargets = @[[RLMObjectSchema schemaForObjectClass:MigrationTestObject.class], [RLMObjectSchema schemaForObjectClass:MigrationTwoStringObject.class]]; RLMObjectSchema *from = [RLMObjectSchema schemaForObjectClass:MigrationLinkObject.class]; @@ -477,9 +477,9 @@ - (void)testChangingLinkListTargetRequiresMigration { } - (void)testChangingPropertyTypesRequiresMigration { - RLMObjectSchema *from = [RLMObjectSchema schemaForObjectClass:MigrationObject.class]; + RLMObjectSchema *from = [RLMObjectSchema schemaForObjectClass:MigrationTestObject.class]; - RLMObjectSchema *to = [RLMObjectSchema schemaForObjectClass:MigrationObject.class]; + RLMObjectSchema *to = [RLMObjectSchema schemaForObjectClass:MigrationTestObject.class]; to.objectClass = RLMObject.class; RLMProperty *prop = to.properties[0]; RLMProperty *strProp = to.properties[1]; @@ -512,14 +512,14 @@ - (void)testDeleteRealmIfMigrationNeededWithSetCustomSchema { - (void)testDeleteRealmIfMigrationNeeded { for (uint64_t targetSchemaVersion = 1; targetSchemaVersion < 2; targetSchemaVersion++) { RLMRealmConfiguration *configuration = [RLMRealmConfiguration defaultConfiguration]; - RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:MigrationObject.class]; + RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:MigrationTestObject.class]; configuration.customSchema = [self schemaWithObjects:@[objectSchema]]; @autoreleasepool { [[NSFileManager defaultManager] removeItemAtURL:configuration.fileURL error:nil]; RLMRealm *realm = [RLMRealm realmWithConfiguration:configuration error:nil]; [realm transactionWithBlock:^{ - [realm addObject:[MigrationObject new]]; + [realm addObject:[MigrationTestObject new]]; }]; } @@ -713,17 +713,17 @@ - (void)testRemovingSubclass { - (void)testAddingPropertyAtEnd { // create schema to migrate from with single string column - RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:MigrationObject.class]; + RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:MigrationTestObject.class]; objectSchema.properties = @[objectSchema.properties[0]]; [self createTestRealmWithSchema:@[objectSchema] block:^(RLMRealm *realm) { - [realm createObject:MigrationObject.className withValue:@[@1]]; - [realm createObject:MigrationObject.className withValue:@[@2]]; + [realm createObject:MigrationTestObject.className withValue:@[@1]]; + [realm createObject:MigrationTestObject.className withValue:@[@2]]; }]; // apply migration RLMRealm *realm = [self migrateTestRealmWithBlock:^(RLMMigration *migration, uint64_t oldSchemaVersion) { XCTAssertEqual(oldSchemaVersion, 0U, @"Initial schema version should be 0"); - [migration enumerateObjects:MigrationObject.className + [migration enumerateObjects:MigrationTestObject.className block:^(RLMObject *oldObject, RLMObject *newObject) { XCTAssertThrows(oldObject[@"stringCol"], @"stringCol should not exist on old object"); NSNumber *intObj; @@ -735,22 +735,22 @@ - (void)testAddingPropertyAtEnd { }]; // verify migration - MigrationObject *mig1 = [MigrationObject allObjectsInRealm:realm][1]; + MigrationTestObject *mig1 = [MigrationTestObject allObjectsInRealm:realm][1]; XCTAssertEqual(mig1.intCol, 2, @"Int column should have value 2"); XCTAssertEqualObjects(mig1.stringCol, @"2", @"String column should be populated"); } - (void)testAddingPropertyAtBeginningPreservesData { // create schema to migrate from with the second and third columns from the final data - RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:ThreeFieldMigrationObject.class]; + RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:ThreeFieldMigrationTestObject.class]; objectSchema.properties = @[objectSchema.properties[1], objectSchema.properties[2]]; [self createTestRealmWithSchema:@[objectSchema] block:^(RLMRealm *realm) { - [realm createObject:ThreeFieldMigrationObject.className withValue:@[@1, @2]]; + [realm createObject:ThreeFieldMigrationTestObject.className withValue:@[@1, @2]]; }]; RLMRealm *realm = [self migrateTestRealmWithBlock:^(RLMMigration *migration, uint64_t) { - [migration enumerateObjects:ThreeFieldMigrationObject.className + [migration enumerateObjects:ThreeFieldMigrationTestObject.className block:^(RLMObject *oldObject, RLMObject *newObject) { XCTAssertThrows(oldObject[@"col1"]); XCTAssertEqualObjects(oldObject[@"col2"], newObject[@"col2"]); @@ -759,7 +759,7 @@ - (void)testAddingPropertyAtBeginningPreservesData { }]; // verify migration - ThreeFieldMigrationObject *mig = [ThreeFieldMigrationObject allObjectsInRealm:realm][0]; + ThreeFieldMigrationTestObject *mig = [ThreeFieldMigrationTestObject allObjectsInRealm:realm][0]; XCTAssertEqual(0, mig.col1); XCTAssertEqual(1, mig.col2); XCTAssertEqual(2, mig.col3); @@ -767,20 +767,20 @@ - (void)testAddingPropertyAtBeginningPreservesData { - (void)testRemoveProperty { // create schema with an extra column - RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:MigrationObject.class]; + RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:MigrationTestObject.class]; RLMProperty *thirdProperty = [[RLMProperty alloc] initWithName:@"deletedCol" type:RLMPropertyTypeBool objectClassName:nil linkOriginPropertyName:nil indexed:NO optional:NO]; objectSchema.properties = [objectSchema.properties arrayByAddingObject:thirdProperty]; // create realm with old schema and populate [self createTestRealmWithSchema:@[objectSchema] block:^(RLMRealm *realm) { - [realm createObject:MigrationObject.className withValue:@[@1, @"1", @YES]]; - [realm createObject:MigrationObject.className withValue:@[@2, @"2", @NO]]; + [realm createObject:MigrationTestObject.className withValue:@[@1, @"1", @YES]]; + [realm createObject:MigrationTestObject.className withValue:@[@2, @"2", @NO]]; }]; // apply migration RLMRealm *realm = [self migrateTestRealmWithBlock:^(RLMMigration *migration, uint64_t oldSchemaVersion) { XCTAssertEqual(oldSchemaVersion, 0U, @"Initial schema version should be 0"); - [migration enumerateObjects:MigrationObject.className + [migration enumerateObjects:MigrationTestObject.className block:^(RLMObject *oldObject, RLMObject *newObject) { XCTAssertNoThrow(oldObject[@"deletedCol"], @"Deleted column should be accessible on old object."); XCTAssertThrows(newObject[@"deletedCol"], @"Deleted column should not be accessible on new object."); @@ -791,20 +791,20 @@ - (void)testRemoveProperty { }]; // verify migration - MigrationObject *mig1 = [MigrationObject allObjectsInRealm:realm][1]; + MigrationTestObject *mig1 = [MigrationTestObject allObjectsInRealm:realm][1]; XCTAssertThrows(mig1[@"deletedCol"], @"Deleted column should no longer be accessible."); } - (void)testRemoveAndAddProperty { // create schema to migrate from with single string column - RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:MigrationObject.class]; + RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:MigrationTestObject.class]; RLMProperty *oldInt = [[RLMProperty alloc] initWithName:@"oldIntCol" type:RLMPropertyTypeInt objectClassName:nil linkOriginPropertyName:nil indexed:NO optional:NO]; objectSchema.properties = @[oldInt, objectSchema.properties[1]]; // create realm with old schema and populate [self createTestRealmWithSchema:@[objectSchema] block:^(RLMRealm *realm) { - [realm createObject:MigrationObject.className withValue:@[@1, @"1"]]; - [realm createObject:MigrationObject.className withValue:@[@1, @"2"]]; + [realm createObject:MigrationTestObject.className withValue:@[@1, @"1"]]; + [realm createObject:MigrationTestObject.className withValue:@[@1, @"2"]]; }]; // object migration object @@ -820,17 +820,17 @@ - (void)testRemoveAndAddProperty { // apply migration RLMRealm *realm = [self migrateTestRealmWithBlock:^(RLMMigration *migration, uint64_t oldSchemaVersion) { XCTAssertEqual(oldSchemaVersion, 0U, @"Initial schema version should be 0"); - [migration enumerateObjects:MigrationObject.className block:migrateObjectBlock]; + [migration enumerateObjects:MigrationTestObject.className block:migrateObjectBlock]; }]; // verify migration - MigrationObject *mig1 = [MigrationObject allObjectsInRealm:realm][1]; + MigrationTestObject *mig1 = [MigrationTestObject allObjectsInRealm:realm][1]; XCTAssertThrows(mig1[@"oldIntCol"], @"Deleted column should no longer be accessible."); } - (void)testChangePropertyType { // make string an int - RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:MigrationObject.class]; + RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:MigrationTestObject.class]; objectSchema.objectClass = RLMObject.class; RLMProperty *stringCol = objectSchema.properties[1]; stringCol.type = RLMPropertyTypeInt; @@ -838,14 +838,14 @@ - (void)testChangePropertyType { // create realm with old schema and populate [self createTestRealmWithSchema:@[objectSchema] block:^(RLMRealm *realm) { - [realm createObject:MigrationObject.className withValue:@[@1, @1]]; - [realm createObject:MigrationObject.className withValue:@[@2, @2]]; + [realm createObject:MigrationTestObject.className withValue:@[@1, @1]]; + [realm createObject:MigrationTestObject.className withValue:@[@2, @2]]; }]; // apply migration RLMRealm *realm = [self migrateTestRealmWithBlock:^(RLMMigration *migration, uint64_t oldSchemaVersion) { XCTAssertEqual(oldSchemaVersion, 0U, @"Initial schema version should be 0"); - [migration enumerateObjects:MigrationObject.className + [migration enumerateObjects:MigrationTestObject.className block:^(RLMObject *oldObject, RLMObject *newObject) { XCTAssertEqualObjects(newObject[@"intCol"], oldObject[@"intCol"]); NSNumber *intObj = oldObject[@"stringCol"]; @@ -855,14 +855,14 @@ - (void)testChangePropertyType { }]; // verify migration - MigrationObject *mig1 = [MigrationObject allObjectsInRealm:realm][1]; + MigrationTestObject *mig1 = [MigrationTestObject allObjectsInRealm:realm][1]; XCTAssertEqualObjects(mig1[@"stringCol"], @"2", @"stringCol should be string after migration."); } - (void)testChangeObjectLinkType { // create realm with old schema and populate [self createTestRealmWithSchema:RLMSchema.sharedSchema.objectSchema block:^(RLMRealm *realm) { - id obj = [realm createObject:MigrationObject.className withValue:@[@1, @"1"]]; + id obj = [realm createObject:MigrationTestObject.className withValue:@[@1, @"1"]]; [realm createObject:MigrationLinkObject.className withValue:@[obj, @[obj]]]; }]; @@ -870,7 +870,7 @@ - (void)testChangeObjectLinkType { RLMRealmConfiguration *config = self.config; RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:MigrationLinkObject.class]; [objectSchema.properties[0] setObjectClassName:MigrationLinkObject.className]; - config.customSchema = [self schemaWithObjects:@[objectSchema, [RLMObjectSchema schemaForObjectClass:MigrationObject.class]]]; + config.customSchema = [self schemaWithObjects:@[objectSchema, [RLMObjectSchema schemaForObjectClass:MigrationTestObject.class]]]; // Apply migration config.schemaVersion = 1; @@ -893,14 +893,14 @@ - (void)testChangeArrayLinkType { // create realm with old schema and populate RLMRealmConfiguration *config = [self config]; [self createTestRealmWithSchema:RLMSchema.sharedSchema.objectSchema block:^(RLMRealm *realm) { - id obj = [realm createObject:MigrationObject.className withValue:@[@1, @"1"]]; + id obj = [realm createObject:MigrationTestObject.className withValue:@[@1, @"1"]]; [realm createObject:MigrationLinkObject.className withValue:@[obj, @[obj]]]; }]; // Make the array linklist property link to a different class RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:MigrationLinkObject.class]; [objectSchema.properties[1] setObjectClassName:MigrationLinkObject.className]; - config.customSchema = [self schemaWithObjects:@[objectSchema, [RLMObjectSchema schemaForObjectClass:MigrationObject.class]]]; + config.customSchema = [self schemaWithObjects:@[objectSchema, [RLMObjectSchema schemaForObjectClass:MigrationTestObject.class]]]; // Apply migration config.schemaVersion = 1; @@ -1373,6 +1373,7 @@ - (void)testMigrationAfterReorderingProperties { XCTAssertEqualObjects(@"World", [allObjects[1] stringCol]); } +#ifndef REALM_SPM - (void)testDateTimeFormatAutoMigration { static const int cookieValue = 0xDEADBEEF; @@ -1448,8 +1449,11 @@ - (void)testDateTimeFormatAutoMigration { @autoreleasepool { NSURL *bundledRealmURL = [[NSBundle bundleForClass:[DateMigrationObject class]] URLForResource:@"fileformat-pre-null" withExtension:@"realm"]; - [NSFileManager.defaultManager removeItemAtURL:config.fileURL error:nil]; - [NSFileManager.defaultManager copyItemAtURL:bundledRealmURL toURL:config.fileURL error:nil]; + NSError *error; + [NSFileManager.defaultManager removeItemAtURL:config.fileURL error:&error]; + XCTAssertNil(error); + [NSFileManager.defaultManager copyItemAtURL:bundledRealmURL toURL:config.fileURL error:&error]; + XCTAssertNil(error); config.schemaVersion = 1; // Nullability of some properties changed RLMRealm *realm = [RLMRealm realmWithConfiguration:config error:nil]; @@ -1508,6 +1512,7 @@ - (void)testMigratingFromMixed { XCTAssertTrue(migrationCalled); #endif } +#endif // REALM_SPM - (void)testModifyPrimaryKeyInMigration { RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:PrimaryStringObject.class]; @@ -1704,7 +1709,7 @@ - (void)testMigrationRenamePropertyTypeMismatch { - (void)testMigrationRenamePropertyObjectTypeMismatch { RLMObjectSchema *objectSchema = [RLMObjectSchema schemaForObjectClass:MigrationLinkObject.class]; - RLMObjectSchema *migrationObjectSchema = [RLMObjectSchema schemaForObjectClass:MigrationObject.class]; + RLMObjectSchema *migrationObjectSchema = [RLMObjectSchema schemaForObjectClass:MigrationTestObject.class]; NSArray *afterProperties = objectSchema.properties; NSMutableArray *beforeProperties = [NSMutableArray arrayWithCapacity:2]; for (RLMProperty *property in afterProperties) { @@ -1720,13 +1725,13 @@ - (void)testMigrationRenamePropertyObjectTypeMismatch { objectSchema.properties = afterProperties; - [self assertPropertyRenameError:@"Cannot rename property 'MigrationLinkObject.before_object' to 'object' because it would change from type '' to ''." + [self assertPropertyRenameError:@"Cannot rename property 'MigrationLinkObject.before_object' to 'object' because it would change from type '' to ''." objectSchemas:@[objectSchema, migrationObjectSchema] className:MigrationLinkObject.className oldName:[beforeProperties[0] name] newName:[afterProperties[0] name]]; - [self assertPropertyRenameError:@"Cannot rename property 'MigrationLinkObject.before_array' to 'array' because it would change from type 'array' to 'array'." + [self assertPropertyRenameError:@"Cannot rename property 'MigrationLinkObject.before_array' to 'array' because it would change from type 'array' to 'array'." objectSchemas:@[objectSchema, migrationObjectSchema] className:MigrationLinkObject.className oldName:[beforeProperties[1] name] diff --git a/Realm/Tests/QueryTests.m b/Realm/Tests/QueryTests.m index 91aeae7c07..8653dc4fa0 100644 --- a/Realm/Tests/QueryTests.m +++ b/Realm/Tests/QueryTests.m @@ -1081,7 +1081,7 @@ - (void)testStringLike RLMAssertCount(StringObject, 0U, @"stringCol LIKE 'aabc'"); RLMAssertCount(StringObject, 0U, @"stringCol LIKE 'b*bc'"); - RLMAssertCount(StringObject, 1U, @"stringCol LIKE 'a??'"); + RLMAssertCount(StringObject, 1U, @"stringCol LIKE 'a?" "?'"); RLMAssertCount(StringObject, 1U, @"stringCol LIKE '?b?'"); RLMAssertCount(StringObject, 1U, @"stringCol LIKE '*?c'"); RLMAssertCount(StringObject, 1U, @"stringCol LIKE 'ab?'"); diff --git a/Realm/Tests/RealmTests.mm b/Realm/Tests/RealmTests.mm index abd5ab8a08..6b6a4d5565 100644 --- a/Realm/Tests/RealmTests.mm +++ b/Realm/Tests/RealmTests.mm @@ -30,6 +30,7 @@ #import #import +#import @interface RLMRealm () + (BOOL)isCoreDebug; @@ -204,6 +205,7 @@ - (void)testFilePermissionDenied { XCTAssertEqualObjects(oldData, newData); \ } while (0) +#ifndef REALM_SPM - (void)testFileFormatUpgradeRequiredDeleteRealmIfNeeded { RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration]; config.deleteRealmIfMigrationNeeded = YES; @@ -263,6 +265,7 @@ - (void)testFileFormatUpgradeRequiredButReadOnly { XCTAssertEqualObjects([NSData dataWithContentsOfURL:bundledRealmURL], [NSData dataWithContentsOfURL:config.fileURL]); } +#endif // REALM_SPM #if TARGET_OS_IPHONE && (!TARGET_IPHONE_SIMULATOR || !TARGET_RT_64_BIT) - (void)testExceedingVirtualAddressSpace { @@ -1690,6 +1693,7 @@ - (void)testWritingCopyUsesWriteTransactionInProgress #pragma mark - Assorted tests +#ifndef REALM_SPM - (void)testCoreDebug { #if DEBUG XCTAssertTrue([RLMRealm isCoreDebug], @"Debug version of Realm should use librealm{-ios}-dbg"); @@ -1697,6 +1701,7 @@ - (void)testCoreDebug { XCTAssertFalse([RLMRealm isCoreDebug], @"Release version of Realm should use librealm{-ios}"); #endif } +#endif - (void)testIsEmpty { RLMRealm *realm = [RLMRealm defaultRealm]; diff --git a/Realm/Tests/Swift/RLMSupport.swift b/Realm/Tests/Swift/RLMSupport.swift new file mode 120000 index 0000000000..421ea5c465 --- /dev/null +++ b/Realm/Tests/Swift/RLMSupport.swift @@ -0,0 +1 @@ +../../Swift/RLMSupport.swift \ No newline at end of file diff --git a/Realm/Tests/Swift/RLMTestCaseUtils.swift b/Realm/Tests/Swift/RLMTestCaseUtils.swift index 48110f9b26..ce4c58e6d4 100644 --- a/Realm/Tests/Swift/RLMTestCaseUtils.swift +++ b/Realm/Tests/Swift/RLMTestCaseUtils.swift @@ -16,6 +16,8 @@ // //////////////////////////////////////////////////////////////////////////// +import RealmTestSupport + extension RLMTestCase { func assertThrowsWithReasonMatching(_ block: @autoclosure @escaping () -> T, _ regexString: String, _ message: String? = nil, fileName: String = #file, lineNumber: UInt = #line) { diff --git a/Realm/Tests/Swift/SwiftArrayPropertyTests.swift b/Realm/Tests/Swift/SwiftArrayPropertyTests.swift index 8dd69515f4..678002d3af 100644 --- a/Realm/Tests/Swift/SwiftArrayPropertyTests.swift +++ b/Realm/Tests/Swift/SwiftArrayPropertyTests.swift @@ -18,13 +18,14 @@ import XCTest import Realm +import RealmTestSupport -class SwiftArrayPropertyTests: RLMTestCase { +class SwiftRLMArrayPropertyTests: RLMTestCase { // Swift models func testBasicArray() { - let string = SwiftStringObject() + let string = SwiftRLMStringObject() string.stringCol = "string" let realm = realmWithTestPath() @@ -32,9 +33,9 @@ class SwiftArrayPropertyTests: RLMTestCase { realm.add(string) try! realm.commitWriteTransaction() - XCTAssertEqual(SwiftStringObject.allObjects(in: realm).count, UInt(1), "There should be a single SwiftStringObject in the realm") + XCTAssertEqual(SwiftRLMStringObject.allObjects(in: realm).count, UInt(1), "There should be a single SwiftRLMStringObject in the realm") - let array = SwiftArrayPropertyObject() + let array = SwiftRLMArrayPropertyObject() array.name = "arrayObject" array.array.add(string) XCTAssertEqual(array.array.count, UInt(1)) @@ -45,9 +46,9 @@ class SwiftArrayPropertyTests: RLMTestCase { array.array.add(string) try! realm.commitWriteTransaction() - let arrayObjects = SwiftArrayPropertyObject.allObjects(in: realm) as! RLMResults + let arrayObjects = SwiftRLMArrayPropertyObject.allObjects(in: realm) as! RLMResults - XCTAssertEqual(arrayObjects.count, UInt(1), "There should be a single SwiftStringObject in the realm") + XCTAssertEqual(arrayObjects.count, UInt(1), "There should be a single SwiftRLMStringObject in the realm") let cmp = arrayObjects.firstObject()!.array.firstObject()! XCTAssertTrue(string.isEqual(to: cmp), "First array object should be the string object we added") } @@ -56,14 +57,14 @@ class SwiftArrayPropertyTests: RLMTestCase { let realm = realmWithTestPath() realm.beginWriteTransaction() - let array = SwiftArrayPropertyObject.create(in: realm, withValue: ["arrayObject", [], []]); + let array = SwiftRLMArrayPropertyObject.create(in: realm, withValue: ["arrayObject", [], []]) XCTAssertNotNil(array.array, "Should be able to get an empty array") XCTAssertEqual(array.array.count, UInt(0), "Should start with no array elements") - let obj = SwiftStringObject() + let obj = SwiftRLMStringObject() obj.stringCol = "a" array.array.add(obj) - array.array.add(SwiftStringObject.create(in: realm, withValue: ["b"])) + array.array.add(SwiftRLMStringObject.create(in: realm, withValue: ["b"])) array.array.add(obj) try! realm.commitWriteTransaction() @@ -80,15 +81,15 @@ class SwiftArrayPropertyTests: RLMTestCase { func testModifyDetatchedArray() { let realm = realmWithTestPath() realm.beginWriteTransaction() - let arObj = SwiftArrayPropertyObject.create(in: realm, withValue: ["arrayObject", [], []]) + let arObj = SwiftRLMArrayPropertyObject.create(in: realm, withValue: ["arrayObject", [], []]) XCTAssertNotNil(arObj.array, "Should be able to get an empty array") XCTAssertEqual(arObj.array.count, UInt(0), "Should start with no array elements") - let obj = SwiftStringObject() + let obj = SwiftRLMStringObject() obj.stringCol = "a" let array = arObj.array array.add(obj) - array.add(SwiftStringObject.create(in: realm, withValue: ["b"])) + array.add(SwiftRLMStringObject.create(in: realm, withValue: ["b"])) try! realm.commitWriteTransaction() XCTAssertEqual(array.count, UInt(2), "Should have two elements in array") @@ -101,27 +102,27 @@ class SwiftArrayPropertyTests: RLMTestCase { realm.beginWriteTransaction() - let obj = SwiftArrayPropertyObject.create(in: realm, withValue: ["arrayObject", [], []]) - let child1 = SwiftStringObject.create(in: realm, withValue: ["a"]) - let child2 = SwiftStringObject() + let obj = SwiftRLMArrayPropertyObject.create(in: realm, withValue: ["arrayObject", [], []]) + let child1 = SwiftRLMStringObject.create(in: realm, withValue: ["a"]) + let child2 = SwiftRLMStringObject() child2.stringCol = "b" obj.array.addObjects([child2, child1] as NSArray) try! realm.commitWriteTransaction() - let children = SwiftStringObject.allObjects(in: realm) - XCTAssertEqual((children[0] as! SwiftStringObject).stringCol, "a", "First child should be 'a'") - XCTAssertEqual((children[1] as! SwiftStringObject).stringCol, "b", "Second child should be 'b'") + let children = SwiftRLMStringObject.allObjects(in: realm) + XCTAssertEqual((children[0] as! SwiftRLMStringObject).stringCol, "a", "First child should be 'a'") + XCTAssertEqual((children[1] as! SwiftRLMStringObject).stringCol, "b", "Second child should be 'b'") } // FIXME: Support unmanaged RLMArray's in Swift-defined models // func testUnmanaged() { // let realm = realmWithTestPath() // - // let array = SwiftArrayPropertyObject() + // let array = SwiftRLMArrayPropertyObject() // array.name = "name" // XCTAssertNotNil(array.array, "RLMArray property should get created on access") // - // let obj = SwiftStringObject() + // let obj = SwiftRLMStringObject() // obj.stringCol = "a" // array.array.addObject(obj) // array.array.addObject(obj) @@ -131,8 +132,8 @@ class SwiftArrayPropertyTests: RLMTestCase { // try! realm.commitWriteTransaction() // // XCTAssertEqual(array.array.count, UInt(2), "Should have two elements in array") - // XCTAssertEqual((array.array[0] as SwiftStringObject).stringCol, "a", "First element should have property value 'a'") - // XCTAssertEqual((array.array[1] as SwiftStringObject).stringCol, "a", "Second element should have property value 'a'") + // XCTAssertEqual((array.array[0] as SwiftRLMStringObject).stringCol, "a", "First element should have property value 'a'") + // XCTAssertEqual((array.array[1] as SwiftRLMStringObject).stringCol, "a", "Second element should have property value 'a'") // } // Objective-C models @@ -167,7 +168,7 @@ class SwiftArrayPropertyTests: RLMTestCase { let realm = realmWithTestPath() realm.beginWriteTransaction() - let array = ArrayPropertyObject.create(in: realm, withValue: ["arrayObject", [], []]); + let array = ArrayPropertyObject.create(in: realm, withValue: ["arrayObject", [], []]) XCTAssertNotNil(array.array, "Should be able to get an empty array") XCTAssertEqual(array.array.count, UInt(0), "Should start with no array elements") diff --git a/Realm/Tests/Swift/SwiftArrayTests.swift b/Realm/Tests/Swift/SwiftArrayTests.swift index a344d1d4d2..ee1484c6ac 100644 --- a/Realm/Tests/Swift/SwiftArrayTests.swift +++ b/Realm/Tests/Swift/SwiftArrayTests.swift @@ -19,8 +19,9 @@ import XCTest import Realm import Foundation +import RealmTestSupport -class SwiftArrayTests: RLMTestCase { +class SwiftRLMArrayTests: RLMTestCase { // Swift models @@ -32,26 +33,26 @@ class SwiftArrayTests: RLMTestCase { let dateMinInput = Date() let dateMaxInput = dateMinInput.addingTimeInterval(1000) - _ = SwiftAggregateObject.create(in: realm, withValue: [10, 1.2 as Float, 0 as Double, true, dateMinInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [10, 0 as Float, 2.5 as Double, false, dateMaxInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [10, 1.2 as Float, 0 as Double, true, dateMinInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [10, 0 as Float, 2.5 as Double, false, dateMaxInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [10, 1.2 as Float, 0 as Double, true, dateMinInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [10, 0 as Float, 2.5 as Double, false, dateMaxInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [10, 1.2 as Float, 0 as Double, true, dateMinInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [10, 0 as Float, 2.5 as Double, false, dateMaxInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [10, 1.2 as Float, 0 as Double, true, dateMinInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [10, 1.2 as Float, 0 as Double, true, dateMinInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [10, 1.2 as Float, 0 as Double, true, dateMinInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [10, 0 as Float, 2.5 as Double, false, dateMaxInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [10, 1.2 as Float, 0 as Double, true, dateMinInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [10, 0 as Float, 2.5 as Double, false, dateMaxInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [10, 1.2 as Float, 0 as Double, true, dateMinInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [10, 0 as Float, 2.5 as Double, false, dateMaxInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [10, 1.2 as Float, 0 as Double, true, dateMinInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [10, 0 as Float, 2.5 as Double, false, dateMaxInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [10, 1.2 as Float, 0 as Double, true, dateMinInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [10, 1.2 as Float, 0 as Double, true, dateMinInput]) try! realm.commitWriteTransaction() - let result = SwiftAggregateObject.objects(in: realm, where: "intCol < %d", 100) + let result = SwiftRLMAggregateObject.objects(in: realm, where: "intCol < %d", 100) XCTAssertEqual(result.count, UInt(10), "10 objects added") var totalSum = 0 for obj in result { - if let ao = obj as? SwiftAggregateObject { + if let ao = obj as? SwiftRLMAggregateObject { totalSum += ao.intCol } } @@ -67,21 +68,21 @@ class SwiftArrayTests: RLMTestCase { let dateMinInput = Date() let dateMaxInput = dateMinInput.addingTimeInterval(1000) - _ = SwiftAggregateObject.create(in: realm, withValue: [0, 1.2 as Float, 0 as Double, true, dateMinInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [1, 0 as Float, 2.5 as Double, false, dateMaxInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [0, 1.2 as Float, 0 as Double, true, dateMinInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [1, 0 as Float, 2.5 as Double, false, dateMaxInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [0, 1.2 as Float, 0 as Double, true, dateMinInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [1, 0 as Float, 2.5 as Double, false, dateMaxInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [0, 1.2 as Float, 0 as Double, true, dateMinInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [1, 0 as Float, 2.5 as Double, false, dateMaxInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [0, 1.2 as Float, 0 as Double, true, dateMinInput]) - _ = SwiftAggregateObject.create(in: realm, withValue: [0, 1.2 as Float, 0 as Double, true, dateMinInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [0, 1.2 as Float, 0 as Double, true, dateMinInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [1, 0 as Float, 2.5 as Double, false, dateMaxInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [0, 1.2 as Float, 0 as Double, true, dateMinInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [1, 0 as Float, 2.5 as Double, false, dateMaxInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [0, 1.2 as Float, 0 as Double, true, dateMinInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [1, 0 as Float, 2.5 as Double, false, dateMaxInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [0, 1.2 as Float, 0 as Double, true, dateMinInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [1, 0 as Float, 2.5 as Double, false, dateMaxInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [0, 1.2 as Float, 0 as Double, true, dateMinInput]) + _ = SwiftRLMAggregateObject.create(in: realm, withValue: [0, 1.2 as Float, 0 as Double, true, dateMinInput]) try! realm.commitWriteTransaction() - let noArray = SwiftAggregateObject.objects(in: realm, where: "boolCol == NO") - let yesArray = SwiftAggregateObject.objects(in: realm, where: "boolCol == YES") + let noArray = SwiftRLMAggregateObject.objects(in: realm, where: "boolCol == NO") + let yesArray = SwiftRLMAggregateObject.objects(in: realm, where: "boolCol == YES") // SUM :::::::::::::::::::::::::::::::::::::::::::::: // Test int sum @@ -166,7 +167,7 @@ class SwiftArrayTests: RLMTestCase { realm.beginWriteTransaction() for _ in 0..<1012 { - let person = SwiftEmployeeObject() + let person = SwiftRLMEmployeeObject() person.name = "Mary" person.age = 24 person.hired = true @@ -175,7 +176,7 @@ class SwiftArrayTests: RLMTestCase { try! realm.commitWriteTransaction() - let description = SwiftEmployeeObject.allObjects(in: realm).description + let description = SwiftRLMEmployeeObject.allObjects(in: realm).description XCTAssertTrue((description as NSString).range(of: "name").location != Foundation.NSNotFound, "property names should be displayed when calling \"description\" on RLMArray") XCTAssertTrue((description as NSString).range(of: "Mary").location != Foundation.NSNotFound, "property values should be displayed when calling \"description\" on RLMArray") @@ -191,17 +192,17 @@ class SwiftArrayTests: RLMTestCase { realm.beginWriteTransaction() - let po1 = SwiftEmployeeObject() + let po1 = SwiftRLMEmployeeObject() po1.age = 40 po1.name = "Joe" po1.hired = true - let po2 = SwiftEmployeeObject() + let po2 = SwiftRLMEmployeeObject() po2.age = 30 po2.name = "John" po2.hired = false - let po3 = SwiftEmployeeObject() + let po3 = SwiftRLMEmployeeObject() po3.age = 25 po3.name = "Jill" po3.hired = true @@ -210,9 +211,9 @@ class SwiftArrayTests: RLMTestCase { realm.add(po2) realm.add(po3) - let company = SwiftCompanyObject() + let company = SwiftRLMCompanyObject() realm.add(company) - company.employees.addObjects(SwiftEmployeeObject.allObjects(in: realm)) + company.employees.addObjects(SwiftRLMEmployeeObject.allObjects(in: realm)) try! realm.commitWriteTransaction() diff --git a/Realm/Tests/Swift/SwiftDynamicTests.swift b/Realm/Tests/Swift/SwiftDynamicTests.swift index c57741c84c..a964cae880 100644 --- a/Realm/Tests/Swift/SwiftDynamicTests.swift +++ b/Realm/Tests/Swift/SwiftDynamicTests.swift @@ -20,8 +20,9 @@ import XCTest import Foundation import Realm.Private import Realm.Dynamic +import RealmTestSupport -class SwiftDynamicTests: RLMTestCase { +class SwiftRLMDynamicTests: RLMTestCase { // Swift models @@ -30,24 +31,24 @@ class SwiftDynamicTests: RLMTestCase { // open realm in autoreleasepool to create tables and then dispose let realm = RLMRealm(url: RLMTestRealmURL()) realm.beginWriteTransaction() - _ = SwiftDynamicObject.create(in: realm, withValue: ["column1", 1]) - _ = SwiftDynamicObject.create(in: realm, withValue: ["column2", 2]) + _ = SwiftRLMDynamicObject.create(in: realm, withValue: ["column1", 1]) + _ = SwiftRLMDynamicObject.create(in: realm, withValue: ["column2", 2]) try! realm.commitWriteTransaction() } let dyrealm = realm(withTestPathAndSchema: nil) XCTAssertNotNil(dyrealm, "realm should not be nil") // verify schema - let dynSchema = dyrealm.schema[SwiftDynamicObject.className()] + let dynSchema = dyrealm.schema[SwiftRLMDynamicObject.className()] XCTAssertNotNil(dynSchema, "Should be able to get object schema dynamically") XCTAssertEqual(dynSchema.properties.count, Int(2)) XCTAssertEqual(dynSchema.properties[0].name, "stringCol") XCTAssertEqual(dynSchema.properties[1].type, RLMPropertyType.int) // verify object type - let array = SwiftDynamicObject.allObjects(in: dyrealm) + let array = SwiftRLMDynamicObject.allObjects(in: dyrealm) XCTAssertEqual(array.count, UInt(2)) - XCTAssertEqual(array.objectClassName, SwiftDynamicObject.className()) + XCTAssertEqual(array.objectClassName, SwiftRLMDynamicObject.className()) } func testDynamicProperties() { @@ -55,14 +56,14 @@ class SwiftDynamicTests: RLMTestCase { // open realm in autoreleasepool to create tables and then dispose let realm = RLMRealm(url: RLMTestRealmURL()) realm.beginWriteTransaction() - _ = SwiftDynamicObject.create(in: realm, withValue: ["column1", 1]) - _ = SwiftDynamicObject.create(in: realm, withValue: ["column2", 2]) + _ = SwiftRLMDynamicObject.create(in: realm, withValue: ["column1", 1]) + _ = SwiftRLMDynamicObject.create(in: realm, withValue: ["column2", 2]) try! realm.commitWriteTransaction() } // verify properties let dyrealm = realm(withTestPathAndSchema: nil) - let array = dyrealm.allObjects("SwiftDynamicObject") + let array = dyrealm.allObjects("SwiftRLMDynamicObject") XCTAssertTrue(array[0]["intCol"] as! NSNumber == 1) XCTAssertTrue(array[1]["stringCol"] as! String == "column2") @@ -75,24 +76,24 @@ class SwiftDynamicTests: RLMTestCase { // open realm in autoreleasepool to create tables and then dispose let realm = RLMRealm(url: RLMTestRealmURL()) realm.beginWriteTransaction() - _ = DynamicObject.create(in: realm, withValue: ["column1", 1]) - _ = DynamicObject.create(in: realm, withValue: ["column2", 2]) + _ = DynamicTestObject.create(in: realm, withValue: ["column1", 1]) + _ = DynamicTestObject.create(in: realm, withValue: ["column2", 2]) try! realm.commitWriteTransaction() } let dyrealm = realm(withTestPathAndSchema: nil) XCTAssertNotNil(dyrealm, "realm should not be nil") // verify schema - let dynSchema = dyrealm.schema[DynamicObject.className()] + let dynSchema = dyrealm.schema[DynamicTestObject.className()] XCTAssertNotNil(dynSchema, "Should be able to get object schema dynamically") XCTAssertTrue(dynSchema.properties.count == 2) XCTAssertTrue(dynSchema.properties[0].name == "stringCol") XCTAssertTrue(dynSchema.properties[1].type == RLMPropertyType.int) // verify object type - let array = DynamicObject.allObjects(in: dyrealm) + let array = DynamicTestObject.allObjects(in: dyrealm) XCTAssertEqual(array.count, UInt(2)) - XCTAssertEqual(array.objectClassName, DynamicObject.className()) + XCTAssertEqual(array.objectClassName, DynamicTestObject.className()) } func testDynamicProperties_objc() { @@ -100,14 +101,14 @@ class SwiftDynamicTests: RLMTestCase { // open realm in autoreleasepool to create tables and then dispose let realm = RLMRealm(url: RLMTestRealmURL()) realm.beginWriteTransaction() - _ = DynamicObject.create(in: realm, withValue: ["column1", 1]) - _ = DynamicObject.create(in: realm, withValue: ["column2", 2]) + _ = DynamicTestObject.create(in: realm, withValue: ["column1", 1]) + _ = DynamicTestObject.create(in: realm, withValue: ["column2", 2]) try! realm.commitWriteTransaction() } // verify properties let dyrealm = realm(withTestPathAndSchema: nil) - let array = dyrealm.allObjects("DynamicObject") + let array = dyrealm.allObjects("DynamicTestObject") XCTAssertTrue(array[0]["intCol"] as! NSNumber == 1) XCTAssertTrue(array[1]["stringCol"] as! String == "column2") diff --git a/Realm/Tests/Swift/SwiftLinkTests.swift b/Realm/Tests/Swift/SwiftLinkTests.swift index 5b2dea1064..66d7184153 100644 --- a/Realm/Tests/Swift/SwiftLinkTests.swift +++ b/Realm/Tests/Swift/SwiftLinkTests.swift @@ -18,72 +18,73 @@ import XCTest import Realm +import RealmTestSupport -class SwiftLinkTests: RLMTestCase { +class SwiftRLMLinkTests: RLMTestCase { // Swift models func testBasicLink() { let realm = realmWithTestPath() - let owner = SwiftOwnerObject() + let owner = SwiftRLMOwnerObject() owner.name = "Tim" - owner.dog = SwiftDogObject() + owner.dog = SwiftRLMDogObject() owner.dog!.dogName = "Harvie" realm.beginWriteTransaction() realm.add(owner) try! realm.commitWriteTransaction() - let owners = SwiftOwnerObject.allObjects(in: realm) - let dogs = SwiftDogObject.allObjects(in: realm) + let owners = SwiftRLMOwnerObject.allObjects(in: realm) + let dogs = SwiftRLMDogObject.allObjects(in: realm) XCTAssertEqual(owners.count, UInt(1), "Expecting 1 owner") XCTAssertEqual(dogs.count, UInt(1), "Expecting 1 dog") - XCTAssertEqual((owners[0] as! SwiftOwnerObject).name, "Tim", "Tim is named Tim") - XCTAssertEqual((dogs[0] as! SwiftDogObject).dogName, "Harvie", "Harvie is named Harvie") + XCTAssertEqual((owners[0] as! SwiftRLMOwnerObject).name, "Tim", "Tim is named Tim") + XCTAssertEqual((dogs[0] as! SwiftRLMDogObject).dogName, "Harvie", "Harvie is named Harvie") - let tim = owners[0] as! SwiftOwnerObject + let tim = owners[0] as! SwiftRLMOwnerObject XCTAssertEqual(tim.dog!.dogName, "Harvie", "Tim's dog should be Harvie") } func testMultipleOwnerLink() { let realm = realmWithTestPath() - let owner = SwiftOwnerObject() + let owner = SwiftRLMOwnerObject() owner.name = "Tim" - owner.dog = SwiftDogObject() + owner.dog = SwiftRLMDogObject() owner.dog!.dogName = "Harvie" realm.beginWriteTransaction() realm.add(owner) try! realm.commitWriteTransaction() - XCTAssertEqual(SwiftOwnerObject.allObjects(in: realm).count, UInt(1), "Expecting 1 owner") - XCTAssertEqual(SwiftDogObject.allObjects(in: realm).count, UInt(1), "Expecting 1 dog") + XCTAssertEqual(SwiftRLMOwnerObject.allObjects(in: realm).count, UInt(1), "Expecting 1 owner") + XCTAssertEqual(SwiftRLMDogObject.allObjects(in: realm).count, UInt(1), "Expecting 1 dog") realm.beginWriteTransaction() - let fiel = SwiftOwnerObject.create(in: realm, withValue: ["Fiel", NSNull()]) + let fiel = SwiftRLMOwnerObject.create(in: realm, withValue: ["Fiel", NSNull()]) fiel.dog = owner.dog try! realm.commitWriteTransaction() - XCTAssertEqual(SwiftOwnerObject.allObjects(in: realm).count, UInt(2), "Expecting 2 owners") - XCTAssertEqual(SwiftDogObject.allObjects(in: realm).count, UInt(1), "Expecting 1 dog") + XCTAssertEqual(SwiftRLMOwnerObject.allObjects(in: realm).count, UInt(2), "Expecting 2 owners") + XCTAssertEqual(SwiftRLMDogObject.allObjects(in: realm).count, UInt(1), "Expecting 1 dog") } func testLinkRemoval() { let realm = realmWithTestPath() - let owner = SwiftOwnerObject() + let owner = SwiftRLMOwnerObject() owner.name = "Tim" - owner.dog = SwiftDogObject() + owner.dog = SwiftRLMDogObject() owner.dog!.dogName = "Harvie" realm.beginWriteTransaction() realm.add(owner) try! realm.commitWriteTransaction() - XCTAssertEqual(SwiftOwnerObject.allObjects(in: realm).count, UInt(1), "Expecting 1 owner") - XCTAssertEqual(SwiftDogObject.allObjects(in: realm).count, UInt(1), "Expecting 1 dog") + XCTAssertEqual(SwiftRLMOwnerObject.allObjects(in: realm).count, UInt(1), "Expecting 1 owner") + XCTAssertEqual(SwiftRLMDogObject.allObjects(in: realm).count, UInt(1), "Expecting 1 dog") realm.beginWriteTransaction() realm.delete(owner.dog!) @@ -92,19 +93,19 @@ class SwiftLinkTests: RLMTestCase { XCTAssertNil(owner.dog, "Dog should be nullified when deleted") // refresh owner and check - let owner2 = SwiftOwnerObject.allObjects(in: realm).firstObject() as! SwiftOwnerObject + let owner2 = SwiftRLMOwnerObject.allObjects(in: realm).firstObject() as! SwiftRLMOwnerObject XCTAssertNotNil(owner2, "Should have 1 owner") XCTAssertNil(owner2.dog, "Dog should be nullified when deleted") - XCTAssertEqual(SwiftDogObject.allObjects(in: realm).count, UInt(0), "Expecting 0 dogs") + XCTAssertEqual(SwiftRLMDogObject.allObjects(in: realm).count, UInt(0), "Expecting 0 dogs") } func testLinkingObjects() { let realm = realmWithTestPath() - let target = SwiftLinkTargetObject() + let target = SwiftRLMLinkTargetObject() target.id = 0 - let source = SwiftLinkSourceObject() + let source = SwiftRLMLinkSourceObject() source.id = 1234 source.link = target @@ -116,14 +117,14 @@ class SwiftLinkTests: RLMTestCase { XCTAssertNotNil(target.realm) XCTAssertEqual(1, target.backlinks!.count) - XCTAssertEqual(1234, (target.backlinks!.firstObject() as! SwiftLinkSourceObject).id) + XCTAssertEqual(1234, (target.backlinks!.firstObject() as! SwiftRLMLinkSourceObject).id) } // FIXME - disabled until we fix commit log issue which break transacions when leaking realm objects // func testCircularLinks() { // let realm = realmWithTestPath() // -// let obj = SwiftCircleObject() +// let obj = SwiftRLMCircleObject() // obj.data = "a" // obj.next = obj // @@ -132,7 +133,7 @@ class SwiftLinkTests: RLMTestCase { // obj.next.data = "b" // try! realm.commitWriteTransaction() // -// let obj2 = SwiftCircleObject.allObjectsInRealm(realm).firstObject() as SwiftCircleObject +// let obj2 = SwiftRLMCircleObject.allObjectsInRealm(realm).firstObject() as SwiftRLMCircleObject // XCTAssertEqual(obj2.data, "b", "data should be 'b'") // XCTAssertEqual(obj2.data, obj2.next.data, "objects should be equal") // } diff --git a/Realm/Tests/Swift/SwiftObjectInterfaceTests.swift b/Realm/Tests/Swift/SwiftObjectInterfaceTests.swift index 958842821e..4c728ec7c1 100644 --- a/Realm/Tests/Swift/SwiftObjectInterfaceTests.swift +++ b/Realm/Tests/Swift/SwiftObjectInterfaceTests.swift @@ -19,6 +19,7 @@ import XCTest import Realm import Foundation +import RealmTestSupport class OuterClass { class InnerClass { @@ -26,16 +27,16 @@ class OuterClass { } } -class SwiftStringObjectSubclass : SwiftStringObject { +class SwiftRLMStringObjectSubclass: SwiftRLMStringObject { @objc dynamic var stringCol2 = "" } -class SwiftSelfRefrencingSubclass: SwiftStringObject { - @objc dynamic var objects = RLMArray(objectClassName: SwiftSelfRefrencingSubclass.className()) +class SwiftRLMSelfRefrencingSubclass: SwiftRLMStringObject { + @objc dynamic var objects = RLMArray(objectClassName: SwiftRLMSelfRefrencingSubclass.className()) } -class SwiftDefaultObject: RLMObject { +class SwiftRLMDefaultObject: RLMObject { @objc dynamic var intCol = 1 @objc dynamic var boolCol = true @@ -44,22 +45,22 @@ class SwiftDefaultObject: RLMObject { } } -class SwiftOptionalNumberObject: RLMObject { +class SwiftRLMOptionalNumberObject: RLMObject { @objc dynamic var intCol: NSNumber? = 1 @objc dynamic var floatCol: NSNumber? = 2.2 as Float as NSNumber @objc dynamic var doubleCol: NSNumber? = 3.3 @objc dynamic var boolCol: NSNumber? = true } -class SwiftObjectInterfaceTests: RLMTestCase { +class SwiftRLMObjectInterfaceTests: RLMTestCase { // Swift models - func testSwiftObject() { + func testSwiftRLMObject() { let realm = realmWithTestPath() realm.beginWriteTransaction() - let obj = SwiftObject() + let obj = SwiftRLMObject() realm.add(obj) obj.boolCol = true @@ -69,14 +70,14 @@ class SwiftObjectInterfaceTests: RLMTestCase { obj.stringCol = "abcd" obj.binaryCol = "abcd".data(using: String.Encoding.utf8) obj.dateCol = Date(timeIntervalSince1970: 123) - obj.objectCol = SwiftBoolObject() + obj.objectCol = SwiftRLMBoolObject() obj.objectCol.boolCol = true obj.arrayCol.add(obj.objectCol) try! realm.commitWriteTransaction() let data = "abcd".data(using: String.Encoding.utf8) - let firstObj = SwiftObject.allObjects(in: realm).firstObject() as! SwiftObject + let firstObj = SwiftRLMObject.allObjects(in: realm).firstObject() as! SwiftRLMObject XCTAssertEqual(firstObj.boolCol, true, "should be true") XCTAssertEqual(firstObj.intCol, 1234, "should be 1234") XCTAssertEqual(firstObj.floatCol, Float(1.1), "should be 1.1") @@ -89,15 +90,15 @@ class SwiftObjectInterfaceTests: RLMTestCase { XCTAssertEqual(obj.arrayCol.firstObject()!.boolCol, true, "should be true") } - func testDefaultValueSwiftObject() { + func testDefaultValueSwiftRLMObject() { let realm = realmWithTestPath() realm.beginWriteTransaction() - realm.add(SwiftObject()) + realm.add(SwiftRLMObject()) try! realm.commitWriteTransaction() let data = "a".data(using: String.Encoding.utf8) - let firstObj = SwiftObject.allObjects(in: realm).firstObject() as! SwiftObject + let firstObj = SwiftRLMObject.allObjects(in: realm).firstObject() as! SwiftRLMObject XCTAssertEqual(firstObj.boolCol, false, "should be false") XCTAssertEqual(firstObj.intCol, 123, "should be 123") XCTAssertEqual(firstObj.floatCol, Float(1.23), "should be 1.23") @@ -109,44 +110,44 @@ class SwiftObjectInterfaceTests: RLMTestCase { XCTAssertEqual(firstObj.arrayCol.count, UInt(0), "array count should be zero") } - func testMergedDefaultValuesSwiftObject() { + func testMergedDefaultValuesSwiftRLMObject() { let realm = self.realmWithTestPath() realm.beginWriteTransaction() - _ = SwiftDefaultObject.create(in: realm, withValue: NSDictionary()) + _ = SwiftRLMDefaultObject.create(in: realm, withValue: NSDictionary()) try! realm.commitWriteTransaction() - let object = SwiftDefaultObject.allObjects(in: realm).firstObject() as! SwiftDefaultObject + let object = SwiftRLMDefaultObject.allObjects(in: realm).firstObject() as! SwiftRLMDefaultObject XCTAssertEqual(object.intCol, 2, "defaultPropertyValues should override native property default value") XCTAssertEqual(object.boolCol, true, "native property default value should be used if defaultPropertyValues doesn't contain that key") } func testSubclass() { // test className methods - XCTAssertEqual("SwiftStringObject", SwiftStringObject.className()) - XCTAssertEqual("SwiftStringObjectSubclass", SwiftStringObjectSubclass.className()) + XCTAssertEqual("SwiftRLMStringObject", SwiftRLMStringObject.className()) + XCTAssertEqual("SwiftRLMStringObjectSubclass", SwiftRLMStringObjectSubclass.className()) let realm = RLMRealm.default() realm.beginWriteTransaction() - _ = SwiftStringObject.createInDefaultRealm(withValue: ["string"]) + _ = SwiftRLMStringObject.createInDefaultRealm(withValue: ["string"]) - _ = SwiftStringObjectSubclass.createInDefaultRealm(withValue: ["string", "string2"]) + _ = SwiftRLMStringObjectSubclass.createInDefaultRealm(withValue: ["string", "string2"]) try! realm.commitWriteTransaction() // ensure creation in proper table - XCTAssertEqual(UInt(1), SwiftStringObjectSubclass.allObjects().count) - XCTAssertEqual(UInt(1), SwiftStringObject.allObjects().count) + XCTAssertEqual(UInt(1), SwiftRLMStringObjectSubclass.allObjects().count) + XCTAssertEqual(UInt(1), SwiftRLMStringObject.allObjects().count) try! realm.transaction { // create self referencing subclass - let sub = SwiftSelfRefrencingSubclass.createInDefaultRealm(withValue: ["string", []]) - let sub2 = SwiftSelfRefrencingSubclass() + let sub = SwiftRLMSelfRefrencingSubclass.createInDefaultRealm(withValue: ["string", []]) + let sub2 = SwiftRLMSelfRefrencingSubclass() sub.objects.add(sub2) } } func testOptionalNSNumberProperties() { let realm = realmWithTestPath() - let no = SwiftOptionalNumberObject() + let no = SwiftRLMOptionalNumberObject() XCTAssertEqual([.int, .float, .double, .bool], no.objectSchema.properties.map { $0.type }) XCTAssertEqual(1, no.intCol!) @@ -180,11 +181,11 @@ class SwiftObjectInterfaceTests: RLMTestCase { XCTAssertEqual(false, no.boolCol!) } - func testOptionalSwiftProperties() { + func testOptionalSwiftRLMProperties() { let realm = realmWithTestPath() - try! realm.transaction { realm.add(SwiftOptionalObject()) } + try! realm.transaction { realm.add(SwiftRLMOptionalObject()) } - let firstObj = SwiftOptionalObject.allObjects(in: realm).firstObject() as! SwiftOptionalObject + let firstObj = SwiftRLMOptionalObject.allObjects(in: realm).firstObject() as! SwiftRLMOptionalObject XCTAssertNil(firstObj.optObjectCol) XCTAssertNil(firstObj.optStringCol) XCTAssertNil(firstObj.optNSStringCol) @@ -192,7 +193,7 @@ class SwiftObjectInterfaceTests: RLMTestCase { XCTAssertNil(firstObj.optDateCol) try! realm.transaction { - firstObj.optObjectCol = SwiftBoolObject() + firstObj.optObjectCol = SwiftRLMBoolObject() firstObj.optObjectCol!.boolCol = true firstObj.optStringCol = "Hi!" @@ -220,13 +221,13 @@ class SwiftObjectInterfaceTests: RLMTestCase { XCTAssertNil(firstObj.optDateCol) } - func testSwiftClassNameIsDemangled() { - XCTAssertEqual(SwiftObject.className(), "SwiftObject", + func testSwiftRLMClassNameIsDemangled() { + XCTAssertEqual(SwiftRLMObject.className(), "SwiftRLMObject", "Calling className() on Swift class should return demangled name") } func testPrimitiveArray() { - let obj = SwiftPrimitiveArrayObject() + let obj = SwiftRLMPrimitiveArrayObject() let str = "str" as NSString let data = "str".data(using: .utf8)! as Data as NSData let date = NSDate() @@ -298,17 +299,17 @@ class SwiftObjectInterfaceTests: RLMTestCase { func testCreateOrUpdate() { let realm = RLMRealm.default() realm.beginWriteTransaction() - _ = SwiftPrimaryStringObject.createOrUpdateInDefaultRealm(withValue: ["string", 1]) - let objects = SwiftPrimaryStringObject.allObjects(); - XCTAssertEqual(objects.count, UInt(1), "Should have 1 object"); - XCTAssertEqual((objects[0] as! SwiftPrimaryStringObject).intCol, 1, "Value should be 1"); + _ = SwiftRLMPrimaryStringObject.createOrUpdateInDefaultRealm(withValue: ["string", 1]) + let objects = SwiftRLMPrimaryStringObject.allObjects() + XCTAssertEqual(objects.count, UInt(1), "Should have 1 object") + XCTAssertEqual((objects[0] as! SwiftRLMPrimaryStringObject).intCol, 1, "Value should be 1") - _ = SwiftPrimaryStringObject.createOrUpdateInDefaultRealm(withValue: ["stringCol": "string2", "intCol": 2]) + _ = SwiftRLMPrimaryStringObject.createOrUpdateInDefaultRealm(withValue: ["stringCol": "string2", "intCol": 2]) XCTAssertEqual(objects.count, UInt(2), "Should have 2 objects") - _ = SwiftPrimaryStringObject.createOrUpdateInDefaultRealm(withValue: ["string", 3]) + _ = SwiftRLMPrimaryStringObject.createOrUpdateInDefaultRealm(withValue: ["string", 3]) XCTAssertEqual(objects.count, UInt(2), "Should have 2 objects") - XCTAssertEqual((objects[0] as! SwiftPrimaryStringObject).intCol, 3, "Value should be 3"); + XCTAssertEqual((objects[0] as! SwiftRLMPrimaryStringObject).intCol, 3, "Value should be 3") try! realm.commitWriteTransaction() } @@ -316,9 +317,9 @@ class SwiftObjectInterfaceTests: RLMTestCase { func testObjectForPrimaryKey() { let realm = RLMRealm.default() realm.beginWriteTransaction() - _ = SwiftPrimaryStringObject.createOrUpdateInDefaultRealm(withValue: ["string", 1]) + _ = SwiftRLMPrimaryStringObject.createOrUpdateInDefaultRealm(withValue: ["string", 1]) - let obj = SwiftPrimaryStringObject.object(forPrimaryKey: "string") + let obj = SwiftRLMPrimaryStringObject.object(forPrimaryKey: "string") XCTAssertNotNil(obj!) XCTAssertEqual(obj!.intCol, 1) @@ -328,13 +329,21 @@ class SwiftObjectInterfaceTests: RLMTestCase { // if this fails (and you haven't changed the test module name), the checks // for swift class names and the demangling logic need to be updated func testNSStringFromClassDemangledTopLevelClassNames() { +#if SWIFT_PACKAGE + XCTAssertEqual(NSStringFromClass(OuterClass.self), "RealmObjcSwiftTests.OuterClass") +#else XCTAssertEqual(NSStringFromClass(OuterClass.self), "Tests.OuterClass") +#endif } // if this fails (and you haven't changed the test module name), the prefix // check in RLMSchema initialization needs to be updated func testNestedClassNameMangling() { +#if SWIFT_PACKAGE + XCTAssertEqual(NSStringFromClass(OuterClass.InnerClass.self), "_TtCC19RealmObjcSwiftTests10OuterClass10InnerClass") +#else XCTAssertEqual(NSStringFromClass(OuterClass.InnerClass.self), "_TtCC5Tests10OuterClass10InnerClass") +#endif } } diff --git a/Realm/Tests/Swift/SwiftPropertyTypeTest.swift b/Realm/Tests/Swift/SwiftPropertyTypeTest.swift index 72cd2df385..0a77ef8460 100644 --- a/Realm/Tests/Swift/SwiftPropertyTypeTest.swift +++ b/Realm/Tests/Swift/SwiftPropertyTypeTest.swift @@ -18,8 +18,9 @@ import XCTest import Realm +import RealmTestSupport -class SwiftPropertyTypeTest: RLMTestCase { +class SwiftRLMPropertyTypeTest: RLMTestCase { func testLongType() { let longNumber: Int64 = 17179869184 @@ -30,22 +31,22 @@ class SwiftPropertyTypeTest: RLMTestCase { let realm = realmWithTestPath() realm.beginWriteTransaction() - _ = SwiftLongObject.create(in: realm, withValue: [NSNumber(value: longNumber)]) - _ = SwiftLongObject.create(in: realm, withValue: [NSNumber(value: intNumber)]) - _ = SwiftLongObject.create(in: realm, withValue: [NSNumber(value: negativeLongNumber)]) + _ = SwiftRLMLongObject.create(in: realm, withValue: [NSNumber(value: longNumber)]) + _ = SwiftRLMLongObject.create(in: realm, withValue: [NSNumber(value: intNumber)]) + _ = SwiftRLMLongObject.create(in: realm, withValue: [NSNumber(value: negativeLongNumber)]) try! realm.commitWriteTransaction() - let objects = SwiftLongObject.allObjects(in: realm) + let objects = SwiftRLMLongObject.allObjects(in: realm) XCTAssertEqual(objects.count, UInt(3), "3 rows expected") - XCTAssertEqual((objects[0] as! SwiftLongObject).longCol, longNumber, "2 ^ 34 expected") - XCTAssertEqual((objects[1] as! SwiftLongObject).longCol, intNumber, "2 ^ 31 - 1 expected") - XCTAssertEqual((objects[2] as! SwiftLongObject).longCol, negativeLongNumber, "-2 ^ 34 expected") + XCTAssertEqual((objects[0] as! SwiftRLMLongObject).longCol, longNumber, "2 ^ 34 expected") + XCTAssertEqual((objects[1] as! SwiftRLMLongObject).longCol, intNumber, "2 ^ 31 - 1 expected") + XCTAssertEqual((objects[2] as! SwiftRLMLongObject).longCol, negativeLongNumber, "-2 ^ 34 expected") realm.beginWriteTransaction() - (objects[0] as! SwiftLongObject).longCol = updatedLongNumber + (objects[0] as! SwiftRLMLongObject).longCol = updatedLongNumber try! realm.commitWriteTransaction() - XCTAssertEqual((objects[0] as! SwiftLongObject).longCol, updatedLongNumber, "After update: 2 ^ 33 expected") + XCTAssertEqual((objects[0] as! SwiftRLMLongObject).longCol, updatedLongNumber, "After update: 2 ^ 33 expected") } func testIntSizes() { @@ -57,7 +58,7 @@ class SwiftPropertyTypeTest: RLMTestCase { // 1 << 40 doesn't auto-promote to Int64 on 32-bit platforms let v64 = Int64(1) << 40 try! realm.transaction { - let obj = SwiftAllIntSizesObject() + let obj = SwiftRLMAllIntSizesObject() obj.int8 = v8 XCTAssertEqual(obj.int8, v8) @@ -71,7 +72,7 @@ class SwiftPropertyTypeTest: RLMTestCase { realm.add(obj) } - let obj = SwiftAllIntSizesObject.allObjects(in: realm)[0] as! SwiftAllIntSizesObject + let obj = SwiftRLMAllIntSizesObject.allObjects(in: realm)[0] as! SwiftRLMAllIntSizesObject XCTAssertEqual(obj.int8, v8) XCTAssertEqual(obj.int16, v16) XCTAssertEqual(obj.int32, v32) @@ -107,7 +108,7 @@ class SwiftPropertyTypeTest: RLMTestCase { func testLazyVarProperties() { let realm = realmWithTestPath() let succeeded : Void? = try? realm.transaction { - realm.add(SwiftLazyVarObject()) + realm.add(SwiftRLMLazyVarObject()) } XCTAssertNotNil(succeeded, "Writing an NSObject-based object with an lazy property should work.") } @@ -115,18 +116,18 @@ class SwiftPropertyTypeTest: RLMTestCase { func testIgnoredLazyVarProperties() { let realm = realmWithTestPath() let succeeded : Void? = try? realm.transaction { - realm.add(SwiftIgnoredLazyVarObject()) + realm.add(SwiftRLMIgnoredLazyVarObject()) } XCTAssertNotNil(succeeded, "Writing an object with an ignored lazy property should work.") } func testObjectiveCTypeProperties() { let realm = realmWithTestPath() - var object: SwiftObjectiveCTypesObject! + var object: SwiftRLMObjectiveCTypesObject! let now = NSDate() let data = "fizzbuzz".data(using: .utf8)! as Data as NSData try! realm.transaction { - object = SwiftObjectiveCTypesObject() + object = SwiftRLMObjectiveCTypesObject() realm.add(object) object.stringCol = "Hello world!" object.dateCol = now diff --git a/Realm/Tests/Swift/SwiftRealmTests.swift b/Realm/Tests/Swift/SwiftRealmTests.swift index a1291e42ab..91a80d51db 100644 --- a/Realm/Tests/Swift/SwiftRealmTests.swift +++ b/Realm/Tests/Swift/SwiftRealmTests.swift @@ -18,8 +18,9 @@ import XCTest import Realm +import RealmTestSupport -class SwiftRealmTests: RLMTestCase { +class SwiftRLMRealmTests: RLMTestCase { // No models @@ -40,26 +41,26 @@ class SwiftRealmTests: RLMTestCase { func testRealmAddAndRemoveObjects() { let realm = realmWithTestPath() realm.beginWriteTransaction() - _ = SwiftStringObject.create(in: realm, withValue: ["a"]) - _ = SwiftStringObject.create(in: realm, withValue: ["b"]) - _ = SwiftStringObject.create(in: realm, withValue: ["c"]) - XCTAssertEqual(SwiftStringObject.allObjects(in: realm).count, UInt(3), "Expecting 3 objects") + _ = SwiftRLMStringObject.create(in: realm, withValue: ["a"]) + _ = SwiftRLMStringObject.create(in: realm, withValue: ["b"]) + _ = SwiftRLMStringObject.create(in: realm, withValue: ["c"]) + XCTAssertEqual(SwiftRLMStringObject.allObjects(in: realm).count, UInt(3), "Expecting 3 objects") try! realm.commitWriteTransaction() // test again after write transaction - var objects = SwiftStringObject.allObjects(in: realm) + var objects = SwiftRLMStringObject.allObjects(in: realm) XCTAssertEqual(objects.count, UInt(3), "Expecting 3 objects") - XCTAssertEqual((objects[0] as! SwiftStringObject).stringCol, "a", "Expecting column to be 'a'") + XCTAssertEqual((objects[0] as! SwiftRLMStringObject).stringCol, "a", "Expecting column to be 'a'") realm.beginWriteTransaction() - realm.delete(objects[2] as! SwiftStringObject) - realm.delete(objects[0] as! SwiftStringObject) - XCTAssertEqual(SwiftStringObject.allObjects(in: realm).count, UInt(1), "Expecting 1 object") + realm.delete(objects[2] as! SwiftRLMStringObject) + realm.delete(objects[0] as! SwiftRLMStringObject) + XCTAssertEqual(SwiftRLMStringObject.allObjects(in: realm).count, UInt(1), "Expecting 1 object") try! realm.commitWriteTransaction() - objects = SwiftStringObject.allObjects(in: realm) + objects = SwiftRLMStringObject.allObjects(in: realm) XCTAssertEqual(objects.count, UInt(1), "Expecting 1 object") - XCTAssertEqual((objects[0] as! SwiftStringObject).stringCol, "b", "Expecting column to be 'b'") + XCTAssertEqual((objects[0] as! SwiftRLMStringObject).stringCol, "b", "Expecting column to be 'b'") } func testRealmIsUpdatedAfterBackgroundUpdate() { @@ -75,22 +76,22 @@ class SwiftRealmTests: RLMTestCase { dispatchAsync { let realm = self.realmWithTestPath() realm.beginWriteTransaction() - _ = SwiftStringObject.create(in: realm, withValue: ["string"]) + _ = SwiftRLMStringObject.create(in: realm, withValue: ["string"]) try! realm.commitWriteTransaction() } waitForExpectations(timeout: 2.0, handler: nil) token.invalidate() // get object - let objects = SwiftStringObject.allObjects(in: realm) + let objects = SwiftRLMStringObject.allObjects(in: realm) XCTAssertEqual(objects.count, UInt(1), "There should be 1 object of type StringObject") - XCTAssertEqual((objects[0] as! SwiftStringObject).stringCol, "string", "Value of first column should be 'string'") + XCTAssertEqual((objects[0] as! SwiftRLMStringObject).stringCol, "string", "Value of first column should be 'string'") } func testRealmIgnoresProperties() { let realm = realmWithTestPath() - let object = SwiftIgnoredPropertiesObject() + let object = SwiftRLMIgnoredPropertiesObject() realm.beginWriteTransaction() object.name = "@fz" object.age = 31 @@ -102,9 +103,9 @@ class SwiftRealmTests: RLMTestCase { object.runtimeProperty = NSObject() try! realm.commitWriteTransaction() - let objects = SwiftIgnoredPropertiesObject.allObjects(in: realm) - XCTAssertEqual(objects.count, UInt(1), "There should be 1 object of type SwiftIgnoredPropertiesObject") - let retrievedObject = objects[0] as! SwiftIgnoredPropertiesObject + let objects = SwiftRLMIgnoredPropertiesObject.allObjects(in: realm) + XCTAssertEqual(objects.count, UInt(1), "There should be 1 object of type SwiftRLMIgnoredPropertiesObject") + let retrievedObject = objects[0] as! SwiftRLMIgnoredPropertiesObject XCTAssertNil(retrievedObject.runtimeProperty, "Ignored property should be nil") XCTAssertEqual(retrievedObject.name, "@fz", "Value of the name column doesn't match the assigned one.") XCTAssertEqual(retrievedObject.objectSchema.properties.count, 2, "Only 'name' and 'age' properties should be detected by Realm") @@ -112,8 +113,8 @@ class SwiftRealmTests: RLMTestCase { func testUpdatingSortedArrayAfterBackgroundUpdate() { let realm = realmWithTestPath() - let objs = SwiftIntObject.allObjects(in: realm) - let objects = SwiftIntObject.allObjects(in: realm).sortedResults(usingKeyPath: "intCol", ascending: true) + let objs = SwiftRLMIntObject.allObjects(in: realm) + let objects = SwiftRLMIntObject.allObjects(in: realm).sortedResults(usingKeyPath: "intCol", ascending: true) let updateComplete = expectation(description: "background update complete") let token = realm.addNotificationBlock() { (_, _) in @@ -126,11 +127,11 @@ class SwiftRealmTests: RLMTestCase { dispatchAsync { let realm = self.realmWithTestPath() try! realm.transaction { - var obj = SwiftIntObject() + var obj = SwiftRLMIntObject() obj.intCol = 2; realm.add(obj) - obj = SwiftIntObject() + obj = SwiftRLMIntObject() obj.intCol = 1; realm.add(obj) } @@ -151,23 +152,23 @@ class SwiftRealmTests: RLMTestCase { dispatchAsync { let realm = self.realmWithTestPath() - let obj = SwiftStringObject(value: ["string"]) + let obj = SwiftRLMStringObject(value: ["string"]) realm.beginWriteTransaction() realm.add(obj) try! realm.commitWriteTransaction() - let objects = SwiftStringObject.allObjects(in: realm) + let objects = SwiftRLMStringObject.allObjects(in: realm) XCTAssertEqual(objects.count, UInt(1), "There should be 1 object of type StringObject") - XCTAssertEqual((objects[0] as! SwiftStringObject).stringCol, "string", "Value of first column should be 'string'") + XCTAssertEqual((objects[0] as! SwiftRLMStringObject).stringCol, "string", "Value of first column should be 'string'") } waitForExpectations(timeout: 2.0, handler: nil) token.invalidate() // get object - let objects = SwiftStringObject.allObjects(in: realm) + let objects = SwiftRLMStringObject.allObjects(in: realm) XCTAssertEqual(objects.count, UInt(1), "There should be 1 object of type RLMTestObject") - XCTAssertEqual((objects[0] as! SwiftStringObject).stringCol, "string", "Value of first column should be 'string'") + XCTAssertEqual((objects[0] as! SwiftRLMStringObject).stringCol, "string", "Value of first column should be 'string'") } // Objective-C models diff --git a/Realm/Tests/Swift/SwiftSchemaTests.swift b/Realm/Tests/Swift/SwiftSchemaTests.swift index 45bf87733a..a0c3ae3694 100644 --- a/Realm/Tests/Swift/SwiftSchemaTests.swift +++ b/Realm/Tests/Swift/SwiftSchemaTests.swift @@ -19,41 +19,42 @@ import XCTest import Realm import Realm.Private +import RealmTestSupport class InitLinkedToClass: RLMObject { - @objc dynamic var value = SwiftIntObject(value: [0]) + @objc dynamic var value: SwiftRLMIntObject! = SwiftRLMIntObject(value: [0]) } -class SwiftNonDefaultObject: RLMObject { +class SwiftRLMNonDefaultObject: RLMObject { @objc dynamic var value = 0 public override class func shouldIncludeInDefaultSchema() -> Bool { return false } } -class SwiftLinkedNonDefaultObject: RLMObject { - @objc dynamic var obj: SwiftNonDefaultObject? +class SwiftRLMLinkedNonDefaultObject: RLMObject { + @objc dynamic var obj: SwiftRLMNonDefaultObject? public override class func shouldIncludeInDefaultSchema() -> Bool { return false } } -class SwiftNonDefaultArrayObject: RLMObject { - @objc dynamic var array = RLMArray(objectClassName: SwiftNonDefaultObject.className()) +class SwiftRLMNonDefaultArrayObject: RLMObject { + @objc dynamic var array = RLMArray(objectClassName: SwiftRLMNonDefaultObject.className()) public override class func shouldIncludeInDefaultSchema() -> Bool { return false } } -class SwiftMutualLink1Object: RLMObject { - @objc dynamic var object: SwiftMutualLink2Object? +class SwiftRLMMutualLink1Object: RLMObject { + @objc dynamic var object: SwiftRLMMutualLink2Object? public override class func shouldIncludeInDefaultSchema() -> Bool { return false } } -class SwiftMutualLink2Object: RLMObject { - @objc dynamic var object: SwiftMutualLink1Object? +class SwiftRLMMutualLink2Object: RLMObject { + @objc dynamic var object: SwiftRLMMutualLink1Object? public override class func shouldIncludeInDefaultSchema() -> Bool { return false } @@ -61,18 +62,18 @@ class SwiftMutualLink2Object: RLMObject { class IgnoredLinkPropertyObject : RLMObject { @objc dynamic var value = 0 - var obj = SwiftIntObject() + var obj = SwiftRLMIntObject() override class func ignoredProperties() -> [String] { return ["obj"] } } -class SwiftRecursingSchemaTestObject : RLMObject { - @objc dynamic var propertyWithIllegalDefaultValue: SwiftIntObject? = { +class SwiftRLMRecursingSchemaTestObject : RLMObject { + @objc dynamic var propertyWithIllegalDefaultValue: SwiftRLMIntObject? = { if mayAccessSchema { let realm = RLMRealm.default() - return SwiftIntObject.allObjects().firstObject() as! SwiftIntObject? + return SwiftRLMIntObject.allObjects().firstObject() as! SwiftRLMIntObject? } else { return nil } @@ -82,24 +83,28 @@ class SwiftRecursingSchemaTestObject : RLMObject { } class InvalidArrayType: FakeObject { - @objc dynamic var array = RLMArray(objectClassName: "invalid class") + @objc dynamic var array = RLMArray(objectClassName: "invalid class") } class InitAppendsToArrayProperty : RLMObject { - @objc dynamic var propertyWithIllegalDefaultValue: RLMArray = { + @objc dynamic var propertyWithIllegalDefaultValue: RLMArray = { if mayAppend { - let array = RLMArray(objectClassName: SwiftIntObject.className()) - array.add(SwiftIntObject()) + let array = RLMArray(objectClassName: InitAppendsToArrayValue.className()) + array.add(InitAppendsToArrayValue()) return array } else { - return RLMArray(objectClassName: SwiftIntObject.className()) + return RLMArray(objectClassName: InitAppendsToArrayValue.className()) } }() static var mayAppend = false } -class SwiftSchemaTests: RLMMultiProcessTestCase { +class InitAppendsToArrayValue : RLMObject { + @objc dynamic var value: Int = 0 +} + +class SwiftRLMSchemaTests: RLMMultiProcessTestCase { func testWorksAtAll() { if isParent { XCTAssertEqual(0, runChildAndWait(), "Tests in child process failed") @@ -128,9 +133,9 @@ class SwiftSchemaTests: RLMMultiProcessTestCase { } // Object in default schema - _ = SwiftIntObject() + _ = SwiftRLMIntObject() // Object not in default schema - _ = SwiftNonDefaultObject() + _ = SwiftRLMNonDefaultObject() } func testCreateUnmanagedObjectWithNestedObjectWithUninitializedSchema() { @@ -146,12 +151,12 @@ class SwiftSchemaTests: RLMMultiProcessTestCase { _ = InitLinkedToClass() // Again with an object that links to an unintialized type // rather than creating one - _ = SwiftCompanyObject() + _ = SwiftRLMCompanyObject() // Objects not in default schema - _ = SwiftLinkedNonDefaultObject(value: [[1]]) - _ = SwiftNonDefaultArrayObject(value: [[[1]]]) - _ = SwiftMutualLink1Object(value: [[[:]]]) + _ = SwiftRLMLinkedNonDefaultObject(value: [[1]]) + _ = SwiftRLMNonDefaultArrayObject(value: [[[1]]]) + _ = SwiftRLMMutualLink1Object(value: [[[:]]]) } func testCreateUnmanagedObjectWhichCreatesAnotherClassViaInitWithValueDuringSchemaInit() { @@ -161,7 +166,7 @@ class SwiftSchemaTests: RLMMultiProcessTestCase { } _ = InitLinkedToClass(value: [[0]]) - _ = SwiftCompanyObject(value: [[["Jaden", 20, false]]]) + _ = SwiftRLMCompanyObject(value: [[["Jaden", 20, false]]]) } func testInitUnmanagedObjectNotInClassSubsetDuringSchemaInit() { @@ -186,7 +191,7 @@ class SwiftSchemaTests: RLMMultiProcessTestCase { return } - SwiftRecursingSchemaTestObject.mayAccessSchema = true + SwiftRLMRecursingSchemaTestObject.mayAccessSchema = true assertThrowsWithReasonMatching(RLMSchema.shared(), ".*recursive.*") } diff --git a/Realm/Tests/Swift/SwiftTestObjects.swift b/Realm/Tests/Swift/SwiftTestObjects.swift index 25d6771d36..c742192009 100644 --- a/Realm/Tests/Swift/SwiftTestObjects.swift +++ b/Realm/Tests/Swift/SwiftTestObjects.swift @@ -17,24 +17,25 @@ //////////////////////////////////////////////////////////////////////////// import Realm +import RealmTestSupport -class SwiftStringObject: RLMObject { +class SwiftRLMStringObject: RLMObject { @objc dynamic var stringCol = "" } -class SwiftBoolObject: RLMObject { +class SwiftRLMBoolObject: RLMObject { @objc dynamic var boolCol = false } -class SwiftIntObject: RLMObject { +class SwiftRLMIntObject: RLMObject { @objc dynamic var intCol = 0 } -class SwiftLongObject: RLMObject { +class SwiftRLMLongObject: RLMObject { @objc dynamic var longCol: Int64 = 0 } -class SwiftObject: RLMObject { +class SwiftRLMObject: RLMObject { @objc dynamic var boolCol = false @objc dynamic var intCol = 123 @objc dynamic var floatCol = 1.23 as Float @@ -42,19 +43,25 @@ class SwiftObject: RLMObject { @objc dynamic var stringCol = "a" @objc dynamic var binaryCol = "a".data(using: String.Encoding.utf8) @objc dynamic var dateCol = Date(timeIntervalSince1970: 1) - @objc dynamic var objectCol = SwiftBoolObject() - @objc dynamic var arrayCol = RLMArray(objectClassName: SwiftBoolObject.className()) + #if SWIFT_PACKAGE + // FIXME: we fail to check if an object property is actually optional unless + // RealmSwift happens to be loaded in the process + @objc dynamic var objectCol: SwiftRLMBoolObject! = SwiftRLMBoolObject() + #else + @objc dynamic var objectCol = SwiftRLMBoolObject() + #endif + @objc dynamic var arrayCol = RLMArray(objectClassName: SwiftRLMBoolObject.className()) } -class SwiftOptionalObject: RLMObject { +class SwiftRLMOptionalObject: RLMObject { @objc dynamic var optStringCol: String? @objc dynamic var optNSStringCol: NSString? @objc dynamic var optBinaryCol: Data? @objc dynamic var optDateCol: Date? - @objc dynamic var optObjectCol: SwiftBoolObject? + @objc dynamic var optObjectCol: SwiftRLMBoolObject? } -class SwiftPrimitiveArrayObject: RLMObject { +class SwiftRLMPrimitiveArrayObject: RLMObject { @objc dynamic var stringCol = RLMArray(objectType: .string, optional: false) @objc dynamic var optStringCol = RLMArray(objectType: .string, optional: true) @objc dynamic var dataCol = RLMArray(objectType: .data, optional: false) @@ -63,16 +70,16 @@ class SwiftPrimitiveArrayObject: RLMObject { @objc dynamic var optDateCol = RLMArray(objectType: .date, optional: true) } -class SwiftDogObject: RLMObject { +class SwiftRLMDogObject: RLMObject { @objc dynamic var dogName = "" } -class SwiftOwnerObject: RLMObject { +class SwiftRLMOwnerObject: RLMObject { @objc dynamic var name = "" - @objc dynamic var dog: SwiftDogObject? = SwiftDogObject() + @objc dynamic var dog: SwiftRLMDogObject? = SwiftRLMDogObject() } -class SwiftAggregateObject: RLMObject { +class SwiftRLMAggregateObject: RLMObject { @objc dynamic var intCol = 0 @objc dynamic var floatCol = 0 as Float @objc dynamic var doubleCol = 0.0 @@ -80,39 +87,39 @@ class SwiftAggregateObject: RLMObject { @objc dynamic var dateCol = Date() } -class SwiftAllIntSizesObject: RLMObject { - @objc dynamic var int8 : Int8 = 0 - @objc dynamic var int16 : Int16 = 0 - @objc dynamic var int32 : Int32 = 0 - @objc dynamic var int64 : Int64 = 0 +class SwiftRLMAllIntSizesObject: RLMObject { + @objc dynamic var int8: Int8 = 0 + @objc dynamic var int16: Int16 = 0 + @objc dynamic var int32: Int32 = 0 + @objc dynamic var int64: Int64 = 0 } -class SwiftEmployeeObject: RLMObject { +class SwiftRLMEmployeeObject: RLMObject { @objc dynamic var name = "" @objc dynamic var age = 0 @objc dynamic var hired = false } -class SwiftCompanyObject: RLMObject { - @objc dynamic var employees = RLMArray(objectClassName: SwiftEmployeeObject.className()) +class SwiftRLMCompanyObject: RLMObject { + @objc dynamic var employees = RLMArray(objectClassName: SwiftRLMEmployeeObject.className()) } -class SwiftArrayPropertyObject: RLMObject { +class SwiftRLMArrayPropertyObject: RLMObject { @objc dynamic var name = "" - @objc dynamic var array = RLMArray(objectClassName: SwiftStringObject.className()) - @objc dynamic var intArray = RLMArray(objectClassName: SwiftIntObject.className()) + @objc dynamic var array = RLMArray(objectClassName: SwiftRLMStringObject.className()) + @objc dynamic var intArray = RLMArray(objectClassName: SwiftRLMIntObject.className()) } -class SwiftDynamicObject: RLMObject { +class SwiftRLMDynamicObject: RLMObject { @objc dynamic var stringCol = "a" @objc dynamic var intCol = 0 } -class SwiftUTF8Object: RLMObject { +class SwiftRLMUTF8Object: RLMObject { @objc dynamic var 柱колоéнǢкƱаم👍 = "值значен™👍☞⎠‱௹♣︎☐▼❒∑⨌⧭иеمرحبا" } -class SwiftIgnoredPropertiesObject: RLMObject { +class SwiftRLMIgnoredPropertiesObject: RLMObject { @objc dynamic var name = "" @objc dynamic var age = 0 @objc dynamic var runtimeProperty: AnyObject? @@ -123,7 +130,7 @@ class SwiftIgnoredPropertiesObject: RLMObject { } } -class SwiftPrimaryStringObject: RLMObject { +class SwiftRLMPrimaryStringObject: RLMObject { @objc dynamic var stringCol = "" @objc dynamic var intCol = 0 @@ -132,31 +139,31 @@ class SwiftPrimaryStringObject: RLMObject { } } -class SwiftLinkSourceObject: RLMObject { +class SwiftRLMLinkSourceObject: RLMObject { @objc dynamic var id = 0 - @objc dynamic var link: SwiftLinkTargetObject? + @objc dynamic var link: SwiftRLMLinkTargetObject? } -class SwiftLinkTargetObject: RLMObject { +class SwiftRLMLinkTargetObject: RLMObject { @objc dynamic var id = 0 - @objc dynamic var backlinks: RLMLinkingObjects? + @objc dynamic var backlinks: RLMLinkingObjects? override class func linkingObjectsProperties() -> [String : RLMPropertyDescriptor] { - return ["backlinks": RLMPropertyDescriptor(with: SwiftLinkSourceObject.self, propertyName: "link")] + return ["backlinks": RLMPropertyDescriptor(with: SwiftRLMLinkSourceObject.self, propertyName: "link")] } } -class SwiftLazyVarObject : RLMObject { - @objc dynamic lazy var lazyProperty : String = "hello world" +class SwiftRLMLazyVarObject: RLMObject { + @objc dynamic lazy var lazyProperty: String = "hello world" } -class SwiftIgnoredLazyVarObject : RLMObject { +class SwiftRLMIgnoredLazyVarObject: RLMObject { @objc dynamic var id = 0 - @objc dynamic lazy var ignoredVar : String = "hello world" + @objc dynamic lazy var ignoredVar: String = "hello world" override class func ignoredProperties() -> [String] { return ["ignoredVar"] } } -class SwiftObjectiveCTypesObject: RLMObject { +class SwiftRLMObjectiveCTypesObject: RLMObject { @objc dynamic var stringCol: NSString? @objc dynamic var dateCol: NSDate? @objc dynamic var dataCol: NSData? diff --git a/Realm/Tests/Swift/SwiftUnicodeTests.swift b/Realm/Tests/Swift/SwiftUnicodeTests.swift index 726a78ec2f..f3c3207ba9 100644 --- a/Realm/Tests/Swift/SwiftUnicodeTests.swift +++ b/Realm/Tests/Swift/SwiftUnicodeTests.swift @@ -18,37 +18,38 @@ import XCTest import Realm +import RealmTestSupport let utf8TestString = "值значен™👍☞⎠‱௹♣︎☐▼❒∑⨌⧭иеمرحبا" -class SwiftUnicodeTests: RLMTestCase { +class SwiftRLMUnicodeTests: RLMTestCase { // Swift models func testUTF8StringContents() { let realm = realmWithTestPath() realm.beginWriteTransaction() - _ = SwiftStringObject.create(in: realm, withValue: [utf8TestString]) + _ = SwiftRLMStringObject.create(in: realm, withValue: [utf8TestString]) try! realm.commitWriteTransaction() - let obj1 = SwiftStringObject.allObjects(in: realm).firstObject() as! SwiftStringObject + let obj1 = SwiftRLMStringObject.allObjects(in: realm).firstObject() as! SwiftRLMStringObject XCTAssertEqual(obj1.stringCol, utf8TestString, "Storing and retrieving a string with UTF8 content should work") - let obj2 = SwiftStringObject.objects(in: realm, where: "stringCol == %@", utf8TestString).firstObject() as! SwiftStringObject + let obj2 = SwiftRLMStringObject.objects(in: realm, where: "stringCol == %@", utf8TestString).firstObject() as! SwiftRLMStringObject XCTAssertTrue(obj1.isEqual(to: obj2), "Querying a realm searching for a string with UTF8 content should work") } func testUTF8PropertyWithUTF8StringContents() { let realm = realmWithTestPath() realm.beginWriteTransaction() - _ = SwiftUTF8Object.create(in: realm, withValue: [utf8TestString]) + _ = SwiftRLMUTF8Object.create(in: realm, withValue: [utf8TestString]) try! realm.commitWriteTransaction() - let obj1 = SwiftUTF8Object.allObjects(in: realm).firstObject() as! SwiftUTF8Object + let obj1 = SwiftRLMUTF8Object.allObjects(in: realm).firstObject() as! SwiftRLMUTF8Object XCTAssertEqual(obj1.柱колоéнǢкƱаم👍, utf8TestString, "Storing and retrieving a string with UTF8 content should work") // Test fails because of rdar://17735684 -// let obj2 = SwiftUTF8Object.objectsInRealm(realm, "柱колоéнǢкƱаم👍 == %@", utf8TestString).firstObject() as SwiftUTF8Object +// let obj2 = SwiftRLMUTF8Object.objectsInRealm(realm, "柱колоéнǢкƱаم👍 == %@", utf8TestString).firstObject() as SwiftRLMUTF8Object // XCTAssertEqual(obj1, obj2, "Querying a realm searching for a string with UTF8 content should work") } diff --git a/Realm/Tests/TestUtils.mm b/Realm/Tests/TestUtils.mm deleted file mode 100644 index 731b86d751..0000000000 --- a/Realm/Tests/TestUtils.mm +++ /dev/null @@ -1,48 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2015 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -#import "TestUtils.h" - -#import -#import -#import "RLMRealmUtil.hpp" - -void RLMAssertThrowsWithReasonMatchingSwift(XCTestCase *self, - __attribute__((noescape)) dispatch_block_t block, - NSString *regexString, NSString *message, - NSString *fileName, NSUInteger lineNumber) { - BOOL didThrow = NO; - @try { - block(); - } - @catch (NSException *e) { - didThrow = YES; - NSString *reason = e.reason; - NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regexString options:(NSRegularExpressionOptions)0 error:nil]; - if ([regex numberOfMatchesInString:reason options:(NSMatchingOptions)0 range:NSMakeRange(0, reason.length)] == 0) { - NSString *msg = [NSString stringWithFormat:@"The given expression threw an exception with reason '%@', but expected to match '%@'", - reason, regexString]; - [self recordFailureWithDescription:msg inFile:fileName atLine:lineNumber expected:NO]; - } - } - if (!didThrow) { - NSString *prefix = @"The given expression failed to throw an exception"; - message = message ? [NSString stringWithFormat:@"%@ (%@)", prefix, message] : prefix; - [self recordFailureWithDescription:message inFile:fileName atLine:lineNumber expected:NO]; - } -} diff --git a/Realm/Tests/UtilTests.mm b/Realm/Tests/UtilTests.mm index ba239d7c8c..996c4e400d 100644 --- a/Realm/Tests/UtilTests.mm +++ b/Realm/Tests/UtilTests.mm @@ -20,7 +20,10 @@ #import "RLMConstants.h" #import "RLMUtil.hpp" + +#ifndef REALM_COCOA_VERSION #import "RLMVersion.h" +#endif #import "shared_realm.hpp" diff --git a/RealmSwift.podspec b/RealmSwift.podspec index a510057364..f8db6bd7c8 100644 --- a/RealmSwift.podspec +++ b/RealmSwift.podspec @@ -19,6 +19,7 @@ Pod::Spec.new do |s| s.dependency 'Realm', "= #{s.version}" s.source_files = 'RealmSwift/*.swift' + s.exclude_files = 'RealmSwift/Nonsync.swift' s.prepare_command = 'sh build.sh cocoapods-setup swift' s.preserve_paths = %w(build.sh) diff --git a/RealmSwift/Nonsync.swift b/RealmSwift/Nonsync.swift new file mode 100644 index 0000000000..e664df7e6f --- /dev/null +++ b/RealmSwift/Nonsync.swift @@ -0,0 +1,27 @@ +//////////////////////////////////////////////////////////////////////////// +// +// Copyright 2019 Realm Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////// + +import Realm.Private + +public struct SyncConfiguration { + func asConfig() -> RLMSyncConfiguration? { return nil } + init?(config: RLMSyncConfiguration) { return nil } +} + +public struct SyncSubscription { +} diff --git a/RealmSwift/Object.swift b/RealmSwift/Object.swift index 7d9f3bf818..84ab084be2 100644 --- a/RealmSwift/Object.swift +++ b/RealmSwift/Object.swift @@ -396,13 +396,20 @@ public final class DynamicObject: Object { @objc(RealmSwiftObjectUtil) public class ObjectUtil: NSObject { @objc private class func swiftVersion() -> NSString { +#if SWIFT_PACKAGE + return "5.1" +#else return swiftLanguageVersion as NSString +#endif } @objc private class func ignoredPropertiesForClass(_ type: AnyClass) -> NSArray? { if let type = type as? Object.Type { return type.ignoredProperties() as NSArray? } + if let type = type as? RLMObject.Type { + return type.ignoredProperties() as NSArray? + } return nil } @@ -410,10 +417,16 @@ public class ObjectUtil: NSObject { if let type = type as? Object.Type { return type.indexedProperties() as NSArray? } + if let type = type as? RLMObject.Type { + return type.indexedProperties() as NSArray? + } return nil } @objc private class func linkingObjectsPropertiesForClass(_ type: AnyClass) -> NSDictionary? { + if let type = type as? RLMObject.Type { + return type.linkingObjectsProperties() as NSDictionary? + } // Not used for Swift. getLinkingObjectsProperties(_:) is used instead. return nil } @@ -462,6 +475,11 @@ public class ObjectUtil: NSObject { // Ignored lazy property. return false } + if object is RLMObject { + // Implicitly ignore lazy properties on RLMObject subclasses + // FIXME: should align RLMObject/Object behavior in 4.0 + return false + } // Managed lazy property; not currently supported. // FIXME: revisit this once Swift gets property behaviors/property macros. throwRealmException("Lazy managed property '\(lazyBaseName)' is not allowed on a Realm Swift object" diff --git a/RealmSwift/ObjectiveCSupport+Sync.swift b/RealmSwift/ObjectiveCSupport+Sync.swift new file mode 100644 index 0000000000..c00cb9cb35 --- /dev/null +++ b/RealmSwift/ObjectiveCSupport+Sync.swift @@ -0,0 +1,49 @@ +//////////////////////////////////////////////////////////////////////////// +// +// Copyright 2015 Realm Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////// + +import Realm + +/** + :nodoc: + **/ +public extension ObjectiveCSupport { + /// Convert a `SyncCredentials` to a `RLMSyncCredentials`. + static func convert(object: SyncCredentials) -> RLMSyncCredentials { + return RLMSyncCredentials(object) + } + + /// Convert a `RLMSyncCredentials` to a `SyncCredentials`. + static func convert(object: RLMSyncCredentials) -> SyncCredentials { + return SyncCredentials(object) + } + + /// Convert a `SyncConfiguration` to a `RLMSyncConfiguration`. + static func convert(object: SyncConfiguration) -> RLMSyncConfiguration { + return object.asConfig() + } + + /// Convert a `RLMSyncConfiguration` to a `SyncConfiguration`. + static func convert(object: RLMSyncConfiguration) -> SyncConfiguration { + return SyncConfiguration(config: object) + } + + /// Convert a `RLMSyncSubscription` to a `SyncSubscription`. + static func convert(object: RLMSyncSubscription) -> SyncSubscription { + return SyncSubscription(object) + } +} diff --git a/RealmSwift/ObjectiveCSupport.swift b/RealmSwift/ObjectiveCSupport.swift index 3c94c720c1..db69e27efa 100644 --- a/RealmSwift/ObjectiveCSupport.swift +++ b/RealmSwift/ObjectiveCSupport.swift @@ -130,16 +130,6 @@ public final class ObjectiveCSupport { return SortDescriptor(keyPath: object.keyPath, ascending: object.ascending) } - /// Convert a `SyncCredentials` to a `RLMSyncCredentials`. - public static func convert(object: SyncCredentials) -> RLMSyncCredentials { - return RLMSyncCredentials(object) - } - - /// Convert a `RLMSyncCredentials` to a `SyncCredentials`. - public static func convert(object: RLMSyncCredentials) -> SyncCredentials { - return SyncCredentials(object) - } - /// Convert a `RLMShouldCompactOnLaunchBlock` to a Realm Swift compact block. public static func convert(object: @escaping RLMShouldCompactOnLaunchBlock) -> (Int, Int) -> Bool { return { totalBytes, usedBytes in @@ -153,19 +143,4 @@ public final class ObjectiveCSupport { return object(Int(totalBytes), Int(usedBytes)) } } - - /// Convert a `SyncConfiguration` to a `RLMSyncConfiguration`. - public static func convert(object: SyncConfiguration) -> RLMSyncConfiguration { - return object.asConfig() - } - - /// Convert a `RLMSyncConfiguration` to a `SyncConfiguration`. - public static func convert(object: RLMSyncConfiguration) -> SyncConfiguration { - return SyncConfiguration(config: object) - } - - /// Convert a `RLMSyncSubscription` to a `SyncSubscription`. - public static func convert(object: RLMSyncSubscription) -> SyncSubscription { - return SyncSubscription(object) - } } diff --git a/RealmSwift/Sync.swift b/RealmSwift/Sync.swift index 456558c8c7..66f1bdf937 100644 --- a/RealmSwift/Sync.swift +++ b/RealmSwift/Sync.swift @@ -904,7 +904,7 @@ public enum SyncSubscriptionState: Equatable { /// Changes to the state of the subscription can be observed using `SyncSubscription.observe(_:options:_:)`. /// /// Subscriptions are created using `Results.subscribe()` or `Results.subscribe(named:)`. -public class SyncSubscription: RealmCollectionValue { +public final class SyncSubscription: RealmCollectionValue { private let rlmSubscription: RLMSyncSubscription /// The name of the subscription. @@ -1018,6 +1018,16 @@ public class SyncSubscription: RealmCollectionValue { } } +// :nodoc: +extension SyncSubscription: CustomObjectiveCBridgeable { + static func bridging(objCValue: Any) -> SyncSubscription { + return ObjectiveCSupport.convert(object: RLMCastToSyncSubscription(objCValue)) as! SyncSubscription + } + var objCValue: Any { + return 0 + } +} + extension Results { // MARK: Sync diff --git a/RealmSwift/Tests/KVOTests.swift b/RealmSwift/Tests/KVOTests.swift index 1519443556..cd0aea2931 100644 --- a/RealmSwift/Tests/KVOTests.swift +++ b/RealmSwift/Tests/KVOTests.swift @@ -25,7 +25,7 @@ func nextPrimaryKey() -> Int { return pkCounter } -class KVOObject: Object { +class SwiftKVOObject: Object { @objc dynamic var pk = nextPrimaryKey() // primary key for equality @objc dynamic var ignored: Int = 0 @@ -39,8 +39,8 @@ class KVOObject: Object { @objc dynamic var stringCol: String = "" @objc dynamic var binaryCol: Data = Data() @objc dynamic var dateCol: Date = Date(timeIntervalSince1970: 0) - @objc dynamic var objectCol: KVOObject? - let arrayCol = List() + @objc dynamic var objectCol: SwiftKVOObject? + let arrayCol = List() let optIntCol = RealmOptional() let optFloatCol = RealmOptional() let optDoubleCol = RealmOptional() @@ -100,7 +100,7 @@ class KVOTests: TestCase { } // swiftlint:disable:next cyclomatic_complexity - func observeChange(_ obj: KVOObject, _ key: String, _ old: T?, _ new: T?, + func observeChange(_ obj: SwiftKVOObject, _ key: String, _ old: T?, _ new: T?, fileName: StaticString = #file, lineNumber: UInt = #line, _ block: () -> Void) { let kvoOptions: NSKeyValueObservingOptions = [.old, .new] obj.addObserver(self, forKeyPath: key, options: kvoOptions, context: nil) @@ -123,7 +123,7 @@ class KVOTests: TestCase { changeDictionary = nil } - func observeChange(_ obj: KVOObject, _ keyPath: KeyPath, _ old: Any?, _ new: Any?, + func observeChange(_ obj: SwiftKVOObject, _ keyPath: KeyPath, _ old: Any?, _ new: Any?, fileName: StaticString = #file, lineNumber: UInt = #line, _ block: () -> Void) { let kvoOptions: NSKeyValueObservingOptions = [.old, .new] var gotNotification = false @@ -165,14 +165,14 @@ class KVOTests: TestCase { changeDictionary = nil } - func getObject(_ obj: KVOObject) -> (KVOObject, KVOObject) { + func getObject(_ obj: SwiftKVOObject) -> (SwiftKVOObject, SwiftKVOObject) { return (obj, obj) } // Actual tests follow func testAllPropertyTypes() { - let (obj, obs) = getObject(KVOObject()) + let (obj, obs) = getObject(SwiftKVOObject()) observeChange(obs, "boolCol", false, true) { obj.boolCol = true } observeChange(obs, "int8Col", 1 as Int8, 10) { obj.int8Col = 10 } @@ -248,14 +248,14 @@ class KVOTests: TestCase { self.realm.delete(obj) } - let (obj2, obs2) = getObject(KVOObject()) + let (obj2, obs2) = getObject(SwiftKVOObject()) observeChange(obs2, "arrayCol.invalidated", false, true) { self.realm.delete(obj2) } } func testTypedObservation() { - let (obj, obs) = getObject(KVOObject()) + let (obj, obs) = getObject(SwiftKVOObject()) observeChange(obs, \.boolCol, false, true) { obj.boolCol = true } @@ -299,23 +299,23 @@ class KVOTests: TestCase { } func testReadSharedSchemaFromObservedObject() { - let obj = KVOObject() + let obj = SwiftKVOObject() obj.addObserver(self, forKeyPath: "boolCol", options: [.old, .new], context: nil) - XCTAssertEqual(type(of: obj).sharedSchema(), KVOObject.sharedSchema()) + XCTAssertEqual(type(of: obj).sharedSchema(), SwiftKVOObject.sharedSchema()) obj.removeObserver(self, forKeyPath: "boolCol") } } class KVOPersistedTests: KVOTests { - override func getObject(_ obj: KVOObject) -> (KVOObject, KVOObject) { + override func getObject(_ obj: SwiftKVOObject) -> (SwiftKVOObject, SwiftKVOObject) { realm.add(obj) return (obj, obj) } } class KVOMultipleAccessorsTests: KVOTests { - override func getObject(_ obj: KVOObject) -> (KVOObject, KVOObject) { + override func getObject(_ obj: SwiftKVOObject) -> (SwiftKVOObject, SwiftKVOObject) { realm.add(obj) - return (obj, realm.object(ofType: KVOObject.self, forPrimaryKey: obj.pk)!) + return (obj, realm.object(ofType: SwiftKVOObject.self, forPrimaryKey: obj.pk)!) } } diff --git a/RealmSwift/Tests/ObjectAccessorTests.swift b/RealmSwift/Tests/ObjectAccessorTests.swift index 74d6dfbd55..7b31f70948 100644 --- a/RealmSwift/Tests/ObjectAccessorTests.swift +++ b/RealmSwift/Tests/ObjectAccessorTests.swift @@ -356,11 +356,11 @@ class ObjectAccessorTests: TestCase { } func testRenamedProperties() { - let obj = RenamedProperties1() + let obj = SwiftRenamedProperties1() obj.propA = 5 obj.propB = "a" - let link = LinkToRenamedProperties1() + let link = LinkToSwiftRenamedProperties1() link.linkA = obj link.array1.append(obj) @@ -377,14 +377,14 @@ class ObjectAccessorTests: TestCase { XCTAssertEqual(obj["propA"]! as! Int, 5) XCTAssertEqual(obj["propB"]! as! String, "a") - XCTAssertTrue((link["linkA"]! as! RenamedProperties1).isSameObject(as: obj)) - XCTAssertTrue((link["array1"]! as! List)[0].isSameObject(as: obj)) - XCTAssertTrue((obj["linking1"]! as! LinkingObjects)[0].isSameObject(as: link)) + XCTAssertTrue((link["linkA"]! as! SwiftRenamedProperties1).isSameObject(as: obj)) + XCTAssertTrue((link["array1"]! as! List)[0].isSameObject(as: obj)) + XCTAssertTrue((obj["linking1"]! as! LinkingObjects)[0].isSameObject(as: link)) XCTAssertTrue(link.dynamicList("array1")[0].isSameObject(as: obj)) - let obj2 = realm.objects(RenamedProperties2.self).first! - let link2 = realm.objects(LinkToRenamedProperties2.self).first! + let obj2 = realm.objects(SwiftRenamedProperties2.self).first! + let link2 = realm.objects(LinkToSwiftRenamedProperties2.self).first! XCTAssertEqual(obj2.propC, 5) XCTAssertEqual(obj2.propD, "a") @@ -394,9 +394,9 @@ class ObjectAccessorTests: TestCase { XCTAssertEqual(obj2["propC"]! as! Int, 5) XCTAssertEqual(obj2["propD"]! as! String, "a") - XCTAssertTrue((link2["linkC"]! as! RenamedProperties1).isSameObject(as: obj)) - XCTAssertTrue((link2["array2"]! as! List)[0].isSameObject(as: obj)) - XCTAssertTrue((obj2["linking1"]! as! LinkingObjects)[0].isSameObject(as: link)) + XCTAssertTrue((link2["linkC"]! as! SwiftRenamedProperties1).isSameObject(as: obj)) + XCTAssertTrue((link2["array2"]! as! List)[0].isSameObject(as: obj)) + XCTAssertTrue((obj2["linking1"]! as! LinkingObjects)[0].isSameObject(as: link)) XCTAssertTrue(link2.dynamicList("array2")[0].isSameObject(as: obj)) } diff --git a/RealmSwift/Tests/ObjectTests.swift b/RealmSwift/Tests/ObjectTests.swift index f58d0250fa..e400948673 100644 --- a/RealmSwift/Tests/ObjectTests.swift +++ b/RealmSwift/Tests/ObjectTests.swift @@ -25,7 +25,7 @@ private func nextDynamicDefaultSeed() -> Int { dynamicDefaultSeed += 1 return dynamicDefaultSeed } -class DynamicDefaultObject: Object { +class SwiftDynamicDefaultObject: Object { @objc dynamic var intCol = nextDynamicDefaultSeed() @objc dynamic var floatCol = Float(nextDynamicDefaultSeed()) @objc dynamic var doubleCol = Double(nextDynamicDefaultSeed()) @@ -121,15 +121,15 @@ class ObjectTests: TestCase { recursiveObject.objects.append(recursiveObject) assertMatches(recursiveObject.description, "SwiftRecursiveObject \\{\n\tobjects = List <0x[0-9a-f]+> \\(\n\t\t\\[0\\] SwiftRecursiveObject \\{\n\t\t\tobjects = List <0x[0-9a-f]+> \\(\n\t\t\t\t\\[0\\] SwiftRecursiveObject \\{\n\t\t\t\t\tobjects = ;\n\t\t\t\t\\}\n\t\t\t\\);\n\t\t\\}\n\t\\);\n\\}") - let renamedObject = LinkToRenamedProperties1() - renamedObject.linkA = RenamedProperties1() - assertMatches(renamedObject.description, "LinkToRenamedProperties1 \\{\n\tlinkA = RenamedProperties1 \\{\n\t\tpropA = 0;\n\t\tpropB = ;\n\t\\};\n\tlinkB = \\(null\\);\n\tarray1 = List <0x[0-9a-f]+> \\(\n\t\n\t\\);\n\\}") - assertMatches(renamedObject.linkA!.linking1.description, "LinkingObjects <0x[0-9a-f]+> \\(\n\n\\)") + let renamedObject = LinkToSwiftRenamedProperties1() + renamedObject.linkA = SwiftRenamedProperties1() + assertMatches(renamedObject.description, "LinkToSwiftRenamedProperties1 \\{\n\tlinkA = SwiftRenamedProperties1 \\{\n\t\tpropA = 0;\n\t\tpropB = ;\n\t\\};\n\tlinkB = \\(null\\);\n\tarray1 = List <0x[0-9a-f]+> \\(\n\t\n\t\\);\n\\}") + assertMatches(renamedObject.linkA!.linking1.description, "LinkingObjects <0x[0-9a-f]+> \\(\n\n\\)") let realm = try! Realm() try! realm.write { realm.add(renamedObject) } - assertMatches(renamedObject.description, "LinkToRenamedProperties1 \\{\n\tlinkA = RenamedProperties1 \\{\n\t\tpropA = 0;\n\t\tpropB = ;\n\t\\};\n\tlinkB = \\(null\\);\n\tarray1 = List <0x[0-9a-f]+> \\(\n\t\n\t\\);\n\\}") - assertMatches(renamedObject.linkA!.linking1.description, "LinkingObjects <0x[0-9a-f]+> \\(\n\t\\[0\\] LinkToRenamedProperties1 \\{\n\t\tlinkA = RenamedProperties1 \\{\n\t\t\tpropA = 0;\n\t\t\tpropB = ;\n\t\t\\};\n\t\tlinkB = \\(null\\);\n\t\tarray1 = List <0x[0-9a-f]+> \\(\n\t\t\n\t\t\\);\n\t\\}\n\\)") + assertMatches(renamedObject.description, "LinkToSwiftRenamedProperties1 \\{\n\tlinkA = SwiftRenamedProperties1 \\{\n\t\tpropA = 0;\n\t\tpropB = ;\n\t\\};\n\tlinkB = \\(null\\);\n\tarray1 = List <0x[0-9a-f]+> \\(\n\t\n\t\\);\n\\}") + assertMatches(renamedObject.linkA!.linking1.description, "LinkingObjects <0x[0-9a-f]+> \\(\n\t\\[0\\] LinkToSwiftRenamedProperties1 \\{\n\t\tlinkA = SwiftRenamedProperties1 \\{\n\t\t\tpropA = 0;\n\t\t\tpropB = ;\n\t\t\\};\n\t\tlinkB = \\(null\\);\n\t\tarray1 = List <0x[0-9a-f]+> \\(\n\t\t\n\t\t\\);\n\t\\}\n\\)") // swiftlint:enable line_length } @@ -221,7 +221,7 @@ class ObjectTests: TestCase { } func testDynamicDefaultPropertyValues() { - func assertDifferentPropertyValues(_ obj1: DynamicDefaultObject, _ obj2: DynamicDefaultObject) { + func assertDifferentPropertyValues(_ obj1: SwiftDynamicDefaultObject, _ obj2: SwiftDynamicDefaultObject) { XCTAssertNotEqual(obj1.intCol, obj2.intCol) XCTAssertNotEqual(obj1.floatCol, obj2.floatCol) XCTAssertNotEqual(obj1.doubleCol, obj2.doubleCol) @@ -230,11 +230,11 @@ class ObjectTests: TestCase { XCTAssertNotEqual(obj1.stringCol, obj2.stringCol) XCTAssertNotEqual(obj1.binaryCol, obj2.binaryCol) } - assertDifferentPropertyValues(DynamicDefaultObject(), DynamicDefaultObject()) + assertDifferentPropertyValues(SwiftDynamicDefaultObject(), SwiftDynamicDefaultObject()) let realm = try! Realm() try! realm.write { - assertDifferentPropertyValues(realm.create(DynamicDefaultObject.self), - realm.create(DynamicDefaultObject.self)) + assertDifferentPropertyValues(realm.create(SwiftDynamicDefaultObject.self), + realm.create(SwiftDynamicDefaultObject.self)) } } diff --git a/RealmSwift/Tests/ObjectiveCSupportTests.swift b/RealmSwift/Tests/ObjectiveCSupportTests.swift index 676f3f728e..f56b0bf6a0 100644 --- a/RealmSwift/Tests/ObjectiveCSupportTests.swift +++ b/RealmSwift/Tests/ObjectiveCSupportTests.swift @@ -59,12 +59,10 @@ class ObjectiveCSupportTests: TestCase { } func testConfigurationSupport() { - let realm = try! Realm() try! realm.write { realm.add(SwiftObject()) - return } XCTAssertEqual(realm.configuration.fileURL, @@ -75,9 +73,11 @@ class ObjectiveCSupportTests: TestCase { ObjectiveCSupport.convert(object: realm.configuration).inMemoryIdentifier, "Configuration.inMemoryIdentifier must be equal to RLMConfiguration.inMemoryIdentifier") + #if !SWIFT_PACKAGE XCTAssertEqual(realm.configuration.syncConfiguration?.realmURL, ObjectiveCSupport.convert(object: realm.configuration).syncConfiguration?.realmURL, "Configuration.syncConfiguration must be equal to RLMConfiguration.syncConfiguration") + #endif XCTAssertEqual(realm.configuration.encryptionKey, ObjectiveCSupport.convert(object: realm.configuration).encryptionKey, diff --git a/RealmSwift/Tests/RealmSwiftTests-BridgingHeader.h b/RealmSwift/Tests/RealmSwiftTests-BridgingHeader.h index b7c089974a..2b51d13d7f 100644 --- a/RealmSwift/Tests/RealmSwiftTests-BridgingHeader.h +++ b/RealmSwift/Tests/RealmSwiftTests-BridgingHeader.h @@ -17,3 +17,5 @@ //////////////////////////////////////////////////////////////////////////// #import "TestUtils.h" +#import "RLMAssertions.h" +#import "RLMTestCase.h" diff --git a/RealmSwift/Tests/RealmTests.swift b/RealmSwift/Tests/RealmTests.swift index ef628f4b45..5afa58dc82 100644 --- a/RealmSwift/Tests/RealmTests.swift +++ b/RealmSwift/Tests/RealmTests.swift @@ -107,14 +107,14 @@ class RealmTests: TestCase { try! fileManager.setAttributes([FileAttributeKey.posixPermissions: permissions], ofItemAtPath: testRealmURL().path) } - #if DEBUG + #if !SWIFT_PACKAGE && DEBUG func testFileFormatUpgradeRequiredButDisabled() { var config = Realm.Configuration() - var bundledRealmPath = NSBundle(forClass: RealmTests.self).pathForResource("fileformat-pre-null.realm", - ofType: nil)! - try! NSFileManager.defaultManager.copyItemAtPath(bundledRealmPath, toPath: config.path) + let bundledRealmPath = Bundle(for: RealmTests.self).path(forResource: "fileformat-pre-null.realm", + ofType: nil)! + try! FileManager.default.copyItem(atPath: bundledRealmPath, toPath: config.fileURL!.path) config.disableFormatUpgrade = true - assertFails(Error.FileFormatUpgradeRequired) { + assertFails(Realm.Error.fileFormatUpgradeRequired) { try Realm(configuration: config) } } diff --git a/RealmSwift/Tests/SwiftTestObjects.swift b/RealmSwift/Tests/SwiftTestObjects.swift index b37fb34a81..8f12815571 100644 --- a/RealmSwift/Tests/SwiftTestObjects.swift +++ b/RealmSwift/Tests/SwiftTestObjects.swift @@ -550,47 +550,47 @@ class SwiftGenericPropsOrderingHelper: Object { @objc dynamic var second: SwiftGenericPropsOrderingObject? } -class RenamedProperties1: Object { +class SwiftRenamedProperties1: Object { @objc dynamic var propA = 0 @objc dynamic var propB = "" - let linking1 = LinkingObjects(fromType: LinkToRenamedProperties1.self, property: "linkA") - let linking2 = LinkingObjects(fromType: LinkToRenamedProperties2.self, property: "linkD") + let linking1 = LinkingObjects(fromType: LinkToSwiftRenamedProperties1.self, property: "linkA") + let linking2 = LinkingObjects(fromType: LinkToSwiftRenamedProperties2.self, property: "linkD") - override class func _realmObjectName() -> String { return "Renamed Properties" } + override class func _realmObjectName() -> String { return "Swift Renamed Properties" } override class func _realmColumnNames() -> [String: String] { return ["propA": "prop 1", "propB": "prop 2"] } } -class RenamedProperties2: Object { +class SwiftRenamedProperties2: Object { @objc dynamic var propC = 0 @objc dynamic var propD = "" - let linking1 = LinkingObjects(fromType: LinkToRenamedProperties1.self, property: "linkA") - let linking2 = LinkingObjects(fromType: LinkToRenamedProperties2.self, property: "linkD") + let linking1 = LinkingObjects(fromType: LinkToSwiftRenamedProperties1.self, property: "linkA") + let linking2 = LinkingObjects(fromType: LinkToSwiftRenamedProperties2.self, property: "linkD") - override class func _realmObjectName() -> String { return "Renamed Properties" } + override class func _realmObjectName() -> String { return "Swift Renamed Properties" } override class func _realmColumnNames() -> [String: String] { return ["propC": "prop 1", "propD": "prop 2"] } } -class LinkToRenamedProperties1: Object { - @objc dynamic var linkA: RenamedProperties1? - @objc dynamic var linkB: RenamedProperties2? - let array1 = List() +class LinkToSwiftRenamedProperties1: Object { + @objc dynamic var linkA: SwiftRenamedProperties1? + @objc dynamic var linkB: SwiftRenamedProperties2? + let array1 = List() - override class func _realmObjectName() -> String { return "Link To Renamed Properties" } + override class func _realmObjectName() -> String { return "Link To Swift Renamed Properties" } override class func _realmColumnNames() -> [String: String] { return ["linkA": "link 1", "linkB": "link 2", "array1": "array"] } } -class LinkToRenamedProperties2: Object { - @objc dynamic var linkC: RenamedProperties1? - @objc dynamic var linkD: RenamedProperties2? - let array2 = List() +class LinkToSwiftRenamedProperties2: Object { + @objc dynamic var linkC: SwiftRenamedProperties1? + @objc dynamic var linkD: SwiftRenamedProperties2? + let array2 = List() - override class func _realmObjectName() -> String { return "Link To Renamed Properties" } + override class func _realmObjectName() -> String { return "Link To Swift Renamed Properties" } override class func _realmColumnNames() -> [String: String] { return ["linkC": "link 1", "linkD": "link 2", "array2": "array"] } diff --git a/RealmSwift/Tests/TestCase.swift b/RealmSwift/Tests/TestCase.swift index 7fdf94eeb8..1d7a5bf778 100644 --- a/RealmSwift/Tests/TestCase.swift +++ b/RealmSwift/Tests/TestCase.swift @@ -19,6 +19,7 @@ import Foundation import Realm import Realm.Dynamic +import RealmTestSupport import RealmSwift import XCTest @@ -26,7 +27,7 @@ func inMemoryRealm(_ inMememoryIdentifier: String) -> Realm { return try! Realm(configuration: Realm.Configuration(inMemoryIdentifier: inMememoryIdentifier)) } -class TestCase: XCTestCase { +class TestCase: RLMTestCaseBase { var exceptionThrown = false var testDir: String! = nil @@ -39,22 +40,6 @@ class TestCase: XCTestCase { return try! Realm(configuration: configuration) } - override class func setUp() { - super.setUp() -#if DEBUG || arch(i386) || arch(x86_64) - // Disable actually syncing anything to the disk to greatly speed up the - // tests, but only when not running on device because it can't be - // re-enabled and we need it enabled for performance tests - RLMDisableSyncToDisk() -#endif - do { - // Clean up any potentially lingering Realm files from previous runs - try FileManager.default.removeItem(atPath: RLMRealmPathForFile("")) - } catch { - // The directory might not actually already exist, so not an error - } - } - override class func tearDown() { RLMRealm.resetRealmState() super.tearDown() @@ -99,10 +84,6 @@ class TestCase: XCTestCase { } } - func resetRealmState() { - RLMRealm.resetRealmState() - } - func dispatchSyncNewThread(block: @escaping () -> Void) { queue.async { autoreleasepool { diff --git a/RealmSwift/Tests/TestUtils.h b/RealmSwift/Tests/TestUtils.h deleted file mode 100644 index 82dd0a3864..0000000000 --- a/RealmSwift/Tests/TestUtils.h +++ /dev/null @@ -1,41 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2015 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -#import -#import - -FOUNDATION_EXTERN void RLMAssertThrowsWithName(XCTestCase *self, __attribute__((noescape)) dispatch_block_t block, - NSString *name, NSString *message, NSString *fileName, - NSUInteger lineNumber); - - -FOUNDATION_EXTERN void RLMAssertThrowsWithReasonMatching(XCTestCase *self, - __attribute__((noescape)) dispatch_block_t block, - NSString *regexString, NSString *message, - NSString *fileName, NSUInteger lineNumber); - -FOUNDATION_EXTERN void RLMAssertMatches(XCTestCase *self, __attribute__((noescape)) NSString *(^block)(), - NSString *regexString, NSString *message, NSString *fileName, - NSUInteger lineNumber); - -FOUNDATION_EXTERN void RLMAssertThrowsWithReason(XCTestCase *self, - __attribute__((noescape)) dispatch_block_t block, - NSString *regexString, NSString *message, - NSString *fileName, NSUInteger lineNumber); - -FOUNDATION_EXTERN bool RLMHasCachedRealmForPath(NSString *path); diff --git a/RealmSwift/Util.swift b/RealmSwift/Util.swift index 1e0e6a8c35..fd5d0ae370 100644 --- a/RealmSwift/Util.swift +++ b/RealmSwift/Util.swift @@ -83,19 +83,19 @@ extension Object { // MARK: CustomObjectiveCBridgeable -internal func dynamicBridgeCast(fromObjectiveC x: Any) -> T { +/// :nodoc: +public func dynamicBridgeCast(fromObjectiveC x: Any) -> T { if T.self == DynamicObject.self { return unsafeBitCast(x as AnyObject, to: T.self) } else if let bridgeableType = T.self as? CustomObjectiveCBridgeable.Type { return bridgeableType.bridging(objCValue: x) as! T - } else if T.self == SyncSubscription.self { - return ObjectiveCSupport.convert(object: RLMCastToSyncSubscription(x)) as! T } else { return x as! T } } -internal func dynamicBridgeCast(fromSwift x: T) -> Any { +/// :nodoc: +public func dynamicBridgeCast(fromSwift x: T) -> Any { if let x = x as? CustomObjectiveCBridgeable { return x.objCValue } else { diff --git a/TestHost copy-Info.plist b/TestHost copy-Info.plist deleted file mode 100644 index e8c29fb535..0000000000 --- a/TestHost copy-Info.plist +++ /dev/null @@ -1,45 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UIRequiredDeviceCapabilities - - armv7 - - NSPrincipalClass - $(PRINCIPAL_CLASS) - LSUIElement - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - - - diff --git a/build.sh b/build.sh index 9ecb356c23..931bcf7ec9 100755 --- a/build.sh +++ b/build.sh @@ -6,8 +6,8 @@ # (C) Copyright 2011-2015 by realm.io. ################################################################################## -# Warning: pipefail is not a POSIX compatible option, but on OS X it works just fine. -# OS X uses a POSIX complain version of bash as /bin/sh, but apparently it does +# Warning: pipefail is not a POSIX compatible option, but on macOS it works just fine. +# macOS uses a POSIX complain version of bash as /bin/sh, but apparently it does # not strip away this feature. Also, this will fail if somebody forces the script # to be run with zsh. set -o pipefail @@ -45,7 +45,7 @@ command: clean: clean up/remove all generated files download-core: downloads core library (binary version) download-sync: downloads sync library (binary version, core+sync) - build: builds all iOS and OS X frameworks + build: builds all iOS and macOS frameworks ios-static: builds fat iOS static framework ios-dynamic: builds iOS dynamic frameworks ios-swift: builds RealmSwift frameworks for iOS @@ -53,11 +53,11 @@ command: watchos-swift: builds RealmSwift framework for watchOS tvos: builds tvOS framework tvos-swift: builds RealmSwift framework for tvOS - osx: builds OS X framework - osx-swift: builds RealmSwift framework for OS X - analyze-osx: analyzes OS X framework - test: tests all iOS and OS X frameworks - test-all: tests all iOS and OS X frameworks in both Debug and Release configurations + osx: builds macOS framework + osx-swift: builds RealmSwift framework for macOS + analyze-osx: analyzes macOS framework + test: tests all iOS and macOS frameworks + test-all: tests all iOS and macOS frameworks in both Debug and Release configurations test-ios-static: tests static iOS framework on 32-bit and 64-bit simulators test-ios-dynamic: tests dynamic iOS framework on 32-bit and 64-bit simulators test-ios-swift: tests RealmSwift iOS framework on 32-bit and 64-bit simulators @@ -67,15 +67,16 @@ command: test-tvos: tests tvOS framework test-tvos-swift: tests RealmSwift tvOS framework test-tvos-devices: tests ObjC & Swift tvOS frameworks on all attached tvOS devices - test-osx: tests OS X framework - test-osx-swift: tests RealmSwift OS X framework + test-osx: tests macOS framework + test-osx-swift: tests RealmSwift macOS framework + test-swiftpm: tests ObjC and Swift macOS frameworks via SwiftPM verify: verifies docs, osx, osx-swift, ios-static, ios-dynamic, ios-swift, ios-device in both Debug and Release configurations, swiftlint verify-osx-object-server: downloads the Realm Object Server and runs the Objective-C and Swift integration tests docs: builds docs in docs/output examples: builds all examples examples-ios: builds all static iOS examples examples-ios-swift: builds all Swift iOS examples - examples-osx: builds all OS X examples + examples-osx: builds all macOS examples get-version: get the current version set-version version: set the version cocoapods-setup: download realm-core and create a stub RLMPlatform.h file to enable building via CocoaPods @@ -692,6 +693,11 @@ case "$COMMAND" in exit 0 ;; + "test-swiftpm") + xcrun swift test --configuration $(echo $CONFIGURATION | tr "[:upper:]" "[:lower:]") + exit 0 + ;; + ###################################### # Full verification ###################################### @@ -715,6 +721,7 @@ case "$COMMAND" in sh build.sh verify-tvos-debug sh build.sh verify-tvos-device sh build.sh verify-swiftlint + sh build.sh verify-swiftpm sh build.sh verify-osx-object-server ;; @@ -842,6 +849,13 @@ case "$COMMAND" in exit 0 ;; + "verify-swiftpm") + if (( $(xcode_version_major) >= 10 )); then + sh build.sh test-swiftpm + fi + exit 0 + ;; + "verify-osx-object-server") sh build.sh test-osx-object-server exit 0 @@ -955,6 +969,8 @@ case "$COMMAND" in PlistBuddy -c "Set :CFBundleShortVersionString $realm_version" "$version_file" done sed -i '' "s/^VERSION=.*/VERSION=$realm_version/" dependencies.list + sed -i '' "s/^let coreVersionStr =.*/let coreVersionStr = \"$REALM_CORE_VERSION\"/" Package.swift + sed -i '' "s/^let cocoaVersionStr =.*/let cocoaVersionStr = \"$realm_version\"/" Package.swift exit 0 ;; @@ -1380,7 +1396,7 @@ EOF sh build.sh package-ios-swift cp build/ios/realm-swift-framework-ios.zip .. - echo 'Packaging OS X' + echo 'Packaging macOS' sh build.sh package-osx cp build/DerivedData/Realm/Build/Products/Release/realm-framework-osx.zip .. sh build.sh package-osx-swift diff --git a/examples/installation/SwiftPMExample/.gitignore b/examples/installation/SwiftPMExample/.gitignore new file mode 100644 index 0000000000..02c087533d --- /dev/null +++ b/examples/installation/SwiftPMExample/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj diff --git a/examples/installation/SwiftPMExample/Package.swift b/examples/installation/SwiftPMExample/Package.swift new file mode 100644 index 0000000000..5447507f50 --- /dev/null +++ b/examples/installation/SwiftPMExample/Package.swift @@ -0,0 +1,18 @@ +// swift-tools-version:5.1 + +import PackageDescription + +let package = Package( + name: "SwiftPMExample", + dependencies: [ + .package(path: "../../.."), + ], + targets: [ + .target( + name: "SwiftPMExample", + dependencies: ["RealmSwift"]), + .testTarget( + name: "SwiftPMExampleTests", + dependencies: ["SwiftPMExample"]), + ] +) diff --git a/examples/installation/SwiftPMExample/Sources/SwiftPMExample/main.swift b/examples/installation/SwiftPMExample/Sources/SwiftPMExample/main.swift new file mode 100644 index 0000000000..7e2280e555 --- /dev/null +++ b/examples/installation/SwiftPMExample/Sources/SwiftPMExample/main.swift @@ -0,0 +1,13 @@ +import Foundation +import RealmSwift + +class MyModel: Object { + @objc dynamic var str: String = "" +} + +let realm = try! Realm() +try! realm.write { + realm.create(MyModel.self, value: ["Hello, world!"]) +} + +print(realm.objects(MyModel.self).last!.str) diff --git a/examples/installation/SwiftPMExample/Tests/SwiftPMExampleTests/SwiftPMExampleTests.swift b/examples/installation/SwiftPMExample/Tests/SwiftPMExampleTests/SwiftPMExampleTests.swift new file mode 100644 index 0000000000..7abfaf0242 --- /dev/null +++ b/examples/installation/SwiftPMExample/Tests/SwiftPMExampleTests/SwiftPMExampleTests.swift @@ -0,0 +1,40 @@ +import XCTest +import class Foundation.Bundle + +#if os(macOS) +final class SwiftPMExampleTests: XCTestCase { + func testExample() throws { + guard #available(macOS 10.13, *) else { + return + } + + let fooBinary = productsDirectory.appendingPathComponent("SwiftPMExample") + + let process = Process() + process.executableURL = fooBinary + + let pipe = Pipe() + process.standardOutput = pipe + + try process.run() + process.waitUntilExit() + + let data = pipe.fileHandleForReading.readDataToEndOfFile() + let output = String(data: data, encoding: .utf8) + + XCTAssertEqual(output, "Hello, world!\n") + } + + /// Returns path to the built products directory. + var productsDirectory: URL { + for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") { + return bundle.bundleURL.deletingLastPathComponent() + } + fatalError("couldn't find the products directory") + } + + static var allTests = [ + ("testExample", testExample), + ] +} +#endif diff --git a/examples/installation/build.sh b/examples/installation/build.sh index fd9b3143b7..b53f5b0d12 100755 --- a/examples/installation/build.sh +++ b/examples/installation/build.sh @@ -17,14 +17,16 @@ command: test-ios-objc-carthage: tests iOS Objective-C Carthage example. test-ios-swift-dynamic: tests iOS Swift dynamic example. test-ios-swift-cocoapods: tests iOS Swift CocoaPods example. - test-ios-swift-carthage: tests iOS Objective-C Carthage example. + test-ios-swift-carthage: tests iOS Swift Carthage example. + test-ios-spm: tests iOS Swift Package Manager example. - test-osx-objc-dynamic: tests OS X Objective-C dynamic example. - test-osx-objc-cocoapods: tests OS X Objective-C CocoaPods example. - test-osx-objc-carthage: tests OS X Objective-C Carthage example. - test-osx-swift-dynamic: tests OS X Swift dynamic example. - test-osx-swift-cocoapods: tests OS X Swift CocoaPods example. - test-osx-swift-carthage: tests OS X Swift Carthage example. + test-osx-objc-dynamic: tests macOS Objective-C dynamic example. + test-osx-objc-cocoapods: tests macOS Objective-C CocoaPods example. + test-osx-objc-carthage: tests macOS Objective-C Carthage example. + test-osx-swift-dynamic: tests macOS Swift dynamic example. + test-osx-swift-cocoapods: tests macOS Swift CocoaPods example. + test-osx-swift-carthage: tests macOS Swift Carthage example. + test-osx-spm: tests macOS Swift Package Manager example. test-watchos-objc-dynamic: tests watchOS Objective-C dynamic example. test-watchos-objc-cocoapods: tests watchOS Objective-C CocoaPods example. @@ -32,6 +34,9 @@ command: test-watchos-swift-dynamic: tests watchOS Swift dynamic example. test-watchos-swift-cocoapods: tests watchOS Swift CocoaPods example. test-watchos-swift-carthage: tests watchOS Swift Carthage example. + test-watchos-spm: tests watchOS Swift Package Manager example. + + test-tvos-spm: tests tvOS Swift Package Manager example. EOF } @@ -51,6 +56,10 @@ download_zip_if_needed() { fi } +xcode_version_major() { + echo "${REALM_XCODE_VERSION%%.*}" +} + xctest() { PLATFORM="$1" LANG="$2" @@ -114,94 +123,52 @@ xctest() { fi } +swiftpm() { + PLATFORM="$1" + cd SwiftPMExample + xcrun swift build +} + source "$(dirname "$0")/../../scripts/swift-version.sh" set_xcode_and_swift_versions # exports REALM_SWIFT_VERSION, REALM_XCODE_VERSION, and DEVELOPER_DIR variables if not already set +PLATFORM=$(echo $COMMAND | cut -d - -f 2) +LANGUAGE=$(echo $COMMAND | cut -d - -f 3) + case "$COMMAND" in "test-all") for target in ios-swift-dynamic ios-swift-cocoapods osx-swift-dynamic ios-swift-carthage osx-swift-carthage; do ./build.sh test-$target || exit 1 done + if (( $(xcode_version_major) >= 11 )); then + for target in ios osx watchos tvos; do + ./build.sh test-$target-spm || exit 1 + done + fi ;; - "test-ios-objc-static") - xctest ios objc StaticExample - ;; - - "test-ios-objc-dynamic") - xctest ios objc DynamicExample - ;; - - "test-ios-objc-cocoapods") - xctest ios objc CocoaPodsExample - ;; - - "test-ios-objc-cocoapods-dynamic") - xctest ios objc CocoaPodsDynamicExample - ;; - - "test-ios-objc-carthage") - xctest ios objc CarthageExample - ;; - - "test-ios-swift-dynamic") - xctest ios swift DynamicExample - ;; - - "test-ios-swift-cocoapods") - xctest ios swift CocoaPodsExample - ;; - - "test-ios-swift-carthage") - xctest ios swift CarthageExample - ;; - - "test-osx-objc-dynamic") - xctest osx objc DynamicExample - ;; - - "test-osx-objc-cocoapods") - xctest osx objc CocoaPodsExample - ;; - - "test-osx-objc-carthage") - xctest osx objc CarthageExample - ;; - - "test-osx-swift-dynamic") - xctest osx swift DynamicExample - ;; - - "test-osx-swift-cocoapods") - xctest osx swift CocoaPodsExample - ;; - - "test-osx-swift-carthage") - xctest osx swift CarthageExample - ;; - - "test-watchos-objc-dynamic") - xctest watchos objc DynamicExample + test-*-*-static) + xctest $PLATFORM $LANGUAGE StaticExample ;; - "test-watchos-objc-cocoapods") - xctest watchos objc CocoaPodsExample + test-*-*-dynamic) + xctest $PLATFORM $LANGUAGE DynamicExample ;; - "test-watchos-objc-carthage") - xctest watchos objc CarthageExample + test-*-*-cocoapods) + xctest $PLATFORM $LANGUAGE CocoaPodsExample ;; - "test-watchos-swift-dynamic") - xctest watchos swift DynamicExample + test-*-*-cocoapods-dynamic) + xctest $PLATFORM $LANGUAGE CocoaPodsDynamicExample ;; - "test-watchos-swift-cocoapods") - xctest watchos swift CocoaPodsExample + test-*-*-carthage) + xctest $PLATFORM $LANGUAGE CarthageExample ;; - "test-watchos-swift-carthage") - xctest watchos swift CarthageExample + test-*-spm) + swiftpm $PLATFORM ;; *) diff --git a/examples/installation/ios/swift/CocoaPodsExample/CocoaPodsExample.xcodeproj/project.pbxproj b/examples/installation/ios/swift/CocoaPodsExample/CocoaPodsExample.xcodeproj/project.pbxproj index e5dc638b31..a93eda8bdf 100644 --- a/examples/installation/ios/swift/CocoaPodsExample/CocoaPodsExample.xcodeproj/project.pbxproj +++ b/examples/installation/ios/swift/CocoaPodsExample/CocoaPodsExample.xcodeproj/project.pbxproj @@ -253,7 +253,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-CocoaPodsExampleTests/Pods-CocoaPodsExampleTests-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-CocoaPodsExampleTests/Pods-CocoaPodsExampleTests-frameworks.sh", "${BUILT_PRODUCTS_DIR}/Realm/Realm.framework", "${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework", ); @@ -264,7 +264,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CocoaPodsExampleTests/Pods-CocoaPodsExampleTests-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CocoaPodsExampleTests/Pods-CocoaPodsExampleTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; 26913120C8A66DDEF358C3D1 /* [CP] Check Pods Manifest.lock */ = { @@ -309,7 +309,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-CocoaPodsExample/Pods-CocoaPodsExample-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-CocoaPodsExample/Pods-CocoaPodsExample-frameworks.sh", "${BUILT_PRODUCTS_DIR}/Realm/Realm.framework", "${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework", ); @@ -320,7 +320,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CocoaPodsExample/Pods-CocoaPodsExample-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CocoaPodsExample/Pods-CocoaPodsExample-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ diff --git a/include/Realm/NSError+RLMSync.h b/include/Realm/NSError+RLMSync.h new file mode 120000 index 0000000000..78afdad021 --- /dev/null +++ b/include/Realm/NSError+RLMSync.h @@ -0,0 +1 @@ +../../Realm/NSError+RLMSync.h \ No newline at end of file diff --git a/include/Realm/RLMAccessor.h b/include/Realm/RLMAccessor.h new file mode 120000 index 0000000000..6be2baead5 --- /dev/null +++ b/include/Realm/RLMAccessor.h @@ -0,0 +1 @@ +../../Realm/RLMAccessor.h \ No newline at end of file diff --git a/include/Realm/RLMArray.h b/include/Realm/RLMArray.h new file mode 120000 index 0000000000..d8e112a7cf --- /dev/null +++ b/include/Realm/RLMArray.h @@ -0,0 +1 @@ +../../Realm/RLMArray.h \ No newline at end of file diff --git a/include/Realm/RLMArray_Private.h b/include/Realm/RLMArray_Private.h new file mode 120000 index 0000000000..bf340d2d92 --- /dev/null +++ b/include/Realm/RLMArray_Private.h @@ -0,0 +1 @@ +../../Realm/RLMArray_Private.h \ No newline at end of file diff --git a/include/Realm/RLMCollection.h b/include/Realm/RLMCollection.h new file mode 120000 index 0000000000..b1ac3de1f3 --- /dev/null +++ b/include/Realm/RLMCollection.h @@ -0,0 +1 @@ +../../Realm/RLMCollection.h \ No newline at end of file diff --git a/include/Realm/RLMCollection_Private.h b/include/Realm/RLMCollection_Private.h new file mode 120000 index 0000000000..6dc49bfcba --- /dev/null +++ b/include/Realm/RLMCollection_Private.h @@ -0,0 +1 @@ +../../Realm/RLMCollection_Private.h \ No newline at end of file diff --git a/include/Realm/RLMConstants.h b/include/Realm/RLMConstants.h new file mode 120000 index 0000000000..7c1ef09803 --- /dev/null +++ b/include/Realm/RLMConstants.h @@ -0,0 +1 @@ +../../Realm/RLMConstants.h \ No newline at end of file diff --git a/include/Realm/RLMListBase.h b/include/Realm/RLMListBase.h new file mode 120000 index 0000000000..0f05af12e6 --- /dev/null +++ b/include/Realm/RLMListBase.h @@ -0,0 +1 @@ +../../Realm/RLMListBase.h \ No newline at end of file diff --git a/include/Realm/RLMMigration.h b/include/Realm/RLMMigration.h new file mode 120000 index 0000000000..f2820eeb16 --- /dev/null +++ b/include/Realm/RLMMigration.h @@ -0,0 +1 @@ +../../Realm/RLMMigration.h \ No newline at end of file diff --git a/include/Realm/RLMObject.h b/include/Realm/RLMObject.h new file mode 120000 index 0000000000..450a84374f --- /dev/null +++ b/include/Realm/RLMObject.h @@ -0,0 +1 @@ +../../Realm/RLMObject.h \ No newline at end of file diff --git a/include/Realm/RLMObjectBase.h b/include/Realm/RLMObjectBase.h new file mode 120000 index 0000000000..07c9e94e11 --- /dev/null +++ b/include/Realm/RLMObjectBase.h @@ -0,0 +1 @@ +../../Realm/RLMObjectBase.h \ No newline at end of file diff --git a/include/Realm/RLMObjectBase_Dynamic.h b/include/Realm/RLMObjectBase_Dynamic.h new file mode 120000 index 0000000000..0987a432b0 --- /dev/null +++ b/include/Realm/RLMObjectBase_Dynamic.h @@ -0,0 +1 @@ +../../Realm/RLMObjectBase_Dynamic.h \ No newline at end of file diff --git a/include/Realm/RLMObjectBase_Private.h b/include/Realm/RLMObjectBase_Private.h new file mode 120000 index 0000000000..3883eb231f --- /dev/null +++ b/include/Realm/RLMObjectBase_Private.h @@ -0,0 +1 @@ +../../Realm/RLMObjectBase_Private.h \ No newline at end of file diff --git a/include/Realm/RLMObjectSchema.h b/include/Realm/RLMObjectSchema.h new file mode 120000 index 0000000000..c4f41bbabc --- /dev/null +++ b/include/Realm/RLMObjectSchema.h @@ -0,0 +1 @@ +../../Realm/RLMObjectSchema.h \ No newline at end of file diff --git a/include/Realm/RLMObjectSchema_Private.h b/include/Realm/RLMObjectSchema_Private.h new file mode 120000 index 0000000000..3ea13956ec --- /dev/null +++ b/include/Realm/RLMObjectSchema_Private.h @@ -0,0 +1 @@ +../../Realm/RLMObjectSchema_Private.h \ No newline at end of file diff --git a/include/Realm/RLMObjectStore.h b/include/Realm/RLMObjectStore.h new file mode 120000 index 0000000000..7f64490c3a --- /dev/null +++ b/include/Realm/RLMObjectStore.h @@ -0,0 +1 @@ +../../Realm/RLMObjectStore.h \ No newline at end of file diff --git a/include/Realm/RLMObject_Private.h b/include/Realm/RLMObject_Private.h new file mode 120000 index 0000000000..8323da7028 --- /dev/null +++ b/include/Realm/RLMObject_Private.h @@ -0,0 +1 @@ +../../Realm/RLMObject_Private.h \ No newline at end of file diff --git a/include/Realm/RLMOptionalBase.h b/include/Realm/RLMOptionalBase.h new file mode 120000 index 0000000000..ea4d8ee88f --- /dev/null +++ b/include/Realm/RLMOptionalBase.h @@ -0,0 +1 @@ +../../Realm/RLMOptionalBase.h \ No newline at end of file diff --git a/include/Realm/RLMPlatform.h b/include/Realm/RLMPlatform.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/Realm/RLMProperty.h b/include/Realm/RLMProperty.h new file mode 120000 index 0000000000..33dd652412 --- /dev/null +++ b/include/Realm/RLMProperty.h @@ -0,0 +1 @@ +../../Realm/RLMProperty.h \ No newline at end of file diff --git a/include/Realm/RLMProperty_Private.h b/include/Realm/RLMProperty_Private.h new file mode 120000 index 0000000000..83befb9ade --- /dev/null +++ b/include/Realm/RLMProperty_Private.h @@ -0,0 +1 @@ +../../Realm/RLMProperty_Private.h \ No newline at end of file diff --git a/include/Realm/RLMRealm+Sync.h b/include/Realm/RLMRealm+Sync.h new file mode 120000 index 0000000000..80dcd81b77 --- /dev/null +++ b/include/Realm/RLMRealm+Sync.h @@ -0,0 +1 @@ +../../Realm/RLMRealm+Sync.h \ No newline at end of file diff --git a/include/Realm/RLMRealm.h b/include/Realm/RLMRealm.h new file mode 120000 index 0000000000..33d9ba74d6 --- /dev/null +++ b/include/Realm/RLMRealm.h @@ -0,0 +1 @@ +../../Realm/RLMRealm.h \ No newline at end of file diff --git a/include/Realm/RLMRealmConfiguration+Sync.h b/include/Realm/RLMRealmConfiguration+Sync.h new file mode 120000 index 0000000000..2f544a5459 --- /dev/null +++ b/include/Realm/RLMRealmConfiguration+Sync.h @@ -0,0 +1 @@ +../../Realm/RLMRealmConfiguration+Sync.h \ No newline at end of file diff --git a/include/Realm/RLMRealmConfiguration.h b/include/Realm/RLMRealmConfiguration.h new file mode 120000 index 0000000000..4c1ea266bd --- /dev/null +++ b/include/Realm/RLMRealmConfiguration.h @@ -0,0 +1 @@ +../../Realm/RLMRealmConfiguration.h \ No newline at end of file diff --git a/include/Realm/RLMRealmConfiguration_Private.h b/include/Realm/RLMRealmConfiguration_Private.h new file mode 120000 index 0000000000..44ed69946e --- /dev/null +++ b/include/Realm/RLMRealmConfiguration_Private.h @@ -0,0 +1 @@ +../../Realm/RLMRealmConfiguration_Private.h \ No newline at end of file diff --git a/include/Realm/RLMRealm_Dynamic.h b/include/Realm/RLMRealm_Dynamic.h new file mode 120000 index 0000000000..002b247f10 --- /dev/null +++ b/include/Realm/RLMRealm_Dynamic.h @@ -0,0 +1 @@ +../../Realm/RLMRealm_Dynamic.h \ No newline at end of file diff --git a/include/Realm/RLMRealm_Private.h b/include/Realm/RLMRealm_Private.h new file mode 120000 index 0000000000..7fdea48ac9 --- /dev/null +++ b/include/Realm/RLMRealm_Private.h @@ -0,0 +1 @@ +../../Realm/RLMRealm_Private.h \ No newline at end of file diff --git a/include/Realm/RLMResults.h b/include/Realm/RLMResults.h new file mode 120000 index 0000000000..4c7220b639 --- /dev/null +++ b/include/Realm/RLMResults.h @@ -0,0 +1 @@ +../../Realm/RLMResults.h \ No newline at end of file diff --git a/include/Realm/RLMResults_Private.h b/include/Realm/RLMResults_Private.h new file mode 120000 index 0000000000..a453d21ca9 --- /dev/null +++ b/include/Realm/RLMResults_Private.h @@ -0,0 +1 @@ +../../Realm/RLMResults_Private.h \ No newline at end of file diff --git a/include/Realm/RLMSchema.h b/include/Realm/RLMSchema.h new file mode 120000 index 0000000000..bd12e6e55f --- /dev/null +++ b/include/Realm/RLMSchema.h @@ -0,0 +1 @@ +../../Realm/RLMSchema.h \ No newline at end of file diff --git a/include/Realm/RLMSchema_Private.h b/include/Realm/RLMSchema_Private.h new file mode 120000 index 0000000000..3a65b54396 --- /dev/null +++ b/include/Realm/RLMSchema_Private.h @@ -0,0 +1 @@ +../../Realm/RLMSchema_Private.h \ No newline at end of file diff --git a/include/Realm/RLMSyncConfiguration.h b/include/Realm/RLMSyncConfiguration.h new file mode 120000 index 0000000000..6d27816f2f --- /dev/null +++ b/include/Realm/RLMSyncConfiguration.h @@ -0,0 +1 @@ +../../Realm/RLMSyncConfiguration.h \ No newline at end of file diff --git a/include/Realm/RLMSyncConfiguration_Private.h b/include/Realm/RLMSyncConfiguration_Private.h new file mode 120000 index 0000000000..c70f0a65e3 --- /dev/null +++ b/include/Realm/RLMSyncConfiguration_Private.h @@ -0,0 +1 @@ +../../Realm/RLMSyncConfiguration_Private.h \ No newline at end of file diff --git a/include/Realm/RLMSyncCredentials.h b/include/Realm/RLMSyncCredentials.h new file mode 120000 index 0000000000..9f68dcf21a --- /dev/null +++ b/include/Realm/RLMSyncCredentials.h @@ -0,0 +1 @@ +../../Realm/RLMSyncCredentials.h \ No newline at end of file diff --git a/include/Realm/RLMSyncManager.h b/include/Realm/RLMSyncManager.h new file mode 120000 index 0000000000..00f8c943ba --- /dev/null +++ b/include/Realm/RLMSyncManager.h @@ -0,0 +1 @@ +../../Realm/RLMSyncManager.h \ No newline at end of file diff --git a/include/Realm/RLMSyncPermission.h b/include/Realm/RLMSyncPermission.h new file mode 120000 index 0000000000..6625f9f1b6 --- /dev/null +++ b/include/Realm/RLMSyncPermission.h @@ -0,0 +1 @@ +../../Realm/RLMSyncPermission.h \ No newline at end of file diff --git a/include/Realm/RLMSyncSession.h b/include/Realm/RLMSyncSession.h new file mode 120000 index 0000000000..d87d648268 --- /dev/null +++ b/include/Realm/RLMSyncSession.h @@ -0,0 +1 @@ +../../Realm/RLMSyncSession.h \ No newline at end of file diff --git a/include/Realm/RLMSyncSubscription.h b/include/Realm/RLMSyncSubscription.h new file mode 120000 index 0000000000..68b3e5fb29 --- /dev/null +++ b/include/Realm/RLMSyncSubscription.h @@ -0,0 +1 @@ +../../Realm/RLMSyncSubscription.h \ No newline at end of file diff --git a/include/Realm/RLMSyncUser.h b/include/Realm/RLMSyncUser.h new file mode 120000 index 0000000000..0bfe301015 --- /dev/null +++ b/include/Realm/RLMSyncUser.h @@ -0,0 +1 @@ +../../Realm/RLMSyncUser.h \ No newline at end of file diff --git a/include/Realm/RLMSyncUtil.h b/include/Realm/RLMSyncUtil.h new file mode 120000 index 0000000000..35c89ebaa5 --- /dev/null +++ b/include/Realm/RLMSyncUtil.h @@ -0,0 +1 @@ +../../Realm/RLMSyncUtil.h \ No newline at end of file diff --git a/include/Realm/RLMSyncUtil_Private.h b/include/Realm/RLMSyncUtil_Private.h new file mode 120000 index 0000000000..d997ec7e4a --- /dev/null +++ b/include/Realm/RLMSyncUtil_Private.h @@ -0,0 +1 @@ +../../Realm/RLMSyncUtil_Private.h \ No newline at end of file diff --git a/include/Realm/RLMThreadSafeReference.h b/include/Realm/RLMThreadSafeReference.h new file mode 120000 index 0000000000..09caf5cf61 --- /dev/null +++ b/include/Realm/RLMThreadSafeReference.h @@ -0,0 +1 @@ +../../Realm/RLMThreadSafeReference.h \ No newline at end of file diff --git a/include/Realm/Realm.h b/include/Realm/Realm.h new file mode 120000 index 0000000000..2a2f23802b --- /dev/null +++ b/include/Realm/Realm.h @@ -0,0 +1 @@ +../../Realm/Realm.h \ No newline at end of file diff --git a/include/module.modulemap b/include/module.modulemap new file mode 100644 index 0000000000..18b058c233 --- /dev/null +++ b/include/module.modulemap @@ -0,0 +1,33 @@ +// This file should match Realm/Realm.modulemap, except for that it's "module +// Realm" rather than "framework module Realm", and the paths below have the +// Realm/ prefix (due to not being a framework module) +module Realm { + umbrella header "Realm/Realm.h" + export * + module * { export * } + + explicit module Private { + header "Realm/RLMAccessor.h" + header "Realm/RLMArray_Private.h" + header "Realm/RLMCollection_Private.h" + header "Realm/RLMListBase.h" + header "Realm/RLMObject_Private.h" + header "Realm/RLMObjectBase_Dynamic.h" + header "Realm/RLMObjectBase_Private.h" + header "Realm/RLMObjectSchema_Private.h" + header "Realm/RLMObjectStore.h" + header "Realm/RLMOptionalBase.h" + header "Realm/RLMProperty_Private.h" + header "Realm/RLMRealm_Private.h" + header "Realm/RLMRealmConfiguration_Private.h" + header "Realm/RLMResults_Private.h" + header "Realm/RLMSchema_Private.h" + header "Realm/RLMSyncConfiguration_Private.h" + header "Realm/RLMSyncUtil_Private.h" + } + + explicit module Dynamic { + header "Realm/RLMRealm_Dynamic.h" + header "Realm/RLMObjectBase_Dynamic.h" + } +} diff --git a/scripts/reset-simulators.rb b/scripts/reset-simulators.rb index 0705803292..731e7f3a2d 100755 --- a/scripts/reset-simulators.rb +++ b/scripts/reset-simulators.rb @@ -83,7 +83,7 @@ def shutdown_simulator_devices(devices) runtimes_by_platform = Hash.new { |hash, key| hash[key] = [] } runtimes.each do |runtime| - next unless runtime['availability'] == '(available)' + next unless runtime['availability'] == '(available)' || runtime['isAvailable'] == true runtimes_by_platform[platform_for_runtime(runtime)] << runtime end @@ -106,8 +106,8 @@ def shutdown_simulator_devices(devices) end puts ' done!' - print 'Booting iPhone 6 simulator...' - system("xcrun simctl boot 'iPhone 6'") or raise "Failed to boot iPhone 6 simulator" + print 'Booting iPhone 8 simulator...' + system("xcrun simctl boot 'iPhone 8'") or raise "Failed to boot iPhone 8 simulator" puts ' done!' rescue => e