From 2dc09289bfb529eb1aba52c36a8b537e8f6c8bfb Mon Sep 17 00:00:00 2001 From: John Rommel Estropia Date: Fri, 17 Jun 2016 01:24:19 +0900 Subject: [PATCH] fixed platform dependencies --- CoreStore.podspec | 1 - CoreStore.xcodeproj/project.pbxproj | 54 +++- .../BaseTests/BaseTestDataTestCase.swift | 2 +- CoreStoreTests/ListObserverTests.swift | 280 ++++++++++++++++++ CoreStoreTests/ObjectObserverTests.swift | 208 ++++++++++++- CoreStoreTests/QueryTests.swift | 3 +- CoreStoreTests/SectionByTests.swift | 4 + README.md | 2 + ...FetchedResultsController+Convenience.swift | 4 + .../Concrete Clauses/Select.swift | 12 +- .../CoreStoreFetchedResultsController.swift | 5 +- .../FetchedResultsControllerDelegate.swift | 6 +- .../NSManagedObjectContext+Setup.swift | 6 + ...reStore+CustomDebugStringConvertible.swift | 17 +- .../ObjectiveC/CSCoreStore+Observing.swift | 5 +- .../ObjectiveC/CSDataStack+Observing.swift | 5 +- Sources/ObjectiveC/CSListMonitor.swift | 5 +- Sources/ObjectiveC/CSListObserver.swift | 7 +- Sources/ObjectiveC/CSObjectMonitor.swift | 5 +- Sources/ObjectiveC/CSObjectObserver.swift | 5 +- Sources/ObjectiveC/CSSectionBy.swift | 5 +- ...SFetchedResultsController+ObjectiveC.swift | 5 +- Sources/Observing/CoreStore+Observing.swift | 5 +- Sources/Observing/DataStack+Observing.swift | 5 +- Sources/Observing/ListMonitor.swift | 11 +- Sources/Observing/ListObserver.swift | 10 +- Sources/Observing/ObjectMonitor.swift | 8 +- Sources/Observing/ObjectObserver.swift | 6 +- Sources/Observing/SectionBy.swift | 5 +- .../UnsafeDataTransaction+Observing.swift | 5 +- .../Setup/StorageInterfaces/ICloudStore.swift | 4 + .../ICloudStoreObserver.swift | 4 + .../StorageInterfaces/LegacySQLiteStore.swift | 1 + 33 files changed, 662 insertions(+), 48 deletions(-) create mode 100644 CoreStoreTests/ListObserverTests.swift diff --git a/CoreStore.podspec b/CoreStore.podspec index 95bd8b6..5e285af 100644 --- a/CoreStore.podspec +++ b/CoreStore.podspec @@ -13,7 +13,6 @@ Pod::Spec.new do |s| s.tvos.deployment_target = "9.0" s.source_files = "Sources", "Sources/**/*.{swift}" - s.osx.exclude_files = "Sources/Observing/*.{swift}", "Sources/Internal/FetchedResultsControllerDelegate.swift", "Sources/Internal/CoreStoreFetchedResultsController.swift", "Sources/Convenience Helpers/NSFetchedResultsController+Convenience.swift" s.frameworks = "Foundation", "CoreData" s.requires_arc = true s.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS' => '-D USE_FRAMEWORKS' } diff --git a/CoreStore.xcodeproj/project.pbxproj b/CoreStore.xcodeproj/project.pbxproj index 037ea5c..cfbd89e 100644 --- a/CoreStore.xcodeproj/project.pbxproj +++ b/CoreStore.xcodeproj/project.pbxproj @@ -99,10 +99,33 @@ B5202CFD1C046E8400DED140 /* NSFetchedResultsController+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5202CF91C04688100DED140 /* NSFetchedResultsController+Convenience.swift */; }; B5220E081D0C5F8D009BC71E /* ObjectObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5220E071D0C5F8D009BC71E /* ObjectObserverTests.swift */; }; B5220E091D0C5F8D009BC71E /* ObjectObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5220E071D0C5F8D009BC71E /* ObjectObserverTests.swift */; }; - B5220E0A1D0C5F8D009BC71E /* ObjectObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5220E071D0C5F8D009BC71E /* ObjectObserverTests.swift */; }; B5220E0C1D0D0D19009BC71E /* ImportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5220E0B1D0D0D19009BC71E /* ImportTests.swift */; }; B5220E0D1D0D0D19009BC71E /* ImportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5220E0B1D0D0D19009BC71E /* ImportTests.swift */; }; B5220E0E1D0D0D19009BC71E /* ImportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5220E0B1D0D0D19009BC71E /* ImportTests.swift */; }; + B5220E101D0DA6AB009BC71E /* ListObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5220E0F1D0DA6AB009BC71E /* ListObserverTests.swift */; }; + B5220E111D0DA6AB009BC71E /* ListObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5220E0F1D0DA6AB009BC71E /* ListObserverTests.swift */; }; + B5220E131D1305ED009BC71E /* SectionBy.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56007131B3F6C2800A9A8F9 /* SectionBy.swift */; }; + B5220E141D130614009BC71E /* DataStack+Observing.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E84F1A1AFF84860064E85B /* DataStack+Observing.swift */; }; + B5220E151D130663009BC71E /* CoreStore+Observing.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E84F1B1AFF84860064E85B /* CoreStore+Observing.swift */; }; + B5220E161D13067C009BC71E /* ObjectMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E84F1C1AFF84860064E85B /* ObjectMonitor.swift */; }; + B5220E171D1306DF009BC71E /* UnsafeDataTransaction+Observing.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C976E21C6C9F6A00B1AF90 /* UnsafeDataTransaction+Observing.swift */; }; + B5220E181D130711009BC71E /* ObjectObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E84F1F1AFF84860064E85B /* ObjectObserver.swift */; }; + B5220E191D130761009BC71E /* ListMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E84F1D1AFF84860064E85B /* ListMonitor.swift */; }; + B5220E1A1D130791009BC71E /* CoreStoreFetchedResultsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C976E61C6E3A5900B1AF90 /* CoreStoreFetchedResultsController.swift */; }; + B5220E1B1D13079B009BC71E /* CSCoreStore+Observing.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E1B5A11CAA4365007FD580 /* CSCoreStore+Observing.swift */; }; + B5220E1C1D130801009BC71E /* FetchedResultsControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B54A6A541BA15F2A007870FD /* FetchedResultsControllerDelegate.swift */; }; + B5220E1D1D13080A009BC71E /* CSDataStack+Observing.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E1B59C1CAA2568007FD580 /* CSDataStack+Observing.swift */; }; + B5220E1E1D13080D009BC71E /* CSListMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B501FDE11CA8D1F500BE22EF /* CSListMonitor.swift */; }; + B5220E1F1D130810009BC71E /* CSListObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = B501FDE61CA8D20500BE22EF /* CSListObserver.swift */; }; + B5220E201D130813009BC71E /* CSObjectMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E1B5921CAA0C15007FD580 /* CSObjectMonitor.swift */; }; + B5220E211D130816009BC71E /* CSObjectObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E1B5971CAA0C23007FD580 /* CSObjectObserver.swift */; }; + B5220E221D130818009BC71E /* CSSectionBy.swift in Sources */ = {isa = PBXBuildFile; fileRef = B501FDDC1CA8D05000BE22EF /* CSSectionBy.swift */; }; + B5220E231D130826009BC71E /* NSFetchedResultsController+ObjectiveC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B53FBA1D1CAB63FA00F0D40A /* NSFetchedResultsController+ObjectiveC.swift */; }; + B5220E241D13085E009BC71E /* NSFetchedResultsController+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5202CF91C04688100DED140 /* NSFetchedResultsController+Convenience.swift */; }; + B5220E251D13088E009BC71E /* ListObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E84F1E1AFF84860064E85B /* ListObserver.swift */; }; + B5220E261D1308C2009BC71E /* ListObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5220E0F1D0DA6AB009BC71E /* ListObserverTests.swift */; }; + B5220E271D1308D1009BC71E /* ObjectObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5220E071D0C5F8D009BC71E /* ObjectObserverTests.swift */; }; + B5220E281D1308E5009BC71E /* SectionByTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52557831D02A07400E51965 /* SectionByTests.swift */; }; B525576C1CFAF18F00E51965 /* IntoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B525576B1CFAF18F00E51965 /* IntoTests.swift */; }; B525576D1CFAF18F00E51965 /* IntoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B525576B1CFAF18F00E51965 /* IntoTests.swift */; }; B525576E1CFAF18F00E51965 /* IntoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B525576B1CFAF18F00E51965 /* IntoTests.swift */; }; @@ -123,7 +146,6 @@ B52557821D029D2500E51965 /* TweakTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B525577F1D029D2500E51965 /* TweakTests.swift */; }; B52557841D02A07400E51965 /* SectionByTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52557831D02A07400E51965 /* SectionByTests.swift */; }; B52557851D02A07400E51965 /* SectionByTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52557831D02A07400E51965 /* SectionByTests.swift */; }; - B52557861D02A07400E51965 /* SectionByTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52557831D02A07400E51965 /* SectionByTests.swift */; }; B52557881D02DE8100E51965 /* FetchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52557871D02DE8100E51965 /* FetchTests.swift */; }; B52557891D02DE8100E51965 /* FetchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52557871D02DE8100E51965 /* FetchTests.swift */; }; B525578A1D02DE8100E51965 /* FetchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52557871D02DE8100E51965 /* FetchTests.swift */; }; @@ -680,6 +702,7 @@ B5202CF91C04688100DED140 /* NSFetchedResultsController+Convenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSFetchedResultsController+Convenience.swift"; sourceTree = ""; }; B5220E071D0C5F8D009BC71E /* ObjectObserverTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ObjectObserverTests.swift; sourceTree = ""; }; B5220E0B1D0D0D19009BC71E /* ImportTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImportTests.swift; sourceTree = ""; }; + B5220E0F1D0DA6AB009BC71E /* ListObserverTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListObserverTests.swift; sourceTree = ""; }; B525576B1CFAF18F00E51965 /* IntoTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IntoTests.swift; sourceTree = ""; }; B525576F1D02561A00E51965 /* SelectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectTests.swift; sourceTree = ""; }; B52557731D02791400E51965 /* WhereTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WhereTests.swift; sourceTree = ""; }; @@ -964,6 +987,7 @@ B525577B1D0291FE00E51965 /* GroupByTests.swift */, B5220E0B1D0D0D19009BC71E /* ImportTests.swift */, B525576B1CFAF18F00E51965 /* IntoTests.swift */, + B5220E0F1D0DA6AB009BC71E /* ListObserverTests.swift */, B5DC47C51C93D22900FA3BF3 /* MigrationChainTests.swift */, B5220E071D0C5F8D009BC71E /* ObjectObserverTests.swift */, B52557771D02826E00E51965 /* OrderByTests.swift */, @@ -1766,6 +1790,7 @@ buildActionMask = 2147483647; files = ( B52557841D02A07400E51965 /* SectionByTests.swift in Sources */, + B5220E101D0DA6AB009BC71E /* ListObserverTests.swift in Sources */, B5519A401CA1B17B002BEF78 /* ErrorTests.swift in Sources */, B525577C1D0291FE00E51965 /* GroupByTests.swift in Sources */, B52557741D02791400E51965 /* WhereTests.swift in Sources */, @@ -1912,6 +1937,7 @@ buildActionMask = 2147483647; files = ( B52557851D02A07400E51965 /* SectionByTests.swift in Sources */, + B5220E111D0DA6AB009BC71E /* ListObserverTests.swift in Sources */, B5519A411CA1B17B002BEF78 /* ErrorTests.swift in Sources */, B525577D1D0291FE00E51965 /* GroupByTests.swift in Sources */, B52557751D02791400E51965 /* WhereTests.swift in Sources */, @@ -1941,6 +1967,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + B5220E1E1D13080D009BC71E /* CSListMonitor.swift in Sources */, B5DBE2D01C9914A900B5CEFA /* CSCoreStore.swift in Sources */, B5677D411CD3B1E400322BFC /* ICloudStoreObserver.swift in Sources */, B52DD1BE1BE1F94300949AFE /* NSProgress+Convenience.swift in Sources */, @@ -1956,17 +1983,22 @@ B5ECDC2D1CA81CC700C7F112 /* CSDataStack+Transaction.swift in Sources */, B5D7A5BA1CA3BF8F005C752B /* CSInto.swift in Sources */, B5A5F26A1CAEC50F004AB9AF /* CSSelect.swift in Sources */, + B5220E1B1D13079B009BC71E /* CSCoreStore+Observing.swift in Sources */, B5FEC1911C9166E700532541 /* NSPersistentStore+Setup.swift in Sources */, B52DD1AB1BE1F93900949AFE /* From.swift in Sources */, B546F95B1C99B17400D5AC55 /* CSCoreStore+Setup.swift in Sources */, B52DD1A11BE1F92C00949AFE /* DataStack+Transaction.swift in Sources */, B5D3F6481C887C0A00C7492A /* LegacySQLiteStore.swift in Sources */, + B5220E1C1D130801009BC71E /* FetchedResultsControllerDelegate.swift in Sources */, B52DD19E1BE1F92C00949AFE /* AsynchronousDataTransaction.swift in Sources */, B52DD1981BE1F92500949AFE /* CoreStore+Setup.swift in Sources */, + B5220E241D13085E009BC71E /* NSFetchedResultsController+Convenience.swift in Sources */, B559CD471CAA8B6300E4D58B /* CSSetupResult.swift in Sources */, B5ECDBF01CA6BF2000C7F112 /* CSFrom.swift in Sources */, + B5220E1F1D130810009BC71E /* CSListObserver.swift in Sources */, B52DD1941BE1F92500949AFE /* CoreStore.swift in Sources */, B52DD1A61BE1F92F00949AFE /* BaseDataTransaction+Importing.swift in Sources */, + B5220E1D1D13080A009BC71E /* CSDataStack+Observing.swift in Sources */, B52DD1A91BE1F93200949AFE /* CoreStore+Querying.swift in Sources */, B5519A4D1CA1F4FB002BEF78 /* CSError.swift in Sources */, B5E1B5AC1CAA49E2007FD580 /* CSDataStack+Migrating.swift in Sources */, @@ -1984,8 +2016,11 @@ B52DD1C31BE1F94600949AFE /* NotificationObserver.swift in Sources */, B52661441CADD585007B85D9 /* CoreStoreFetchRequest.swift in Sources */, B52DD1A81BE1F93200949AFE /* DataStack+Querying.swift in Sources */, + B5220E221D130818009BC71E /* CSSectionBy.swift in Sources */, B52DD1BC1BE1F94000949AFE /* MigrationResult.swift in Sources */, + B5220E231D130826009BC71E /* NSFetchedResultsController+ObjectiveC.swift in Sources */, B52DD19D1BE1F92C00949AFE /* BaseDataTransaction.swift in Sources */, + B5220E131D1305ED009BC71E /* SectionBy.swift in Sources */, B559CD4D1CAA8C6D00E4D58B /* CSStorageInterface.swift in Sources */, B5ECDBE91CA6BEA300C7F112 /* CSClauseTypes.swift in Sources */, B52DD1B81BE1F94000949AFE /* DataStack+Migration.swift in Sources */, @@ -2001,27 +2036,37 @@ B52DD1B01BE1F93900949AFE /* Tweak.swift in Sources */, B52DD1CA1BE1F94600949AFE /* NSManagedObjectModel+Setup.swift in Sources */, B52DD1A41BE1F92F00949AFE /* ImportableObject.swift in Sources */, + B5220E161D13067C009BC71E /* ObjectMonitor.swift in Sources */, B52DD1AE1BE1F93900949AFE /* OrderBy.swift in Sources */, B52DD1BA1BE1F94000949AFE /* MigrationChain.swift in Sources */, B50392FB1C479640009900CA /* NSManagedObject+Transaction.swift in Sources */, B52DD1A31BE1F92C00949AFE /* SaveResult.swift in Sources */, + B5220E211D130816009BC71E /* CSObjectObserver.swift in Sources */, B52DD19F1BE1F92C00949AFE /* SynchronousDataTransaction.swift in Sources */, B52DD1CB1BE1F94600949AFE /* WeakObject.swift in Sources */, B52DD1C11BE1F94600949AFE /* Functions.swift in Sources */, + B5220E1A1D130791009BC71E /* CoreStoreFetchedResultsController.swift in Sources */, B53FBA0F1CAB5E6500F0D40A /* CSCoreStore+Migrating.swift in Sources */, B59FA0B21CCBACA8007C9BCA /* ICloudStore.swift in Sources */, B52DD19A1BE1F92800949AFE /* CoreStore+Logging.swift in Sources */, B52DD1A71BE1F93200949AFE /* BaseDataTransaction+Querying.swift in Sources */, B546F96C1C9AF26D00D5AC55 /* CSInMemoryStore.swift in Sources */, B52DD1C61BE1F94600949AFE /* NSManagedObjectContext+CoreStore.swift in Sources */, + B5220E141D130614009BC71E /* DataStack+Observing.swift in Sources */, B52DD1A21BE1F92C00949AFE /* CoreStore+Transaction.swift in Sources */, B5E2222E1CA51B6E00BA2E95 /* CSUnsafeDataTransaction.swift in Sources */, + B5220E191D130761009BC71E /* ListMonitor.swift in Sources */, + B5220E181D130711009BC71E /* ObjectObserver.swift in Sources */, + B5220E251D13088E009BC71E /* ListObserver.swift in Sources */, B52DD1A01BE1F92C00949AFE /* UnsafeDataTransaction.swift in Sources */, B5ECDC331CA81CDC00C7F112 /* CSCoreStore+Transaction.swift in Sources */, B52DD1BB1BE1F94000949AFE /* MigrationType.swift in Sources */, B52DD1C91BE1F94600949AFE /* NSManagedObjectContext+Transaction.swift in Sources */, + B5220E151D130663009BC71E /* CoreStore+Observing.swift in Sources */, B52DD19B1BE1F92800949AFE /* CoreStoreLogger.swift in Sources */, B52DD1991BE1F92800949AFE /* DefaultLogger.swift in Sources */, + B5220E201D130813009BC71E /* CSObjectMonitor.swift in Sources */, + B5220E171D1306DF009BC71E /* UnsafeDataTransaction+Observing.swift in Sources */, B53FBA081CAB300C00F0D40A /* CSMigrationType.swift in Sources */, B52DD1B91BE1F94000949AFE /* CoreStore+Migration.swift in Sources */, B5519A5C1CA2008C002BEF78 /* CSBaseDataTransaction.swift in Sources */, @@ -2038,8 +2083,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - B52557861D02A07400E51965 /* SectionByTests.swift in Sources */, B5519A421CA1B17B002BEF78 /* ErrorTests.swift in Sources */, + B5220E271D1308D1009BC71E /* ObjectObserverTests.swift in Sources */, B525577E1D0291FE00E51965 /* GroupByTests.swift in Sources */, B52557761D02791400E51965 /* WhereTests.swift in Sources */, B5DC47C81C93D22900FA3BF3 /* MigrationChainTests.swift in Sources */, @@ -2048,8 +2093,8 @@ B525576E1CFAF18F00E51965 /* IntoTests.swift in Sources */, B580857C1CDF808F004C2EEB /* SetupTests.swift in Sources */, B525578A1D02DE8100E51965 /* FetchTests.swift in Sources */, + B5220E281D1308E5009BC71E /* SectionByTests.swift in Sources */, B5489F521CF603D5008B4978 /* FromTests.swift in Sources */, - B5220E0A1D0C5F8D009BC71E /* ObjectObserverTests.swift in Sources */, B525577A1D02826E00E51965 /* OrderByTests.swift in Sources */, B5489F441CF5EEBC008B4978 /* TestEntity2.swift in Sources */, B52557721D02561A00E51965 /* SelectTests.swift in Sources */, @@ -2057,6 +2102,7 @@ B52557821D029D2500E51965 /* TweakTests.swift in Sources */, B5489F4E1CF5F743008B4978 /* BaseTestCase.swift in Sources */, B5598BCC1BE2093D0092EFCE /* Model.xcdatamodeld in Sources */, + B5220E261D1308C2009BC71E /* ListObserverTests.swift in Sources */, B57D27C01D0BBE8200539C58 /* BaseTestDataTestCase.swift in Sources */, B5489F411CF5EEBC008B4978 /* TestEntity1.swift in Sources */, B57D27C41D0BC20100539C58 /* QueryTests.swift in Sources */, diff --git a/CoreStoreTests/BaseTests/BaseTestDataTestCase.swift b/CoreStoreTests/BaseTests/BaseTestDataTestCase.swift index 0d5460c..d9601b8 100644 --- a/CoreStoreTests/BaseTests/BaseTestDataTestCase.swift +++ b/CoreStoreTests/BaseTests/BaseTestDataTestCase.swift @@ -6,7 +6,7 @@ // Copyright © 2016 John Rommel Estropia. All rights reserved. // -import UIKit +import Foundation @testable import CoreStore diff --git a/CoreStoreTests/ListObserverTests.swift b/CoreStoreTests/ListObserverTests.swift new file mode 100644 index 0000000..258869a --- /dev/null +++ b/CoreStoreTests/ListObserverTests.swift @@ -0,0 +1,280 @@ +// +// ListObserverTests.swift +// CoreStore +// +// Copyright © 2016 John Rommel Estropia +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// + +import XCTest + +@testable +import CoreStore + + +#if os(iOS) || os(watchOS) || os(tvOS) + +// MARK: - ListObserverTests + +class ListObserverTests: BaseTestDataTestCase { + + @objc + dynamic func test_ThatListObservers_CanReceiveInsertNotifications() { + + self.prepareStack { (stack) in + + let observer = TestListObserver() + let monitor = stack.monitorSectionedList( + From(TestEntity1), + SectionBy("testBoolean"), + OrderBy(.Ascending("testEntityID")) + ) + monitor.addObserver(observer) + + XCTAssertFalse(monitor.hasObjects()) + XCTAssertFalse(monitor.hasObjectsInSection(0)) + XCTAssertTrue(monitor.objectsInAllSections().isEmpty) + + var events = 0 + + let willChangeExpectation = self.expectationForNotification( + "listMonitorWillChange:", + object: observer, + handler: { (note) -> Bool in + + XCTAssertEqual((note.userInfo ?? [:]), NSDictionary()) + defer { + + events += 1 + } + return events == 0 + } + ) + let didInsertSectionExpectation = self.expectationForNotification( + "listMonitor:didInsertSection:toSectionIndex:", + object: observer, + handler: { (note) -> Bool in + + XCTAssertEqual( + (note.userInfo ?? [:]), + [ + "sectionInfo": monitor.sectionInfoAtIndex(0), + "sectionIndex": 0 + ] as NSDictionary + ) + defer { + + events += 1 + } + return events == 1 + } + ) + let didInsertObjectExpectation = self.expectationForNotification( + "listMonitor:didInsertObject:toIndexPath:", + object: observer, + handler: { (note) -> Bool in + + let indexPath = note.userInfo?["indexPath"] as? NSIndexPath + XCTAssertEqual(indexPath?.section, 0) + XCTAssertEqual(indexPath?.row, 0) + + let object = note.userInfo?["object"] as? TestEntity1 + XCTAssertEqual(object?.testBoolean, NSNumber(bool: true)) + XCTAssertEqual(object?.testNumber, NSNumber(integer: 1)) + XCTAssertEqual(object?.testDecimal, NSDecimalNumber(string: "1")) + XCTAssertEqual(object?.testString, "nil:TestEntity1:1") + XCTAssertEqual(object?.testData, ("nil:TestEntity1:1" as NSString).dataUsingEncoding(NSUTF8StringEncoding)!) + XCTAssertEqual(object?.testDate, self.dateFormatter.dateFromString("2000-01-01T00:00:00Z")!) + defer { + + events += 1 + } + return events == 2 + } + ) + let didChangeExpectation = self.expectationForNotification( + "listMonitorDidChange:", + object: observer, + handler: { (note) -> Bool in + + XCTAssertEqual((note.userInfo ?? [:]), NSDictionary()) + defer { + + events += 1 + } + return events == 3 + } + ) + let saveExpectation = self.expectationWithDescription("save") + stack.beginAsynchronous { (transaction) in + + let object = transaction.create(Into(TestEntity1)) + object.testBoolean = NSNumber(bool: true) + object.testNumber = NSNumber(integer: 1) + object.testDecimal = NSDecimalNumber(string: "1") + object.testString = "nil:TestEntity1:1" + object.testData = ("nil:TestEntity1:1" as NSString).dataUsingEncoding(NSUTF8StringEncoding)! + object.testDate = self.dateFormatter.dateFromString("2000-01-01T00:00:00Z")! + + transaction.commit { (result) in + + switch result { + + case .Success(let hasChanges): + XCTAssertTrue(hasChanges) + saveExpectation.fulfill() + + case .Failure: + XCTFail() + } + } + } + self.waitAndCheckExpectations() + } + } +} + + +// MARK: TestListObserver + +class TestListObserver: ListSectionObserver { + + // MARK: ListObserver + + typealias ListEntityType = TestEntity1 + + func listMonitorWillChange(monitor: ListMonitor) { + + NSNotificationCenter.defaultCenter().postNotificationName( + "listMonitorWillChange:", + object: self, + userInfo: [:] + ) + } + + func listMonitorDidChange(monitor: ListMonitor) { + + NSNotificationCenter.defaultCenter().postNotificationName( + "listMonitorDidChange:", + object: self, + userInfo: [:] + ) + } + + func listMonitorWillRefetch(monitor: ListMonitor) { + + NSNotificationCenter.defaultCenter().postNotificationName( + "listMonitorWillRefetch:", + object: self, + userInfo: [:] + ) + } + + func listMonitorDidRefetch(monitor: ListMonitor) { + + NSNotificationCenter.defaultCenter().postNotificationName( + "listMonitorDidRefetch:", + object: self, + userInfo: [:] + ) + } + + + // MARK: ListObjectObserver + + func listMonitor(monitor: ListMonitor, didInsertObject object: TestEntity1, toIndexPath indexPath: NSIndexPath) { + + NSNotificationCenter.defaultCenter().postNotificationName( + "listMonitor:didInsertObject:toIndexPath:", + object: self, + userInfo: [ + "object": object, + "indexPath": indexPath + ] + ) + } + + func listMonitor(monitor: ListMonitor, didDeleteObject object: TestEntity1, fromIndexPath indexPath: NSIndexPath) { + + NSNotificationCenter.defaultCenter().postNotificationName( + "listMonitor:didDeleteObject:fromIndexPath:", + object: self, + userInfo: [ + "object": object, + "indexPath": indexPath + ] + ) + } + + func listMonitor(monitor: ListMonitor, didUpdateObject object: TestEntity1, atIndexPath indexPath: NSIndexPath) { + + NSNotificationCenter.defaultCenter().postNotificationName( + "listMonitor:didUpdateObject:atIndexPath:", + object: self, + userInfo: [ + "object": object, + "indexPath": indexPath + ] + ) + } + + + func listMonitor(monitor: ListMonitor, didMoveObject object: TestEntity1, fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) { + + NSNotificationCenter.defaultCenter().postNotificationName( + "listMonitor:didMoveObject:fromIndexPath:toIndexPath:", + object: self, + userInfo: [ + "object": object, + "fromIndexPath": fromIndexPath, + "toIndexPath": toIndexPath + ] + ) + } + + + // MARK: ListSectionObserver + + func listMonitor(monitor: ListMonitor, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int) { + + NSNotificationCenter.defaultCenter().postNotificationName( + "listMonitor:didInsertSection:toSectionIndex:", + object: self, + userInfo: [ + "sectionInfo": sectionInfo, + "sectionIndex": sectionIndex + ] + ) + } + + func listMonitor(monitor: ListMonitor, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int) { + + NSNotificationCenter.defaultCenter().postNotificationName( + "listMonitor:didDeleteSection:fromSectionIndex:", + object: self, + userInfo: [ + "sectionInfo": sectionInfo, + "sectionIndex": sectionIndex + ] + ) + } +} + +#endif diff --git a/CoreStoreTests/ObjectObserverTests.swift b/CoreStoreTests/ObjectObserverTests.swift index d7b95c4..c3d7f5d 100644 --- a/CoreStoreTests/ObjectObserverTests.swift +++ b/CoreStoreTests/ObjectObserverTests.swift @@ -29,9 +29,215 @@ import XCTest import CoreStore +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - ObjectObserverTests class ObjectObserverTests: BaseTestDataTestCase { - + @objc + dynamic func test_ThatObjectObservers_CanReceiveUpdateNotifications() { + + self.prepareStack { (stack) in + + self.prepareTestDataForStack(stack, configurations: [nil]) + + guard let object = stack.fetchOne( + From(TestEntity1), + Where("testEntityID", isEqualTo: 101)) else { + + XCTFail() + return + } + let observer = TestObjectObserver() + let monitor = stack.monitorObject(object) + monitor.addObserver(observer) + + XCTAssertEqual(monitor.object, object) + XCTAssertFalse(monitor.isObjectDeleted) + + var events = 0 + + let willUpdateExpectation = self.expectationForNotification( + "objectMonitor:willUpdateObject:", + object: observer, + handler: { (note) -> Bool in + + XCTAssertEqual( + (note.userInfo ?? [:]), + ["object": object] as NSDictionary + ) + defer { + + events += 1 + } + return events == 0 + } + ) + let didUpdateExpectation = self.expectationForNotification( + "objectMonitor:didUpdateObject:changedPersistentKeys:", + object: observer, + handler: { (note) -> Bool in + + XCTAssertEqual( + (note.userInfo ?? [:]), + [ + "object": object, + "changedPersistentKeys": Set( + [ + "testNumber", + "testString" + ] + ) + ] as NSDictionary + ) + let object = note.userInfo?["object"] as? TestEntity1 + XCTAssertEqual(object?.testNumber, NSNumber(integer: 10)) + XCTAssertEqual(object?.testString, "nil:TestEntity1:10") + + defer { + + events += 1 + } + return events == 1 + } + ) + let saveExpectation = self.expectationWithDescription("save") + stack.beginAsynchronous { (transaction) in + + guard let object = transaction.edit(object) else { + + XCTFail() + return + } + object.testNumber = NSNumber(integer: 10) + object.testString = "nil:TestEntity1:10" + + transaction.commit { (result) in + + switch result { + + case .Success(let hasChanges): + XCTAssertTrue(hasChanges) + saveExpectation.fulfill() + + case .Failure: + XCTFail() + } + } + } + self.waitAndCheckExpectations() + } + } + + @objc + dynamic func test_ThatObjectObservers_CanReceiveDeleteNotifications() { + + self.prepareStack { (stack) in + + self.prepareTestDataForStack(stack, configurations: [nil]) + + guard let object = stack.fetchOne( + From(TestEntity1), + Where("testEntityID", isEqualTo: 101)) else { + + XCTFail() + return + } + let observer = TestObjectObserver() + let monitor = stack.monitorObject(object) + monitor.addObserver(observer) + + XCTAssertEqual(monitor.object, object) + XCTAssertFalse(monitor.isObjectDeleted) + + var events = 0 + + let didDeleteExpectation = self.expectationForNotification( + "objectMonitor:didDeleteObject:", + object: observer, + handler: { (note) -> Bool in + + XCTAssertEqual( + (note.userInfo ?? [:]), + ["object": object] as NSDictionary + ) + defer { + + events += 1 + } + return events == 0 + } + ) + let saveExpectation = self.expectationWithDescription("save") + stack.beginAsynchronous { (transaction) in + + guard let object = transaction.edit(object) else { + + XCTFail() + return + } + transaction.delete(object) + + transaction.commit { (result) in + + switch result { + + case .Success(let hasChanges): + XCTAssertTrue(hasChanges) + XCTAssertTrue(monitor.isObjectDeleted) + saveExpectation.fulfill() + + case .Failure: + XCTFail() + } + } + } + self.waitAndCheckExpectations() + } + } } + + +// MARK: TestObjectObserver + +class TestObjectObserver: ObjectObserver { + + typealias ObjectEntityType = TestEntity1 + + func objectMonitor(monitor: ObjectMonitor, willUpdateObject object: TestEntity1) { + + NSNotificationCenter.defaultCenter().postNotificationName( + "objectMonitor:willUpdateObject:", + object: self, + userInfo: [ + "object": object + ] + ) + } + + func objectMonitor(monitor: ObjectMonitor, didUpdateObject object: TestEntity1, changedPersistentKeys: Set) { + + NSNotificationCenter.defaultCenter().postNotificationName( + "objectMonitor:didUpdateObject:changedPersistentKeys:", + object: self, + userInfo: [ + "object": object, + "changedPersistentKeys": changedPersistentKeys + ] + ) + } + + func objectMonitor(monitor: ObjectMonitor, didDeleteObject object: TestEntity1) { + + NSNotificationCenter.defaultCenter().postNotificationName( + "objectMonitor:didDeleteObject:", + object: self, + userInfo: [ + "object": object + ] + ) + } +} + +#endif diff --git a/CoreStoreTests/QueryTests.swift b/CoreStoreTests/QueryTests.swift index cae3d43..585499f 100644 --- a/CoreStoreTests/QueryTests.swift +++ b/CoreStoreTests/QueryTests.swift @@ -207,7 +207,8 @@ class QueryTests: BaseTestDataTestCase { let from = From(configurations) let queryClauses: [QueryClause] = [ - Where("%K > %@", "testNumber", 1) + Where("%K > %@", "testNumber", 1), + OrderBy(.Ascending("testEntityID")) ] do { diff --git a/CoreStoreTests/SectionByTests.swift b/CoreStoreTests/SectionByTests.swift index f13f9ec..67bf1d9 100644 --- a/CoreStoreTests/SectionByTests.swift +++ b/CoreStoreTests/SectionByTests.swift @@ -29,6 +29,8 @@ import XCTest import CoreStore +#if os(iOS) || os(watchOS) || os(tvOS) + //MARK: - SectionByTests final class SectionByTests: XCTestCase { @@ -51,3 +53,5 @@ final class SectionByTests: XCTestCase { } } } + +#endif diff --git a/README.md b/README.md index 4190ab2..73eaf47 100644 --- a/README.md +++ b/README.md @@ -1171,6 +1171,8 @@ let person2 = self.monitor[1, 2] - Swift 2.2 (Xcode 7.3) - Dependencies: - [GCDKit](https://github.com/JohnEstropia/GCDKit) +- Other notes: + - The `com.apple.CoreData.ConcurrencyDebug` debug argument should be turned off for the app. CoreStore already guarantees safety for you by making the main context read-only, and by only executing transactions serially. ### Install with CocoaPods (iOS 7 not supported) ``` diff --git a/Sources/Convenience/NSFetchedResultsController+Convenience.swift b/Sources/Convenience/NSFetchedResultsController+Convenience.swift index a5da48d..ec8b223 100644 --- a/Sources/Convenience/NSFetchedResultsController+Convenience.swift +++ b/Sources/Convenience/NSFetchedResultsController+Convenience.swift @@ -27,6 +27,8 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - NSFetchedResultsController public extension NSFetchedResultsController { @@ -217,3 +219,5 @@ public extension NSFetchedResultsController { ) } } + +#endif diff --git a/Sources/Fetching and Querying/Concrete Clauses/Select.swift b/Sources/Fetching and Querying/Concrete Clauses/Select.swift index a5eb12f..7b52dbc 100644 --- a/Sources/Fetching and Querying/Concrete Clauses/Select.swift +++ b/Sources/Fetching and Querying/Concrete Clauses/Select.swift @@ -413,7 +413,17 @@ extension Bool: SelectValueResultType { public static func fromResultObject(result: AnyObject) -> Bool? { - return (result as? NSNumber)?.boolValue + switch result { + + case let decimal as NSDecimalNumber: + return NSNumber(double: decimal.doubleValue).boolValue + + case let number as NSNumber: + return number.boolValue + + default: + return nil + } } } diff --git a/Sources/Internal/CoreStoreFetchedResultsController.swift b/Sources/Internal/CoreStoreFetchedResultsController.swift index 01a8500..1811aac 100644 --- a/Sources/Internal/CoreStoreFetchedResultsController.swift +++ b/Sources/Internal/CoreStoreFetchedResultsController.swift @@ -27,9 +27,10 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - CoreStoreFetchedResultsController -@available(OSX, unavailable) internal final class CoreStoreFetchedResultsController: NSFetchedResultsController { // MARK: Internal @@ -108,3 +109,5 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll @nonobjc private let reapplyAffectedStores: (fetchRequest: NSFetchRequest, context: NSManagedObjectContext) -> Bool } + +#endif diff --git a/Sources/Internal/FetchedResultsControllerDelegate.swift b/Sources/Internal/FetchedResultsControllerDelegate.swift index ee43b05..fe35a11 100644 --- a/Sources/Internal/FetchedResultsControllerDelegate.swift +++ b/Sources/Internal/FetchedResultsControllerDelegate.swift @@ -27,9 +27,10 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - FetchedResultsControllerHandler -@available(OSX, unavailable) internal protocol FetchedResultsControllerHandler: class { func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) @@ -46,7 +47,6 @@ internal protocol FetchedResultsControllerHandler: class { // MARK: - FetchedResultsControllerDelegate -@available(OSX, unavailable) internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResultsControllerDelegate { // MARK: Internal @@ -229,3 +229,5 @@ internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResult @nonobjc private var insertedSections = Set() } + +#endif diff --git a/Sources/Internal/NSManagedObjectContext+Setup.swift b/Sources/Internal/NSManagedObjectContext+Setup.swift index bda3c70..77fb99c 100644 --- a/Sources/Internal/NSManagedObjectContext+Setup.swift +++ b/Sources/Internal/NSManagedObjectContext+Setup.swift @@ -68,6 +68,9 @@ internal extension NSManagedObjectContext { context.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy context.undoManager = nil context.setupForCoreStoreWithContextName("com.corestore.rootcontext") + + #if os(iOS) || os(OSX) + context.observerForDidImportUbiquitousContentChangesNotification = NotificationObserver( notificationName: NSPersistentStoreDidImportUbiquitousContentChangesNotification, object: coordinator, @@ -84,6 +87,9 @@ internal extension NSManagedObjectContext { } } ) + + #endif + return context } diff --git a/Sources/Logging/CoreStore+CustomDebugStringConvertible.swift b/Sources/Logging/CoreStore+CustomDebugStringConvertible.swift index 3a641f4..c2c24f1 100644 --- a/Sources/Logging/CoreStore+CustomDebugStringConvertible.swift +++ b/Sources/Logging/CoreStore+CustomDebugStringConvertible.swift @@ -24,6 +24,7 @@ // import Foundation +import CoreData // MARK: - AsynchronousDataTransaction @@ -233,6 +234,8 @@ extension GroupBy: CustomDebugStringConvertible, CoreStoreDebugStringConvertible } +#if os(iOS) || os(OSX) + // MARK: - ICloudStore extension ICloudStore: CustomDebugStringConvertible, CoreStoreDebugStringConvertible { @@ -258,6 +261,8 @@ extension ICloudStore: CustomDebugStringConvertible, CoreStoreDebugStringConvert ) } } + +#endif // MARK: - InMemoryStore @@ -339,6 +344,8 @@ extension LegacySQLiteStore: CustomDebugStringConvertible, CoreStoreDebugStringC } +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - ListMonitor private struct CoreStoreFetchedSectionInfoWrapper: CoreStoreDebugStringConvertible { @@ -377,6 +384,7 @@ extension ListMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConvert ) } } +#endif // MARK: - LocalStorageOptions @@ -546,6 +554,8 @@ extension MigrationType: CustomDebugStringConvertible, CoreStoreDebugStringConve } +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - ObjectMonitor extension ObjectMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConvertible { @@ -569,7 +579,7 @@ extension ObjectMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConve ) } } - +#endif // MARK: - OrderBy @@ -629,6 +639,8 @@ extension SaveResult: CustomDebugStringConvertible, CoreStoreDebugStringConverti } +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - SectionBy extension SectionBy: CustomDebugStringConvertible, CoreStoreDebugStringConvertible { @@ -651,6 +663,7 @@ extension SectionBy: CustomDebugStringConvertible, CoreStoreDebugStringConvertib ) } } +#endif // MARK: - Select @@ -1093,7 +1106,7 @@ extension NSEntityDescription: CoreStoreDebugStringConvertible { ("renamingIdentifier", self.renamingIdentifier), ("compoundIndexes", self.compoundIndexes) ] - if #available(iOS 9.0, *) { + if #available(iOS 9.0, OSXApplicationExtension 10.11, *) { info.append(("uniquenessConstraints", self.uniquenessConstraints)) } diff --git a/Sources/ObjectiveC/CSCoreStore+Observing.swift b/Sources/ObjectiveC/CSCoreStore+Observing.swift index 96a72bc..d0b5732 100644 --- a/Sources/ObjectiveC/CSCoreStore+Observing.swift +++ b/Sources/ObjectiveC/CSCoreStore+Observing.swift @@ -27,9 +27,10 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - CSCoreStore -@available(OSX, unavailable) public extension CSCoreStore { /** @@ -114,3 +115,5 @@ public extension CSCoreStore { ) } } + +#endif diff --git a/Sources/ObjectiveC/CSDataStack+Observing.swift b/Sources/ObjectiveC/CSDataStack+Observing.swift index 9a4f045..194fbd0 100644 --- a/Sources/ObjectiveC/CSDataStack+Observing.swift +++ b/Sources/ObjectiveC/CSDataStack+Observing.swift @@ -27,9 +27,10 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - CSDataStack -@available(OSX, unavailable) public extension CSDataStack { /** @@ -181,3 +182,5 @@ public extension CSDataStack { ) } } + +#endif diff --git a/Sources/ObjectiveC/CSListMonitor.swift b/Sources/ObjectiveC/CSListMonitor.swift index b393772..9364f0e 100644 --- a/Sources/ObjectiveC/CSListMonitor.swift +++ b/Sources/ObjectiveC/CSListMonitor.swift @@ -27,6 +27,8 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - CSListMonitor /** @@ -34,7 +36,6 @@ import CoreData - SeeAlso: `ListMonitor` */ -@available(OSX, unavailable) @objc public final class CSListMonitor: NSObject, CoreStoreObjectiveCType { @@ -568,3 +569,5 @@ extension ListMonitor: CoreStoreSwiftType { return CSListMonitor(self) } } + +#endif diff --git a/Sources/ObjectiveC/CSListObserver.swift b/Sources/ObjectiveC/CSListObserver.swift index 9800d30..3c5e580 100644 --- a/Sources/ObjectiveC/CSListObserver.swift +++ b/Sources/ObjectiveC/CSListObserver.swift @@ -27,6 +27,8 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - CSListObserver /** @@ -40,7 +42,6 @@ import CoreData - SeeAlso: `ListObserver` */ -@available(OSX, unavailable) @objc public protocol CSListObserver: class, AnyObject { @@ -91,7 +92,6 @@ public protocol CSListObserver: class, AnyObject { - SeeAlso: `ListObjectObserver` */ -@available(OSX, unavailable) @objc public protocol CSListObjectObserver: CSListObserver { @@ -152,7 +152,6 @@ public protocol CSListObjectObserver: CSListObserver { - SeeAlso: `ListSectionObserver` */ -@available(OSX, unavailable) @objc public protocol CSListSectionObserver: CSListObjectObserver { @@ -176,3 +175,5 @@ public protocol CSListSectionObserver: CSListObjectObserver { @objc optional func listMonitor(monitor: CSListMonitor, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int) } + +#endif diff --git a/Sources/ObjectiveC/CSObjectMonitor.swift b/Sources/ObjectiveC/CSObjectMonitor.swift index 9be2891..f55b6e8 100644 --- a/Sources/ObjectiveC/CSObjectMonitor.swift +++ b/Sources/ObjectiveC/CSObjectMonitor.swift @@ -27,6 +27,8 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - CSObjectMonitor /** @@ -34,7 +36,6 @@ import CoreData - SeeAlso: `ObjectMonitor` */ -@available(OSX, unavailable) @objc public final class CSObjectMonitor: NSObject, CoreStoreObjectiveCType { @@ -146,3 +147,5 @@ extension ObjectMonitor: CoreStoreSwiftType { return CSObjectMonitor(self) } } + +#endif diff --git a/Sources/ObjectiveC/CSObjectObserver.swift b/Sources/ObjectiveC/CSObjectObserver.swift index 8338949..af0f73d 100644 --- a/Sources/ObjectiveC/CSObjectObserver.swift +++ b/Sources/ObjectiveC/CSObjectObserver.swift @@ -27,6 +27,8 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - CSObjectObserver /** @@ -38,7 +40,6 @@ import CoreData - SeeAlso: `ObjectObserver` */ -@available(OSX, unavailable) @objc public protocol CSObjectObserver: class, AnyObject { @@ -70,3 +71,5 @@ public protocol CSObjectObserver: class, AnyObject { @objc optional func objectMonitor(monitor: CSObjectMonitor, didDeleteObject object: AnyObject) } + +#endif diff --git a/Sources/ObjectiveC/CSSectionBy.swift b/Sources/ObjectiveC/CSSectionBy.swift index d7f9bcb..bf758f6 100644 --- a/Sources/ObjectiveC/CSSectionBy.swift +++ b/Sources/ObjectiveC/CSSectionBy.swift @@ -27,6 +27,8 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - CSSectionBy /** @@ -34,7 +36,6 @@ import CoreData - SeeAlso: `SectionBy` */ -@available(OSX, unavailable) @objc public final class CSSectionBy: NSObject, CoreStoreObjectiveCType { @@ -92,3 +93,5 @@ extension SectionBy: CoreStoreSwiftType { public typealias ObjectiveCType = CSSectionBy } + +#endif diff --git a/Sources/ObjectiveC/NSFetchedResultsController+ObjectiveC.swift b/Sources/ObjectiveC/NSFetchedResultsController+ObjectiveC.swift index bed5fbd..59d6cec 100644 --- a/Sources/ObjectiveC/NSFetchedResultsController+ObjectiveC.swift +++ b/Sources/ObjectiveC/NSFetchedResultsController+ObjectiveC.swift @@ -27,9 +27,10 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - NSFetchedResultsController -@available(OSX, unavailable) public extension NSFetchedResultsController { /** @@ -61,3 +62,5 @@ public extension NSFetchedResultsController { ) } } + +#endif diff --git a/Sources/Observing/CoreStore+Observing.swift b/Sources/Observing/CoreStore+Observing.swift index 807dd56..b956d60 100644 --- a/Sources/Observing/CoreStore+Observing.swift +++ b/Sources/Observing/CoreStore+Observing.swift @@ -27,9 +27,10 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - CoreStore -@available(OSX, unavailable) public extension CoreStore { /** @@ -148,3 +149,5 @@ public extension CoreStore { self.defaultStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses) } } + +#endif diff --git a/Sources/Observing/DataStack+Observing.swift b/Sources/Observing/DataStack+Observing.swift index 0c2c54d..4d08a90 100644 --- a/Sources/Observing/DataStack+Observing.swift +++ b/Sources/Observing/DataStack+Observing.swift @@ -30,9 +30,10 @@ import CoreData #endif +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - DataStack -@available(OSX, unavailable) public extension DataStack { /** @@ -227,3 +228,5 @@ public extension DataStack { ) } } + +#endif diff --git a/Sources/Observing/ListMonitor.swift b/Sources/Observing/ListMonitor.swift index 975d17f..81e3538 100644 --- a/Sources/Observing/ListMonitor.swift +++ b/Sources/Observing/ListMonitor.swift @@ -30,6 +30,8 @@ import CoreData #endif +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - ListMonitor /** @@ -69,7 +71,6 @@ import CoreData ``` In the example above, both `person1` and `person2` will contain the object at section=2, index=3. */ -@available(OSX, unavailable) public final class ListMonitor: Hashable { // MARK: Public (Accessors) @@ -1163,41 +1164,35 @@ public final class ListMonitor: Hashable { // MARK: - ListMonitor: Equatable -@available(OSX, unavailable) @warn_unused_result public func == (lhs: ListMonitor, rhs: ListMonitor) -> Bool { return lhs === rhs } -@available(OSX, unavailable) @warn_unused_result public func == (lhs: ListMonitor, rhs: ListMonitor) -> Bool { return lhs.fetchedResultsController === rhs.fetchedResultsController } -@available(OSX, unavailable) @warn_unused_result public func ~= (lhs: ListMonitor, rhs: ListMonitor) -> Bool { return lhs === rhs } -@available(OSX, unavailable) @warn_unused_result public func ~= (lhs: ListMonitor, rhs: ListMonitor) -> Bool { return lhs.fetchedResultsController === rhs.fetchedResultsController } -@available(OSX, unavailable) extension ListMonitor: Equatable { } // MARK: - ListMonitor: FetchedResultsControllerHandler -@available(OSX, unavailable) extension ListMonitor: FetchedResultsControllerHandler { // MARK: FetchedResultsControllerHandler @@ -1324,3 +1319,5 @@ private let UserInfoKeyNewIndexPath = "UserInfoKeyNewIndexPath" private let UserInfoKeySectionInfo = "UserInfoKeySectionInfo" private let UserInfoKeySectionIndex = "UserInfoKeySectionIndex" + +#endif diff --git a/Sources/Observing/ListObserver.swift b/Sources/Observing/ListObserver.swift index 61c11c8..0e53402 100644 --- a/Sources/Observing/ListObserver.swift +++ b/Sources/Observing/ListObserver.swift @@ -27,6 +27,8 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - ListObserver /** @@ -39,7 +41,6 @@ import CoreData monitor.addObserver(self) ``` */ -@available(OSX, unavailable) public protocol ListObserver: class { /** @@ -79,7 +80,6 @@ public protocol ListObserver: class { // MARK: - ListObserver (Default Implementations) -@available(OSX, unavailable) public extension ListObserver { /** @@ -116,7 +116,6 @@ public extension ListObserver { monitor.addObserver(self) ``` */ -@available(OSX, unavailable) public protocol ListObjectObserver: ListObserver { /** @@ -160,7 +159,6 @@ public protocol ListObjectObserver: ListObserver { // MARK: - ListObjectObserver (Default Implementations) -@available(OSX, unavailable) public extension ListObjectObserver { /** @@ -198,7 +196,6 @@ public extension ListObjectObserver { monitor.addObserver(self) ``` */ -@available(OSX, unavailable) public protocol ListSectionObserver: ListObjectObserver { /** @@ -223,7 +220,6 @@ public protocol ListSectionObserver: ListObjectObserver { // MARK: - ListSectionObserver (Default Implementations) -@available(OSX, unavailable) public extension ListSectionObserver { /** @@ -236,3 +232,5 @@ public extension ListSectionObserver { */ func listMonitor(monitor: ListMonitor, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int) { } } + +#endif diff --git a/Sources/Observing/ObjectMonitor.swift b/Sources/Observing/ObjectMonitor.swift index fc61246..e1e4ff3 100644 --- a/Sources/Observing/ObjectMonitor.swift +++ b/Sources/Observing/ObjectMonitor.swift @@ -30,6 +30,8 @@ import CoreData #endif +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - ObjectMonitor /** @@ -42,7 +44,6 @@ import CoreData Observers registered via `addObserver(_:)` are not retained. `ObjectMonitor` only keeps a `weak` reference to all observers, thus keeping itself free from retain-cycles. */ -@available(OSX, unavailable) public final class ObjectMonitor { /** @@ -300,25 +301,21 @@ public final class ObjectMonitor { // MARK: - ObjectMonitor: Equatable -@available(OSX, unavailable) public func == (lhs: ObjectMonitor, rhs: ObjectMonitor) -> Bool { return lhs === rhs } -@available(OSX, unavailable) public func ~= (lhs: ObjectMonitor, rhs: ObjectMonitor) -> Bool { return lhs === rhs } -@available(OSX, unavailable) extension ObjectMonitor: Equatable { } // MARK: - ObjectMonitor: FetchedResultsControllerHandler -@available(OSX, unavailable) extension ObjectMonitor: FetchedResultsControllerHandler { // MARK: FetchedResultsControllerHandler @@ -371,3 +368,4 @@ private let ObjectMonitorDidUpdateObjectNotification = "ObjectMonitorDidUpdateOb private let UserInfoKeyObject = "UserInfoKeyObject" +#endif diff --git a/Sources/Observing/ObjectObserver.swift b/Sources/Observing/ObjectObserver.swift index ca662bd..f514ba4 100644 --- a/Sources/Observing/ObjectObserver.swift +++ b/Sources/Observing/ObjectObserver.swift @@ -27,6 +27,8 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - ObjectObserver /** @@ -36,7 +38,6 @@ import CoreData monitor.addObserver(self) ``` */ -@available(OSX, unavailable) public protocol ObjectObserver: class { /** @@ -73,7 +74,6 @@ public protocol ObjectObserver: class { // MARK: - ObjectObserver (Default Implementations) -@available(OSX, unavailable) public extension ObjectObserver { /** @@ -91,3 +91,5 @@ public extension ObjectObserver { */ func objectMonitor(monitor: ObjectMonitor, didDeleteObject object: ObjectEntityType) { } } + +#endif diff --git a/Sources/Observing/SectionBy.swift b/Sources/Observing/SectionBy.swift index 97d307f..e472fa3 100644 --- a/Sources/Observing/SectionBy.swift +++ b/Sources/Observing/SectionBy.swift @@ -27,6 +27,8 @@ import Foundation import CoreData +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - SectionBy /** @@ -39,7 +41,6 @@ import CoreData ) ``` */ -@available(OSX, unavailable) public struct SectionBy { /** @@ -71,3 +72,5 @@ public struct SectionBy { internal let sectionKeyPath: KeyPath internal let sectionIndexTransformer: (sectionName: KeyPath?) -> String? } + +#endif diff --git a/Sources/Observing/UnsafeDataTransaction+Observing.swift b/Sources/Observing/UnsafeDataTransaction+Observing.swift index 436cf7e..86e80c6 100644 --- a/Sources/Observing/UnsafeDataTransaction+Observing.swift +++ b/Sources/Observing/UnsafeDataTransaction+Observing.swift @@ -30,9 +30,10 @@ import CoreData #endif +#if os(iOS) || os(watchOS) || os(tvOS) + // MARK: - UnsafeDataTransaction -@available(OSX, unavailable) public extension UnsafeDataTransaction { /** @@ -208,3 +209,5 @@ public extension UnsafeDataTransaction { ) } } + +#endif diff --git a/Sources/Setup/StorageInterfaces/ICloudStore.swift b/Sources/Setup/StorageInterfaces/ICloudStore.swift index 7512ddc..70223c8 100644 --- a/Sources/Setup/StorageInterfaces/ICloudStore.swift +++ b/Sources/Setup/StorageInterfaces/ICloudStore.swift @@ -27,6 +27,8 @@ import Foundation import CoreData +#if os(iOS) || os(OSX) + // MARK: - ICloudStore /** @@ -502,3 +504,5 @@ private let ICloudUbiquitousStoreWillRemoveContentNotification = "ICloudUbiquito private let ICloudUbiquitousStoreDidRemoveContentNotification = "ICloudUbiquitousStoreDidRemoveContentNotification" private let UserInfoKeyDataStack = "UserInfoKeyDataStack" + +#endif diff --git a/Sources/Setup/StorageInterfaces/ICloudStoreObserver.swift b/Sources/Setup/StorageInterfaces/ICloudStoreObserver.swift index 7c257cc..edd5b6e 100644 --- a/Sources/Setup/StorageInterfaces/ICloudStoreObserver.swift +++ b/Sources/Setup/StorageInterfaces/ICloudStoreObserver.swift @@ -26,6 +26,8 @@ import Foundation +#if os(iOS) || os(OSX) + // MARK: - ICloudStoreObserver /** @@ -120,3 +122,5 @@ public extension ICloudStoreObserver { public func iCloudStoreDidRemoveContent(storage storage: ICloudStore, dataStack: DataStack) {} } + +#endif diff --git a/Sources/Setup/StorageInterfaces/LegacySQLiteStore.swift b/Sources/Setup/StorageInterfaces/LegacySQLiteStore.swift index a1fe0ce..b72c0fc 100644 --- a/Sources/Setup/StorageInterfaces/LegacySQLiteStore.swift +++ b/Sources/Setup/StorageInterfaces/LegacySQLiteStore.swift @@ -24,6 +24,7 @@ // import Foundation +import CoreData // MARK: - LegacySQLiteStore