diff --git a/DoThis/DoThis.h b/DoThis-iOS/DoThis-iOS.h similarity index 100% rename from DoThis/DoThis.h rename to DoThis-iOS/DoThis-iOS.h diff --git a/DoThis/Info.plist b/DoThis-iOS/Info.plist similarity index 100% rename from DoThis/Info.plist rename to DoThis-iOS/Info.plist diff --git a/DoThis-macOS/DoThis-macOS.h b/DoThis-macOS/DoThis-macOS.h new file mode 100644 index 0000000..6441035 --- /dev/null +++ b/DoThis-macOS/DoThis-macOS.h @@ -0,0 +1,19 @@ +// +// DoThis-macOS.h +// DoThis-macOS +// +// Created by Thomas Bonk on 22.04.17. +// Copyright © 2017 Barak Harel. All rights reserved. +// + +#import + +//! Project version number for DoThis-macOS. +FOUNDATION_EXPORT double DoThis_macOSVersionNumber; + +//! Project version string for DoThis-macOS. +FOUNDATION_EXPORT const unsigned char DoThis_macOSVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + diff --git a/DoThis-macOS/Info.plist b/DoThis-macOS/Info.plist new file mode 100644 index 0000000..709efcb --- /dev/null +++ b/DoThis-macOS/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 0.1.1 + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSHumanReadableCopyright + Copyright © 2017 Barak Harel. All rights reserved. + NSPrincipalClass + + + diff --git a/DoThis.xcodeproj/project.pbxproj b/DoThis.xcodeproj/project.pbxproj index 8addc91..9494dd4 100644 --- a/DoThis.xcodeproj/project.pbxproj +++ b/DoThis.xcodeproj/project.pbxproj @@ -9,8 +9,10 @@ /* Begin PBXBuildFile section */ E58A01B81DF6025500BDF0DB /* DoThis.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E58A01AE1DF6025500BDF0DB /* DoThis.framework */; }; E58A01BD1DF6025500BDF0DB /* DoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E58A01BC1DF6025500BDF0DB /* DoTests.swift */; }; - E58A01BF1DF6025500BDF0DB /* DoThis.h in Headers */ = {isa = PBXBuildFile; fileRef = E58A01B11DF6025500BDF0DB /* DoThis.h */; settings = {ATTRIBUTES = (Public, ); }; }; - E58A01C91DF6027000BDF0DB /* DoThis.swift in Sources */ = {isa = PBXBuildFile; fileRef = E58A01C81DF6027000BDF0DB /* DoThis.swift */; }; + E971A2341EABB6CA00E1F77C /* DoThis-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = E971A2321EABB6CA00E1F77C /* DoThis-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; }; + E971A2381EABB6D900E1F77C /* DoThis.swift in Sources */ = {isa = PBXBuildFile; fileRef = E971A2371EABB6D900E1F77C /* DoThis.swift */; }; + E971A2421EABB70200E1F77C /* DoThis-macOS.h in Headers */ = {isa = PBXBuildFile; fileRef = E971A2401EABB70200E1F77C /* DoThis-macOS.h */; settings = {ATTRIBUTES = (Public, ); }; }; + E971A2461EABB73F00E1F77C /* DoThis.swift in Sources */ = {isa = PBXBuildFile; fileRef = E971A2371EABB6D900E1F77C /* DoThis.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -27,12 +29,15 @@ E56C564C1DFA23D500507133 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; E56C564D1DFA23D500507133 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; E58A01AE1DF6025500BDF0DB /* DoThis.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DoThis.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - E58A01B11DF6025500BDF0DB /* DoThis.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DoThis.h; sourceTree = ""; }; - E58A01B21DF6025500BDF0DB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; E58A01B71DF6025500BDF0DB /* DoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; E58A01BC1DF6025500BDF0DB /* DoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DoTests.swift; sourceTree = ""; }; E58A01BE1DF6025500BDF0DB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - E58A01C81DF6027000BDF0DB /* DoThis.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoThis.swift; sourceTree = ""; }; + E971A2321EABB6CA00E1F77C /* DoThis-iOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DoThis-iOS.h"; sourceTree = ""; }; + E971A2331EABB6CA00E1F77C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + E971A2371EABB6D900E1F77C /* DoThis.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoThis.swift; sourceTree = ""; }; + E971A23E1EABB70200E1F77C /* DoThis.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DoThis.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + E971A2401EABB70200E1F77C /* DoThis-macOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DoThis-macOS.h"; sourceTree = ""; }; + E971A2411EABB70200E1F77C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -51,16 +56,25 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + E971A23A1EABB70200E1F77C /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ E58A01A41DF6025500BDF0DB = { isa = PBXGroup; children = ( - E58A01B01DF6025500BDF0DB /* DoThis */, + E971A2361EABB6D900E1F77C /* Source */, + E971A2311EABB6CA00E1F77C /* DoThis-iOS */, E58A01BB1DF6025500BDF0DB /* DoTests */, E56C564C1DFA23D500507133 /* LICENSE */, E56C564D1DFA23D500507133 /* README.md */, + E971A23F1EABB70200E1F77C /* DoThis-macOS */, E58A01AF1DF6025500BDF0DB /* Products */, ); sourceTree = ""; @@ -70,27 +84,44 @@ children = ( E58A01AE1DF6025500BDF0DB /* DoThis.framework */, E58A01B71DF6025500BDF0DB /* DoTests.xctest */, + E971A23E1EABB70200E1F77C /* DoThis.framework */, ); name = Products; sourceTree = ""; }; - E58A01B01DF6025500BDF0DB /* DoThis */ = { + E58A01BB1DF6025500BDF0DB /* DoTests */ = { isa = PBXGroup; children = ( - E58A01B11DF6025500BDF0DB /* DoThis.h */, - E58A01B21DF6025500BDF0DB /* Info.plist */, - E58A01C81DF6027000BDF0DB /* DoThis.swift */, + E58A01BC1DF6025500BDF0DB /* DoTests.swift */, + E58A01BE1DF6025500BDF0DB /* Info.plist */, ); - path = DoThis; + path = DoTests; sourceTree = ""; }; - E58A01BB1DF6025500BDF0DB /* DoTests */ = { + E971A2311EABB6CA00E1F77C /* DoThis-iOS */ = { isa = PBXGroup; children = ( - E58A01BC1DF6025500BDF0DB /* DoTests.swift */, - E58A01BE1DF6025500BDF0DB /* Info.plist */, + E971A2321EABB6CA00E1F77C /* DoThis-iOS.h */, + E971A2331EABB6CA00E1F77C /* Info.plist */, ); - path = DoTests; + path = "DoThis-iOS"; + sourceTree = ""; + }; + E971A2361EABB6D900E1F77C /* Source */ = { + isa = PBXGroup; + children = ( + E971A2371EABB6D900E1F77C /* DoThis.swift */, + ); + path = Source; + sourceTree = ""; + }; + E971A23F1EABB70200E1F77C /* DoThis-macOS */ = { + isa = PBXGroup; + children = ( + E971A2401EABB70200E1F77C /* DoThis-macOS.h */, + E971A2411EABB70200E1F77C /* Info.plist */, + ); + path = "DoThis-macOS"; sourceTree = ""; }; /* End PBXGroup section */ @@ -100,16 +131,24 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - E58A01BF1DF6025500BDF0DB /* DoThis.h in Headers */, + E971A2341EABB6CA00E1F77C /* DoThis-iOS.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E971A23B1EABB70200E1F77C /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + E971A2421EABB70200E1F77C /* DoThis-macOS.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ - E58A01AD1DF6025500BDF0DB /* DoThis */ = { + E58A01AD1DF6025500BDF0DB /* DoThis-iOS */ = { isa = PBXNativeTarget; - buildConfigurationList = E58A01C21DF6025500BDF0DB /* Build configuration list for PBXNativeTarget "DoThis" */; + buildConfigurationList = E58A01C21DF6025500BDF0DB /* Build configuration list for PBXNativeTarget "DoThis-iOS" */; buildPhases = ( E58A01A91DF6025500BDF0DB /* Sources */, E58A01AA1DF6025500BDF0DB /* Frameworks */, @@ -120,7 +159,7 @@ ); dependencies = ( ); - name = DoThis; + name = "DoThis-iOS"; productName = Do; productReference = E58A01AE1DF6025500BDF0DB /* DoThis.framework */; productType = "com.apple.product-type.framework"; @@ -143,6 +182,24 @@ productReference = E58A01B71DF6025500BDF0DB /* DoTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; + E971A23D1EABB70200E1F77C /* DoThis-macOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = E971A2431EABB70200E1F77C /* Build configuration list for PBXNativeTarget "DoThis-macOS" */; + buildPhases = ( + E971A2391EABB70200E1F77C /* Sources */, + E971A23A1EABB70200E1F77C /* Frameworks */, + E971A23B1EABB70200E1F77C /* Headers */, + E971A23C1EABB70200E1F77C /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "DoThis-macOS"; + productName = "DoThis-macOS"; + productReference = E971A23E1EABB70200E1F77C /* DoThis.framework */; + productType = "com.apple.product-type.framework"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -150,7 +207,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0810; - LastUpgradeCheck = 0810; + LastUpgradeCheck = 0830; ORGANIZATIONNAME = "Barak Harel"; TargetAttributes = { E58A01AD1DF6025500BDF0DB = { @@ -164,6 +221,10 @@ DevelopmentTeam = T9FT44P7KA; ProvisioningStyle = Automatic; }; + E971A23D1EABB70200E1F77C = { + CreatedOnToolsVersion = 8.3.1; + ProvisioningStyle = Automatic; + }; }; }; buildConfigurationList = E58A01A81DF6025500BDF0DB /* Build configuration list for PBXProject "DoThis" */; @@ -178,7 +239,8 @@ projectDirPath = ""; projectRoot = ""; targets = ( - E58A01AD1DF6025500BDF0DB /* DoThis */, + E58A01AD1DF6025500BDF0DB /* DoThis-iOS */, + E971A23D1EABB70200E1F77C /* DoThis-macOS */, E58A01B61DF6025500BDF0DB /* DoTests */, ); }; @@ -199,6 +261,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + E971A23C1EABB70200E1F77C /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -206,7 +275,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - E58A01C91DF6027000BDF0DB /* DoThis.swift in Sources */, + E971A2381EABB6D900E1F77C /* DoThis.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -218,12 +287,20 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + E971A2391EABB70200E1F77C /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E971A2461EABB73F00E1F77C /* DoThis.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ E58A01BA1DF6025500BDF0DB /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = E58A01AD1DF6025500BDF0DB /* DoThis */; + target = E58A01AD1DF6025500BDF0DB /* DoThis-iOS */; targetProxy = E58A01B91DF6025500BDF0DB /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ @@ -247,6 +324,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -300,6 +378,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -338,11 +417,11 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = DoThis/Info.plist; + INFOPLIST_FILE = "$(SRCROOT)/DoThis-iOS/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.barakharel.do.this; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = DoThis; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 3.0; @@ -359,11 +438,11 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = DoThis/Info.plist; + INFOPLIST_FILE = "$(SRCROOT)/DoThis-iOS/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.barakharel.do.this; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = DoThis; SKIP_INSTALL = YES; SWIFT_VERSION = 3.0; }; @@ -395,6 +474,52 @@ }; name = Release; }; + E971A2441EABB70200E1F77C /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_VERSION = A; + INFOPLIST_FILE = "DoThis-macOS/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.12; + PRODUCT_BUNDLE_IDENTIFIER = com.barakharel.do.this; + PRODUCT_NAME = DoThis; + SDKROOT = macosx; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + E971A2451EABB70200E1F77C /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_VERSION = A; + INFOPLIST_FILE = "DoThis-macOS/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.12; + PRODUCT_BUNDLE_IDENTIFIER = com.barakharel.do.this; + PRODUCT_NAME = DoThis; + SDKROOT = macosx; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -407,7 +532,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - E58A01C21DF6025500BDF0DB /* Build configuration list for PBXNativeTarget "DoThis" */ = { + E58A01C21DF6025500BDF0DB /* Build configuration list for PBXNativeTarget "DoThis-iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( E58A01C31DF6025500BDF0DB /* Debug */, @@ -425,6 +550,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + E971A2431EABB70200E1F77C /* Build configuration list for PBXNativeTarget "DoThis-macOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E971A2441EABB70200E1F77C /* Debug */, + E971A2451EABB70200E1F77C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = E58A01A51DF6025500BDF0DB /* Project object */; diff --git a/DoThis.xcodeproj/project.xcworkspace/xcuserdata/thomas.xcuserdatad/UserInterfaceState.xcuserstate b/DoThis.xcodeproj/project.xcworkspace/xcuserdata/thomas.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..12185f9 Binary files /dev/null and b/DoThis.xcodeproj/project.xcworkspace/xcuserdata/thomas.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/DoThis.xcodeproj/xcshareddata/xcschemes/DoThis.xcscheme b/DoThis.xcodeproj/xcshareddata/xcschemes/DoThis-iOS.xcscheme similarity index 94% rename from DoThis.xcodeproj/xcshareddata/xcschemes/DoThis.xcscheme rename to DoThis.xcodeproj/xcshareddata/xcschemes/DoThis-iOS.xcscheme index 14a9c78..d508f82 100644 --- a/DoThis.xcodeproj/xcshareddata/xcschemes/DoThis.xcscheme +++ b/DoThis.xcodeproj/xcshareddata/xcschemes/DoThis-iOS.xcscheme @@ -1,6 +1,6 @@ @@ -44,7 +44,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "E58A01AD1DF6025500BDF0DB" BuildableName = "DoThis.framework" - BlueprintName = "DoThis" + BlueprintName = "DoThis-iOS" ReferencedContainer = "container:DoThis.xcodeproj"> @@ -66,7 +66,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "E58A01AD1DF6025500BDF0DB" BuildableName = "DoThis.framework" - BlueprintName = "DoThis" + BlueprintName = "DoThis-iOS" ReferencedContainer = "container:DoThis.xcodeproj"> @@ -84,7 +84,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "E58A01AD1DF6025500BDF0DB" BuildableName = "DoThis.framework" - BlueprintName = "DoThis" + BlueprintName = "DoThis-iOS" ReferencedContainer = "container:DoThis.xcodeproj"> diff --git a/DoThis.xcodeproj/xcshareddata/xcschemes/DoThis-macOS.xcscheme b/DoThis.xcodeproj/xcshareddata/xcschemes/DoThis-macOS.xcscheme new file mode 100644 index 0000000..f280cf2 --- /dev/null +++ b/DoThis.xcodeproj/xcshareddata/xcschemes/DoThis-macOS.xcscheme @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DoThis.xcodeproj/xcuserdata/thomas.xcuserdatad/xcschemes/xcschememanagement.plist b/DoThis.xcodeproj/xcuserdata/thomas.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..cea32a8 --- /dev/null +++ b/DoThis.xcodeproj/xcuserdata/thomas.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,37 @@ + + + + + SchemeUserState + + DoThis-iOS.xcscheme_^#shared#^_ + + orderHint + 0 + + DoThis-macOS.xcscheme_^#shared#^_ + + orderHint + 1 + + + SuppressBuildableAutocreation + + E58A01AD1DF6025500BDF0DB + + primary + + + E58A01B61DF6025500BDF0DB + + primary + + + E971A23D1EABB70200E1F77C + + primary + + + + + diff --git a/DoThis/DoThis.swift b/Source/DoThis.swift similarity index 67% rename from DoThis/DoThis.swift rename to Source/DoThis.swift index b8491aa..83a8d53 100644 --- a/DoThis/DoThis.swift +++ b/Source/DoThis.swift @@ -43,16 +43,18 @@ public class DoThis { public fileprivate(set) var error: Error? public fileprivate(set) var previousResult: Any? + fileprivate var checkStop: Bool = false fileprivate var next: DoThis? fileprivate var catchThis: ThisClosure? fileprivate var finallyThis: ThisClosure? - fileprivate init(name: String?, on queue: DispatchQueue, after delay: TimeInterval, index: Int, do this: @escaping ThisClosure) { + fileprivate init(name: String?, on queue: DispatchQueue, checkStop: Bool = false, after delay: TimeInterval, index: Int, do this: @escaping ThisClosure) { self.name = name self.index = index self.onQueue = queue self.delay = delay + self.checkStop = checkStop self.doThis = this } @@ -62,7 +64,7 @@ public class DoThis { /// - Parameters: /// - error: error if any, will continue to the catch and finally closures /// - result: result (optional) passed to the next then or finally closures - public func done(result: Any? = nil, error: Error? = nil) { + public func done(result: Any? = nil, finished: Bool = false, error: Error? = nil) { //if error if let error = error { @@ -76,15 +78,20 @@ public class DoThis { else if let next = self.next { if next.delay > 0 { - next.onQueue.asyncAfter(deadline: .now() + next.delay, execute: { - next.previousResult = result - next.doThis(next) - }) + if !next.checkStop || !finished { + next.onQueue.asyncAfter(deadline: .now() + next.delay, execute: { + next.previousResult = result + next.doThis(next) + }) + } } else { - next.onQueue.async { - next.previousResult = result - next.doThis(next) + if !next.checkStop || !finished { + next.onQueue.async { + next.previousResult = result + next.doThis(next) + + } } } } @@ -96,13 +103,24 @@ public class DoThis { public func then(name: String? = nil, on queue: DispatchQueue? = nil, after delay: TimeInterval = 0, do this: @escaping ThisClosure) -> DoThis { + return createNext(name: name, on: queue, after: delay, do: this) + } + + @discardableResult + public func orThis(name: String? = nil, on queue: DispatchQueue? = nil, after delay: TimeInterval = 0, do this: @escaping ThisClosure) -> DoThis { + + return createNext(name: name, on: queue, checkStop: true, after: delay, do: this) + } + + private func createNext(name: String? = nil, on queue: DispatchQueue? = nil, checkStop: Bool = false, after delay: TimeInterval = 0, do this: @escaping ThisClosure) -> DoThis { + guard self.catchThis == nil else { fatalError("Can't call next() after catch()") } let queue = queue ?? self.onQueue - let next = DoThis(name: name, on: queue, after: delay, index: self.index + 1, do: this) + let next = DoThis(name: name, on: queue, checkStop: checkStop, after: delay, index: self.index + 1, do: this) self.next = next return next