Add PromiseKit dependency

- Added PromiseKit dependency
This commit is contained in:
2018-11-15 22:08:00 -04:00
parent 2689d86c18
commit be7b6b5881
541 changed files with 46282 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
*.xcodeproj/**/xcuserdata/
*.xcscmblueprint
/Carthage
/.build
.DS_Store

View File

@@ -0,0 +1,84 @@
branches:
only:
- master
stages:
- lint
- carthage
- test
jobs:
include:
- &pod
stage: lint
osx_image: xcode8.3
env: SWIFT=3.1
name: pod lib lint --swift-version=3.1
os: osx
language: objective-c
before_install:
gem install cocoapods --prerelease --version 1.6.0.beta.1
install:
carthage bootstrap --no-build PromiseKit
script: |
cd Carthage/Checkouts/PromiseKit
mv .github/PromiseKit.podspec .
rm -rf Extensions/CloudKit/Sources
cp -R ../../../Sources Extensions/CloudKit
pod lib lint --subspec=PromiseKit/CloudKit --fail-fast --swift-version=$SWIFT
- <<: *pod
osx_image: xcode9.2
env: SWIFT=3.2
name: pod lib lint --swift-version=3.2
- <<: *pod
osx_image: xcode9.4
env: SWIFT=3.3
name: pod lib lint --swift-version=3.3
- <<: *pod
osx_image: xcode10
env: SWIFT=3.4
name: pod lib lint --swift-version=3.4
- <<: *pod
osx_image: xcode9.2
env: SWIFT=4.0
name: pod lib lint --swift-version=4.0
- <<: *pod
osx_image: xcode9.4
env: SWIFT=4.1
name: pod lib lint --swift-version=4.1
- <<: *pod
osx_image: xcode10
env: SWIFT=4.2
name: pod lib lint --swift-version=4.2
- stage: carthage
osx_image: xcode10
name: Carthage / watchOS
os: osx
language: objective-c
script:
carthage bootstrap --platform watchOS
cache:
directories:
- Carthage
- &test
stage: test
osx_image: xcode10
name: macOS Tests
env: DST='arch=x86_64' PLAT=macOS
os: osx
language: objective-c
cache:
directories:
- Carthage
before_install:
carthage bootstrap --cache-builds --no-use-binaries --platform $PLAT
install:
xcodebuild -scheme PMKCloudKit -target PMKCloudKit -quiet -destination "$DST" SWIFT_TREAT_WARNINGS_AS_ERRORS=YES build
script:
xcodebuild -scheme PMKCloudKit -quiet -destination "$DST" test
- <<: *test
env: DST='OS=12.0,name=iPhone SE' PLAT=iOS
name: iOS Tests
- <<: *test
env: DST='OS=12.0,name=Apple TV' PLAT=tvOS
name: tvOS Tests

View File

@@ -0,0 +1 @@
github "mxcl/PromiseKit" ~> 6.0

View File

@@ -0,0 +1 @@
github "mxcl/PromiseKit" "6.5.0"

View File

@@ -0,0 +1,7 @@
// Created by Kevin Ballard on 12/14/15.
// Copyright © 2015 Postmates. All rights reserved.
FRAMEWORK_SEARCH_PATHS[sdk=macosx*] = $(SRCROOT)/Carthage/Build/Mac/ $(inherited)
FRAMEWORK_SEARCH_PATHS[sdk=iphone*] = $(SRCROOT)/Carthage/Build/iOS/ $(inherited)
FRAMEWORK_SEARCH_PATHS[sdk=watch*] = $(SRCROOT)/Carthage/Build/watchOS/ $(inherited)
FRAMEWORK_SEARCH_PATHS[sdk=appletv*] = $(SRCROOT)/Carthage/Build/tvOS/ $(inherited)

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@@ -0,0 +1,479 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
63C7FFF71D5C020D003BAE60 /* PMKCloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63C7FFA71D5BEE09003BAE60 /* PMKCloudKit.framework */; };
63F6071E1D5D48B200A11DEA /* CKContainer+AnyPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = 63F607171D5D48B200A11DEA /* CKContainer+AnyPromise.h */; settings = {ATTRIBUTES = (Public, ); }; };
63F6071F1D5D48B200A11DEA /* CKContainer+AnyPromise.m in Sources */ = {isa = PBXBuildFile; fileRef = 63F607181D5D48B200A11DEA /* CKContainer+AnyPromise.m */; };
63F607201D5D48B200A11DEA /* CKContainer+Promise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63F607191D5D48B200A11DEA /* CKContainer+Promise.swift */; };
63F607211D5D48B200A11DEA /* CKDatabase+AnyPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = 63F6071A1D5D48B200A11DEA /* CKDatabase+AnyPromise.h */; settings = {ATTRIBUTES = (Public, ); }; };
63F607221D5D48B200A11DEA /* CKDatabase+AnyPromise.m in Sources */ = {isa = PBXBuildFile; fileRef = 63F6071B1D5D48B200A11DEA /* CKDatabase+AnyPromise.m */; };
63F607231D5D48B200A11DEA /* CKDatabase+Promise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63F6071C1D5D48B200A11DEA /* CKDatabase+Promise.swift */; };
63F607241D5D48B200A11DEA /* PMKCloudKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 63F6071D1D5D48B200A11DEA /* PMKCloudKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
63F607281D5D48D600A11DEA /* TestCloudKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63F607271D5D48D600A11DEA /* TestCloudKit.swift */; };
63F6072C1D5D4A0200A11DEA /* infrastructure.m in Sources */ = {isa = PBXBuildFile; fileRef = 63F6072B1D5D4A0200A11DEA /* infrastructure.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
63C7FFF81D5C020D003BAE60 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 63C7FF9E1D5BEE09003BAE60 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 63C7FFA61D5BEE09003BAE60;
remoteInfo = PMKCloudKit;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
63C700091D5C0253003BAE60 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
63C7FFA71D5BEE09003BAE60 /* PMKCloudKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PMKCloudKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
63C7FFF21D5C020D003BAE60 /* PMKCKTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PMKCKTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
63CCF8121D5C0C4E00503216 /* Cartfile */ = {isa = PBXFileReference; lastKnownFileType = text; path = Cartfile; sourceTree = "<group>"; };
63CCF8171D5C11B500503216 /* Carthage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Carthage.xcconfig; sourceTree = "<group>"; };
63F607171D5D48B200A11DEA /* CKContainer+AnyPromise.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "CKContainer+AnyPromise.h"; path = "Sources/CKContainer+AnyPromise.h"; sourceTree = SOURCE_ROOT; };
63F607181D5D48B200A11DEA /* CKContainer+AnyPromise.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "CKContainer+AnyPromise.m"; path = "Sources/CKContainer+AnyPromise.m"; sourceTree = SOURCE_ROOT; };
63F607191D5D48B200A11DEA /* CKContainer+Promise.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "CKContainer+Promise.swift"; path = "Sources/CKContainer+Promise.swift"; sourceTree = SOURCE_ROOT; };
63F6071A1D5D48B200A11DEA /* CKDatabase+AnyPromise.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "CKDatabase+AnyPromise.h"; path = "Sources/CKDatabase+AnyPromise.h"; sourceTree = SOURCE_ROOT; };
63F6071B1D5D48B200A11DEA /* CKDatabase+AnyPromise.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "CKDatabase+AnyPromise.m"; path = "Sources/CKDatabase+AnyPromise.m"; sourceTree = SOURCE_ROOT; };
63F6071C1D5D48B200A11DEA /* CKDatabase+Promise.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "CKDatabase+Promise.swift"; path = "Sources/CKDatabase+Promise.swift"; sourceTree = SOURCE_ROOT; };
63F6071D1D5D48B200A11DEA /* PMKCloudKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PMKCloudKit.h; path = Sources/PMKCloudKit.h; sourceTree = SOURCE_ROOT; };
63F607271D5D48D600A11DEA /* TestCloudKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TestCloudKit.swift; path = Tests/TestCloudKit.swift; sourceTree = SOURCE_ROOT; };
63F6072A1D5D49BD00A11DEA /* infrastructure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = infrastructure.h; path = Tests/infrastructure.h; sourceTree = SOURCE_ROOT; };
63F6072B1D5D4A0200A11DEA /* infrastructure.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = infrastructure.m; path = Tests/infrastructure.m; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
63C7FFA31D5BEE09003BAE60 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
63C7FFEF1D5C020D003BAE60 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
63C7FFF71D5C020D003BAE60 /* PMKCloudKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
63C7FF9D1D5BEE09003BAE60 = {
isa = PBXGroup;
children = (
63C700091D5C0253003BAE60 /* Info.plist */,
63CCF8121D5C0C4E00503216 /* Cartfile */,
63CCF8171D5C11B500503216 /* Carthage.xcconfig */,
63C7FFA91D5BEE09003BAE60 /* Sources */,
63C7FFF31D5C020D003BAE60 /* Tests */,
63C7FFA81D5BEE09003BAE60 /* Products */,
);
sourceTree = "<group>";
};
63C7FFA81D5BEE09003BAE60 /* Products */ = {
isa = PBXGroup;
children = (
63C7FFA71D5BEE09003BAE60 /* PMKCloudKit.framework */,
63C7FFF21D5C020D003BAE60 /* PMKCKTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
63C7FFA91D5BEE09003BAE60 /* Sources */ = {
isa = PBXGroup;
children = (
63F607171D5D48B200A11DEA /* CKContainer+AnyPromise.h */,
63F607181D5D48B200A11DEA /* CKContainer+AnyPromise.m */,
63F607191D5D48B200A11DEA /* CKContainer+Promise.swift */,
63F6071A1D5D48B200A11DEA /* CKDatabase+AnyPromise.h */,
63F6071B1D5D48B200A11DEA /* CKDatabase+AnyPromise.m */,
63F6071C1D5D48B200A11DEA /* CKDatabase+Promise.swift */,
63F6071D1D5D48B200A11DEA /* PMKCloudKit.h */,
);
path = Sources;
sourceTree = SOURCE_ROOT;
};
63C7FFF31D5C020D003BAE60 /* Tests */ = {
isa = PBXGroup;
children = (
63F6072A1D5D49BD00A11DEA /* infrastructure.h */,
63F6072B1D5D4A0200A11DEA /* infrastructure.m */,
63F607271D5D48D600A11DEA /* TestCloudKit.swift */,
);
path = Tests;
sourceTree = SOURCE_ROOT;
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
63C7FFA41D5BEE09003BAE60 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
63F607241D5D48B200A11DEA /* PMKCloudKit.h in Headers */,
63F6071E1D5D48B200A11DEA /* CKContainer+AnyPromise.h in Headers */,
63F607211D5D48B200A11DEA /* CKDatabase+AnyPromise.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
63C7FFA61D5BEE09003BAE60 /* PMKCloudKit */ = {
isa = PBXNativeTarget;
buildConfigurationList = 63C7FFAF1D5BEE09003BAE60 /* Build configuration list for PBXNativeTarget "PMKCloudKit" */;
buildPhases = (
63C7FFA21D5BEE09003BAE60 /* Sources */,
63C7FFA31D5BEE09003BAE60 /* Frameworks */,
63C7FFA41D5BEE09003BAE60 /* Headers */,
);
buildRules = (
);
dependencies = (
);
name = PMKCloudKit;
productName = "PMK+UIKit";
productReference = 63C7FFA71D5BEE09003BAE60 /* PMKCloudKit.framework */;
productType = "com.apple.product-type.framework";
};
63C7FFF11D5C020D003BAE60 /* PMKCKTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 63C7FFFA1D5C020D003BAE60 /* Build configuration list for PBXNativeTarget "PMKCKTests" */;
buildPhases = (
63C7FFEE1D5C020D003BAE60 /* Sources */,
63C7FFEF1D5C020D003BAE60 /* Frameworks */,
639447051D5D011300DDAE3C /* Embed Carthage Frameworks */,
);
buildRules = (
);
dependencies = (
63C7FFF91D5C020D003BAE60 /* PBXTargetDependency */,
);
name = PMKCKTests;
productName = PMKTests/NS;
productReference = 63C7FFF21D5C020D003BAE60 /* PMKCKTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
63C7FF9E1D5BEE09003BAE60 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 1000;
ORGANIZATIONNAME = "Max Howell";
TargetAttributes = {
63C7FFA61D5BEE09003BAE60 = {
CreatedOnToolsVersion = 8.0;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
63C7FFF11D5C020D003BAE60 = {
CreatedOnToolsVersion = 8.0;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 63C7FFA11D5BEE09003BAE60 /* Build configuration list for PBXProject "PMKCloudKit" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 63C7FF9D1D5BEE09003BAE60;
productRefGroup = 63C7FFA81D5BEE09003BAE60 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
63C7FFA61D5BEE09003BAE60 /* PMKCloudKit */,
63C7FFF11D5C020D003BAE60 /* PMKCKTests */,
);
};
/* End PBXProject section */
/* Begin PBXShellScriptBuildPhase section */
639447051D5D011300DDAE3C /* Embed Carthage Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
PromiseKit,
);
name = "Embed Carthage Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "case \"$PLATFORM_NAME\" in\nmacosx) plat=Mac;;\niphone*) plat=iOS;;\nwatch*) plat=watchOS;;\nappletv*) plat=tvOS;;\n*) echo \"error: Unknown PLATFORM_NAME: $PLATFORM_NAME\"; exit 1;;\nesac\nfor (( n = 0; n < SCRIPT_INPUT_FILE_COUNT; n++ )); do\nVAR=SCRIPT_INPUT_FILE_$n\nframework=$(basename \"${!VAR}\")\nexport SCRIPT_INPUT_FILE_$n=\"$SRCROOT\"/Carthage/Build/$plat/\"$framework\".framework\ndone\n\n/usr/local/bin/carthage copy-frameworks || exit\n\nfor (( n = 0; n < SCRIPT_INPUT_FILE_COUNT; n++ )); do\nVAR=SCRIPT_INPUT_FILE_$n\nsource=${!VAR}.dSYM\ndest=${BUILT_PRODUCTS_DIR}/$(basename \"$source\")\nditto \"$source\" \"$dest\" || exit\ndone\n";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
63C7FFA21D5BEE09003BAE60 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
63F607231D5D48B200A11DEA /* CKDatabase+Promise.swift in Sources */,
63F6071F1D5D48B200A11DEA /* CKContainer+AnyPromise.m in Sources */,
63F607201D5D48B200A11DEA /* CKContainer+Promise.swift in Sources */,
63F607221D5D48B200A11DEA /* CKDatabase+AnyPromise.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
63C7FFEE1D5C020D003BAE60 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
63F6072C1D5D4A0200A11DEA /* infrastructure.m in Sources */,
63F607281D5D48D600A11DEA /* TestCloudKit.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
63C7FFF91D5C020D003BAE60 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 63C7FFA61D5BEE09003BAE60 /* PMKCloudKit */;
targetProxy = 63C7FFF81D5C020D003BAE60 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
63C7FFAD1D5BEE09003BAE60 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 63CCF8171D5C11B500503216 /* Carthage.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.promisekit.CloudKit;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos watchsimulator watchos macosx appletvsimulator appletvos";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 10.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 3.0;
};
name = Debug;
};
63C7FFAE1D5BEE09003BAE60 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 63CCF8171D5C11B500503216 /* Carthage.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = org.promisekit.CloudKit;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos watchsimulator watchos macosx appletvsimulator appletvos";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 10.0;
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 3.0;
};
name = Release;
};
63C7FFB01D5BEE09003BAE60 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_MODULE_NAME = "${TARGET_NAME}";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
63C7FFB11D5BEE09003BAE60 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_MODULE_NAME = "${TARGET_NAME}";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
63C7FFFB1D5C020D003BAE60 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
GCC_WARN_INHIBIT_ALL_WARNINGS = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = Tests/infrastructure.h;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SUPPRESS_WARNINGS = YES;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
63C7FFFC1D5C020D003BAE60 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
GCC_WARN_INHIBIT_ALL_WARNINGS = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = Tests/infrastructure.h;
SWIFT_SUPPRESS_WARNINGS = YES;
SWIFT_VERSION = 4.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
63C7FFA11D5BEE09003BAE60 /* Build configuration list for PBXProject "PMKCloudKit" */ = {
isa = XCConfigurationList;
buildConfigurations = (
63C7FFAD1D5BEE09003BAE60 /* Debug */,
63C7FFAE1D5BEE09003BAE60 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
63C7FFAF1D5BEE09003BAE60 /* Build configuration list for PBXNativeTarget "PMKCloudKit" */ = {
isa = XCConfigurationList;
buildConfigurations = (
63C7FFB01D5BEE09003BAE60 /* Debug */,
63C7FFB11D5BEE09003BAE60 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
63C7FFFA1D5C020D003BAE60 /* Build configuration list for PBXNativeTarget "PMKCKTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
63C7FFFB1D5C020D003BAE60 /* Debug */,
63C7FFFC1D5C020D003BAE60 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 63C7FF9E1D5BEE09003BAE60 /* Project object */;
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:/Users/mxcl/Desktop/PMK+UIKit/PMKFoundation.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
<false/>
</dict>
</plist>

View File

@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "NO">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "NO"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "63C7FFA61D5BEE09003BAE60"
BuildableName = "PMKCloudKit.framework"
BlueprintName = "PMKCloudKit"
ReferencedContainer = "container:PMKCloudKit.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "63C7FFF11D5C020D003BAE60"
BuildableName = "PMKCKTests.xctest"
BlueprintName = "PMKCKTests"
ReferencedContainer = "container:PMKCloudKit.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "63C7FFF11D5C020D003BAE60"
BuildableName = "PMKCKTests.xctest"
BlueprintName = "PMKCKTests"
ReferencedContainer = "container:PMKCloudKit.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "63C7FFA61D5BEE09003BAE60"
BuildableName = "PMKCloudKit.framework"
BlueprintName = "PMKCloudKit"
ReferencedContainer = "container:PMKCloudKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "63C7FFA61D5BEE09003BAE60"
BuildableName = "PMKCloudKit.framework"
BlueprintName = "PMKCloudKit"
ReferencedContainer = "container:PMKCloudKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "63C7FFA61D5BEE09003BAE60"
BuildableName = "PMKCloudKit.framework"
BlueprintName = "PMKCloudKit"
ReferencedContainer = "container:PMKCloudKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -0,0 +1,16 @@
import PackageDescription
let pkg = Package(name: "PMKCloudKit")
pkg.dependencies = [
.Package(url: "https://github.com/mxcl/PromiseKit.git", majorVersion: 6)
]
pkg.exclude = [
"Sources/CKContainer+AnyPromise.h",
"Sources/CKDatabase+AnyPromise.h",
"Sources/PMKCloudKit.h",
"Sources/CKContainer+AnyPromise.m",
"Sources/CKDatabase+AnyPromise.m",
"Tests"
]

View File

@@ -0,0 +1,34 @@
# PromiseKit CloudKit Extensions ![Build Status]
This project adds promises to Apples CloudKit framework.
## CococaPods
```ruby
pod "PromiseKit/CloudKit" ~> 6.0
```
The extensions are built into `PromiseKit.framework` thus nothing else is needed.
## Carthage
```ruby
github "PromiseKit/CloudKit" ~> 3.0
```
The extensions are built into their own framework:
```swift
// swift
import PromiseKit
import PMKFoundation
```
```objc
// objc
@import PromiseKit;
@import PMKCloudKit;
```
[Build Status]: https://travis-ci.org/PromiseKit/CloudKit.svg?branch=master

View File

@@ -0,0 +1,79 @@
#import <CloudKit/CKContainer.h>
#import <PromiseKit/AnyPromise.h>
/**
To import the `CKContainer` category:
use_frameworks!
pod "PromiseKit/CloudKit"
And then in your sources:
@import PromiseKit;
*/
@interface CKContainer (PromiseKit)
/**
Reports whether the current users iCloud account can be accessed.
@return A promise that thens the `CKAccountStatus` of this container.
*/
- (AnyPromise *)accountStatus NS_REFINED_FOR_SWIFT;
/**
Requests the specified permission from the user asynchronously.
@param applicationPermission The requested permission.
@return A promise that thens the `CKApplicationPermissionStatus` for the
requested permission.
*/
- (AnyPromise *)requestApplicationPermission:(CKApplicationPermissions)applicationPermission NS_REFINED_FOR_SWIFT;
/**
Checks the status of the specified permission asynchronously.
@param applicationPermission The permission whose status you want to
check.
@return A promise that thens the `CKApplicationPermissionStatus` for
the requested permission.
*/
- (AnyPromise *)statusForApplicationPermission:(CKApplicationPermissions)applicationPermission NS_REFINED_FOR_SWIFT;
#if !(TARGET_OS_TV && (TARGET_OS_EMBEDDED || TARGET_OS_SIMULATOR))
/**
Retrieves information about all discoverable users that are known to the
current user.
@return A promise that thens the array of `CKDiscoveredUserInfo` objects.
*/
#if TARGET_OS_WATCH
- (AnyPromise *)discoverAllIdentities NS_REFINED_FOR_SWIFT;
#else
- (AnyPromise *)discoverAllContactUserInfos NS_REFINED_FOR_SWIFT;
#endif
#endif
/**
Retrieves information about a single user based on that users email
address or record ID.
@param emailStringOrRecordID Either the email string or the `CKRecordID`
for the user record.
@return A promise that thens the `CKDiscoveredUserInfo` for the
requested user record.
*/
- (AnyPromise *)discoverUserInfo:(id)emailStringOrRecordID NS_REFINED_FOR_SWIFT;
/**
Returns the user record associated with the current user.
@return A promise that thens the `CKRecord` for the current user or `nil`
if there is no current user.
*/
- (AnyPromise *)fetchUserRecordID NS_REFINED_FOR_SWIFT;
@end

View File

@@ -0,0 +1,71 @@
#import <CloudKit/CKRecordID.h>
#import "CKContainer+AnyPromise.h"
@implementation CKContainer (PromiseKit)
- (AnyPromise *)accountStatus {
return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) {
[self accountStatusWithCompletionHandler:^(CKAccountStatus accountStatus, NSError *error) {
resolve(error ?: @(accountStatus));
}];
}];
}
- (AnyPromise *)requestApplicationPermission:(CKApplicationPermissions)permissions {
return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) {
[self requestApplicationPermission:permissions completionHandler:^(CKApplicationPermissionStatus status, NSError *error) {
resolve(error ?: @(status));
}];
}];
}
- (AnyPromise *)statusForApplicationPermission:(CKApplicationPermissions)applicationPermission {
return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) {
[self statusForApplicationPermission:applicationPermission completionHandler:^(CKApplicationPermissionStatus status, NSError *error) {
resolve(error ?: @(status));
}];
}];
}
#if !(TARGET_OS_TV && (TARGET_OS_EMBEDDED || TARGET_OS_SIMULATOR))
#if TARGET_OS_WATCH
- (AnyPromise *)discoverAllIdentities {
return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) {
[self discoverAllIdentitiesWithCompletionHandler:^(NSArray *userInfos, NSError *error) {
resolve(error ?: userInfos);
}];
}];
}
#else
- (AnyPromise *)discoverAllContactUserInfos {
return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) {
[self discoverAllIdentitiesWithCompletionHandler:^(NSArray *userInfos, NSError *error) {
resolve(error ?: userInfos);
}];
}];
}
#endif
#endif
- (AnyPromise *)discoverUserInfo:(id)input {
return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) {
void (^adapter)(id, id) = ^(id value, id error){
resolve(error ?: error);
};
if ([input isKindOfClass:[CKRecordID class]]) {
[self discoverUserIdentityWithUserRecordID:input completionHandler:adapter];
} else {
[self discoverUserIdentityWithEmailAddress:input completionHandler:adapter];
}
}];
}
- (AnyPromise *)fetchUserRecordID {
return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) {
[self fetchUserRecordIDWithCompletionHandler:^(CKRecordID *recordID, NSError *error) {
resolve(error ?: recordID);
}];
}];
}
@end

View File

@@ -0,0 +1,79 @@
import CloudKit
#if !PMKCocoaPods
import PromiseKit
#endif
#if swift(>=4.2)
#else
public extension CKRecord {
typealias ID = CKRecordID
}
public typealias CKContainer_Application_Permissions = CKApplicationPermissions
public typealias CKContainer_Application_PermissionStatus = CKApplicationPermissionStatus
#endif
/**
To import the `CKContainer` category:
use_frameworks!
pod "PromiseKit/CloudKit"
And then in your sources:
@import PromiseKit;
*/
extension CKContainer {
/// Reports whether the current users iCloud account can be accessed.
public func accountStatus() -> Promise<CKAccountStatus> {
return Promise { accountStatus(completionHandler: $0.resolve) }
}
/// Requests the specified permission from the user asynchronously.
public func requestApplicationPermission(_ applicationPermissions: CKContainer_Application_Permissions) -> Promise<CKContainer_Application_PermissionStatus> {
return Promise { requestApplicationPermission(applicationPermissions, completionHandler: $0.resolve) }
}
/// Checks the status of the specified permission asynchronously.
public func status(forApplicationPermission applicationPermissions: CKContainer_Application_Permissions) -> Promise<CKContainer_Application_PermissionStatus> {
return Promise { status(forApplicationPermission: applicationPermissions, completionHandler: $0.resolve) }
}
#if !os(tvOS)
/// Retrieves information about all discoverable users that are known to the current user.
@available(*, deprecated)
public func discoverAllContactUserInfos() -> Promise<[CKUserIdentity]> {
return Promise { discoverAllIdentities(completionHandler: $0.resolve) }
}
public func discoverAllIdentities() -> Promise<[CKUserIdentity]> {
return Promise { discoverAllIdentities(completionHandler: $0.resolve) }
}
#endif
/// Retrieves information about a single user based on that users email address.
@available(*, deprecated)
public func discoverUserInfo(withEmailAddress email: String) -> Promise<CKUserIdentity> {
return Promise { discoverUserIdentity(withEmailAddress: email, completionHandler: $0.resolve) }
}
/// Retrieves information about a single user based on that users email address.
public func discoverUserIdentity(withEmailAddress email: String) -> Promise<CKUserIdentity> {
return Promise { discoverUserIdentity(withEmailAddress: email, completionHandler: $0.resolve) }
}
/// Retrieves information about a single user based on the ID of the corresponding user record.
@available(*, deprecated)
public func discoverUserInfo(withUserRecordID recordID: CKRecord.ID) -> Promise<CKUserIdentity> {
return Promise { discoverUserIdentity(withUserRecordID: recordID, completionHandler: $0.resolve) }
}
/// Retrieves information about a single user based on the ID of the corresponding user record.
public func discoverUserIdentity(withUserRecordID recordID: CKRecord.ID) -> Promise<CKUserIdentity> {
return Promise { discoverUserIdentity(withUserRecordID: recordID, completionHandler: $0.resolve) }
}
/// Returns the user record ID associated with the current user.
public func fetchUserRecordID() -> Promise<CKRecord.ID> {
return Promise { fetchUserRecordID(completionHandler: $0.resolve) }
}
}

View File

@@ -0,0 +1,46 @@
#import <CloudKit/CKDatabase.h>
#import <PromiseKit/AnyPromise.h>
/**
To import the `CKDatabase` category:
use_frameworks!
pod "PromiseKit/CloudKit"
And then in your sources:
@import PromiseKit;
*/
@interface CKDatabase (PromiseKit)
/// Fetches one record asynchronously from the current database.
- (AnyPromise *)fetchRecordWithID:(CKRecordID *)recordID NS_REFINED_FOR_SWIFT;
/// Saves one record zone asynchronously to the current database.
- (AnyPromise *)saveRecord:(CKRecord *)record NS_REFINED_FOR_SWIFT;
/// Delete one subscription object asynchronously from the current database.
- (AnyPromise *)deleteRecordWithID:(CKRecordID *)recordID NS_REFINED_FOR_SWIFT;
/// Searches the specified zone asynchronously for records that match the query parameters.
- (AnyPromise *)performQuery:(CKQuery *)query inZoneWithID:(CKRecordZoneID *)zoneID NS_REFINED_FOR_SWIFT;
/// Fetches all record zones asynchronously from the current database.
- (AnyPromise *)fetchAllRecordZones NS_REFINED_FOR_SWIFT;
/// Fetches one record asynchronously from the current database.
- (AnyPromise *)fetchRecordZoneWithID:(CKRecordZoneID *)zoneID NS_REFINED_FOR_SWIFT;
/// Saves one record zone asynchronously to the current database.
- (AnyPromise *)saveRecordZone:(CKRecordZone *)zone NS_REFINED_FOR_SWIFT;
/// Delete one subscription object asynchronously from the current database.
- (AnyPromise *)deleteRecordZoneWithID:(CKRecordZoneID *)zoneID NS_REFINED_FOR_SWIFT;
#if !(TARGET_OS_WATCH && (TARGET_OS_EMBEDDED || TARGET_OS_SIMULATOR))
/// Fetches one record asynchronously from the current database.
- (AnyPromise *)fetchSubscriptionWithID:(NSString *)subscriptionID NS_REFINED_FOR_SWIFT;
/// Fetches all subscription objects asynchronously from the current database.
- (AnyPromise *)fetchAllSubscriptions NS_REFINED_FOR_SWIFT;
/// Saves one subscription object asynchronously to the current database.
- (AnyPromise *)saveSubscription:(CKSubscription *)subscription NS_REFINED_FOR_SWIFT;
/// Delete one subscription object asynchronously from the current database.
- (AnyPromise *)deleteSubscriptionWithID:(NSString *)subscriptionID NS_REFINED_FOR_SWIFT;
#endif
@end

View File

@@ -0,0 +1,41 @@
#import "CKDatabase+AnyPromise.h"
@implementation CKDatabase (PromiseKit)
#define mkmethod1(method) \
- (AnyPromise *)method { \
return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) { \
[self method ## WithCompletionHandler:^(id a, id b){ \
resolve(b ?: a); \
}]; \
}]; \
}
#define mkmethod2(method) \
- (AnyPromise *)method { \
return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) { \
[self method completionHandler:^(id a, id b){ \
resolve(b ?: a); \
}]; \
}]; \
}
mkmethod2(fetchRecordWithID:(CKRecordID *)recordID);
mkmethod2(saveRecord:(CKRecord *)record);
mkmethod2(deleteRecordWithID:(CKRecordID *)recordID);
mkmethod2(performQuery:(CKQuery *)query inZoneWithID:(CKRecordZoneID *)zoneID);
mkmethod1(fetchAllRecordZones);
mkmethod2(fetchRecordZoneWithID:(CKRecordZoneID *)zoneID);
mkmethod2(saveRecordZone:(CKRecordZone *)zone);
mkmethod2(deleteRecordZoneWithID:(CKRecordZoneID *)zoneID);
#if !(TARGET_OS_WATCH && (TARGET_OS_EMBEDDED || TARGET_OS_SIMULATOR))
mkmethod2(fetchSubscriptionWithID:(NSString *)subscriptionID);
mkmethod1(fetchAllSubscriptions);
mkmethod2(saveSubscription:(CKSubscription *)subscription);
mkmethod2(deleteSubscriptionWithID:(NSString *)subscriptionID);
#endif
@end

View File

@@ -0,0 +1,91 @@
import CloudKit.CKDatabase
#if !PMKCocoaPods
import PromiseKit
#endif
#if swift(>=4.2)
#else
public extension CKRecordZone {
typealias ID = CKRecordZoneID
}
#endif
/**
To import the `CKDatabase` category:
use_frameworks!
pod "PromiseKit/CloudKit"
And then in your sources:
@import PromiseKit;
*/
extension CKDatabase {
/// Fetches one record asynchronously from the current database.
public func fetch(withRecordID recordID: CKRecord.ID) -> Promise<CKRecord> {
return Promise { fetch(withRecordID: recordID, completionHandler: $0.resolve) }
}
/// Fetches one record zone asynchronously from the current database.
public func fetch(withRecordZoneID recordZoneID: CKRecordZone.ID) -> Promise<CKRecordZone> {
return Promise { fetch(withRecordZoneID: recordZoneID, completionHandler: $0.resolve) }
}
/// Fetches all record zones asynchronously from the current database.
public func fetchAllRecordZones() -> Promise<[CKRecordZone]> {
return Promise { fetchAllRecordZones(completionHandler: $0.resolve) }
}
/// Saves one record zone asynchronously to the current database.
public func save(_ record: CKRecord) -> Promise<CKRecord> {
return Promise { save(record, completionHandler: $0.resolve) }
}
/// Saves one record zone asynchronously to the current database.
public func save(_ recordZone: CKRecordZone) -> Promise<CKRecordZone> {
return Promise { save(recordZone, completionHandler: $0.resolve) }
}
/// Delete one subscription object asynchronously from the current database.
public func delete(withRecordID recordID: CKRecord.ID) -> Promise<CKRecord.ID> {
return Promise { delete(withRecordID: recordID, completionHandler: $0.resolve) }
}
/// Delete one subscription object asynchronously from the current database.
public func delete(withRecordZoneID zoneID: CKRecordZone.ID) -> Promise<CKRecordZone.ID> {
return Promise { delete(withRecordZoneID: zoneID, completionHandler: $0.resolve) }
}
/// Searches the specified zone asynchronously for records that match the query parameters.
public func perform(_ query: CKQuery, inZoneWith zoneID: CKRecordZone.ID? = nil) -> Promise<[CKRecord]> {
return Promise { perform(query, inZoneWith: zoneID, completionHandler: $0.resolve) }
}
/// Fetches the record for the current user.
public func fetchUserRecord(_ container: CKContainer = CKContainer.default()) -> Promise<CKRecord> {
return container.fetchUserRecordID().then(on: nil) { uid in
return self.fetch(withRecordID: uid)
}
}
#if !os(watchOS)
/// Fetches one record zone asynchronously from the current database.
public func fetch(withSubscriptionID subscriptionID: String) -> Promise<CKSubscription> {
return Promise { fetch(withSubscriptionID: subscriptionID, completionHandler: $0.resolve) }
}
/// Fetches all subscription objects asynchronously from the current database.
public func fetchAllSubscriptions() -> Promise<[CKSubscription]> {
return Promise { fetchAllSubscriptions(completionHandler: $0.resolve) }
}
/// Saves one subscription object asynchronously to the current database.
public func save(_ subscription: CKSubscription) -> Promise<CKSubscription> {
return Promise { save(subscription, completionHandler: $0.resolve) }
}
/// Delete one subscription object asynchronously from the current database.
public func delete(withSubscriptionID subscriptionID: String) -> Promise<String> {
return Promise { delete(withSubscriptionID: subscriptionID, completionHandler: $0.resolve) }
}
#endif
}

View File

@@ -0,0 +1,2 @@
#import "CKContainer+AnyPromise.h"
#import "CKDatabase+AnyPromise.h"

View File

@@ -0,0 +1,146 @@
import PMKCloudKit
import XCTest
//TODO possibly we should interpret eg. request permission result of Denied as error
// PMK should only resolve with values that allow a typical chain to proceed
class Test_CKContainer_Swift: XCTestCase {
func test_accountStatus() {
class MockContainer: CKContainer {
init(_: Bool = false)
{}
override func accountStatus(completionHandler: @escaping (CKAccountStatus, Error?) -> Void) {
completionHandler(.couldNotDetermine, nil)
}
}
let ex = expectation(description: "")
MockContainer().accountStatus().done { status in
XCTAssertEqual(status, CKAccountStatus.couldNotDetermine)
ex.fulfill()
}
waitForExpectations(timeout: 1)
}
func test_requestApplicationPermission() {
class MockContainer: CKContainer {
init(_: Bool = false)
{}
override func requestApplicationPermission(_ applicationPermission: CKApplicationPermissions, completionHandler: @escaping CKApplicationPermissionBlock) {
completionHandler(.granted, nil)
}
}
let ex = expectation(description: "")
let pp = CKApplicationPermissions.userDiscoverability
MockContainer().requestApplicationPermission(pp).done { perms in
XCTAssertEqual(perms, CKApplicationPermissionStatus.granted)
ex.fulfill()
}
waitForExpectations(timeout: 1)
}
func test_statusForApplicationPermission() {
class MockContainer: CKContainer {
init(_: Bool = false)
{}
override func status(forApplicationPermission applicationPermission: CKApplicationPermissions, completionHandler: @escaping CKApplicationPermissionBlock) {
completionHandler(.granted, nil)
}
}
let ex = expectation(description: "")
let pp = CKApplicationPermissions.userDiscoverability
MockContainer().status(forApplicationPermission: pp).done {
XCTAssertEqual($0, CKApplicationPermissionStatus.granted)
ex.fulfill()
}
waitForExpectations(timeout: 1)
}
#if !os(tvOS)
func test_discoverAllContactUserInfos() {
class MockContainer: CKContainer {
init(_: Bool = false)
{}
override func discoverAllIdentities(completionHandler: @escaping ([CKUserIdentity]?, Error?) -> Void) {
completionHandler([PMKDiscoveredUserInfo()], nil)
}
}
let ex = expectation(description: "")
MockContainer().discoverAllIdentities().done {
XCTAssertEqual($0, [PMKDiscoveredUserInfo()])
ex.fulfill()
}
waitForExpectations(timeout: 1)
}
#endif
func test_discoverUserInfoWithEmailAddress() {
class MockContainer: CKContainer {
init(_: Bool = false)
{}
override func discoverUserIdentity(withEmailAddress email: String, completionHandler: @escaping (CKUserIdentity?, Error?) -> Void) {
completionHandler(PMKDiscoveredUserInfo(), nil)
}
}
let ex = expectation(description: "")
MockContainer().discoverUserIdentity(withEmailAddress: "mxcl@me.com").done {
XCTAssertEqual($0, PMKDiscoveredUserInfo())
ex.fulfill()
}
waitForExpectations(timeout: 1, handler: nil)
}
func test_discoverUserInfoWithRecordID() {
class MockContainer: CKContainer {
init(_: Bool = false)
{}
override func discoverUserIdentity(withUserRecordID userRecordID: CKRecord.ID, completionHandler: @escaping (CKUserIdentity?, Error?) -> Void) {
completionHandler(PMKDiscoveredUserInfo(), nil)
}
}
let ex = expectation(description: "")
MockContainer().discoverUserIdentity(withUserRecordID: dummy()).done {
XCTAssertEqual($0, PMKDiscoveredUserInfo())
ex.fulfill()
}
waitForExpectations(timeout: 1)
}
func test_fetchUserRecordID() {
class MockContainer: CKContainer {
init(_: Bool = false)
{}
override func fetchUserRecordID(completionHandler: @escaping (CKRecordID?, Error?) -> Void) {
completionHandler(dummy(), nil)
}
}
let ex = expectation(description: "")
MockContainer().fetchUserRecordID().done {
XCTAssertEqual($0, dummy())
ex.fulfill()
}
waitForExpectations(timeout: 1)
}
}
/////////////////////////////////////////////////////////////// resources
private func dummy() -> CKRecordID {
return CKRecordID(recordName: "foo")
}

View File

@@ -0,0 +1,2 @@
@class CKUserIdentity;
extern CKUserIdentity *PMKDiscoveredUserInfo();

View File

@@ -0,0 +1,5 @@
@import CloudKit;
CKUserIdentity *PMKDiscoveredUserInfo() {
return [CKUserIdentity alloc];
}