From b0d8784d77c5457d5e53ec0c444367e5c3b45b0b Mon Sep 17 00:00:00 2001 From: brennanMKE Date: Wed, 15 Feb 2017 08:56:59 -0800 Subject: [PATCH 1/5] adds support for CocoaPods and Swift PM --- .swift-version | 1 + Gemfile | 6 ++ Gemfile.lock | 90 +++++++++++++++++++++++ Package.swift | 5 ++ Promise.podspec | 17 +++++ Promise.xcodeproj/project.pbxproj | 20 ++--- Promise/Info.plist | 2 +- README.md | 48 ++++++++++-- {Promise => Sources}/Promise+Extras.swift | 0 {Promise => Sources}/Promise.swift | 0 10 files changed, 173 insertions(+), 16 deletions(-) create mode 100644 .swift-version create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 Package.swift create mode 100644 Promise.podspec rename {Promise => Sources}/Promise+Extras.swift (100%) rename {Promise => Sources}/Promise.swift (100%) diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..f398a20 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +3.0 \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..5c0b3e2 --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +gem 'cocoapods', '~> 1.2.0' +gem 'cocoapods-keys' +gem 'xcpretty' +gem 'xcodeproj' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..0cde9c1 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,90 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (2.3.5) + RubyInline (3.12.4) + ZenTest (~> 4.3) + ZenTest (4.11.1) + activesupport (4.2.7.1) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + claide (1.0.1) + cocoapods (1.2.0) + activesupport (>= 4.0.2, < 5) + claide (>= 1.0.1, < 2.0) + cocoapods-core (= 1.2.0) + cocoapods-deintegrate (>= 1.0.1, < 2.0) + cocoapods-downloader (>= 1.1.3, < 2.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-stats (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.1.2, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored (~> 1.2) + escape (~> 0.0.4) + fourflusher (~> 2.0.1) + gh_inspector (~> 1.0) + molinillo (~> 0.5.5) + nap (~> 1.0) + ruby-macho (~> 0.2.5) + xcodeproj (>= 1.4.1, < 2.0) + cocoapods-core (1.2.0) + activesupport (>= 4.0.2, < 5) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + cocoapods-deintegrate (1.0.1) + cocoapods-downloader (1.1.3) + cocoapods-keys (2.0.0) + dotenv + osx_keychain + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.0) + cocoapods-stats (1.0.0) + cocoapods-trunk (1.1.2) + nap (>= 0.8, < 2.0) + netrc (= 0.7.8) + cocoapods-try (1.1.0) + colored (1.2) + dotenv (2.2.0) + escape (0.0.4) + fourflusher (2.0.1) + fuzzy_match (2.0.4) + gh_inspector (1.0.3) + i18n (0.8.0) + json (1.8.6) + minitest (5.10.1) + molinillo (0.5.6) + nanaimo (0.2.3) + nap (1.1.0) + netrc (0.7.8) + osx_keychain (1.0.1) + RubyInline (~> 3) + rouge (1.11.1) + ruby-macho (0.2.6) + thread_safe (0.3.5) + tzinfo (1.2.2) + thread_safe (~> 0.1) + xcodeproj (1.4.2) + CFPropertyList (~> 2.3.3) + activesupport (>= 3) + claide (>= 1.0.1, < 2.0) + colored (~> 1.2) + nanaimo (~> 0.2.3) + xcpretty (0.2.4) + rouge (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + cocoapods (~> 1.2.0) + cocoapods-keys + xcodeproj + xcpretty + +BUNDLED WITH + 1.10.6 diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..95a44a1 --- /dev/null +++ b/Package.swift @@ -0,0 +1,5 @@ +import PackageDescription + +let package = Package( + name: "Promise" +) \ No newline at end of file diff --git a/Promise.podspec b/Promise.podspec new file mode 100644 index 0000000..aed557c --- /dev/null +++ b/Promise.podspec @@ -0,0 +1,17 @@ +Pod::Spec.new do |s| + s.name = "Promise" + s.version = "2.0.0" + s.summary = "A Promise library for Swift" + s.description = "A Promise library for Swift, based partially on Javascript's A+ spec" + s.module_name = "Promise" + s.homepage = "https://github.com/khanlou/Promise" + s.license = 'MIT' + s.author = { "Soroush Khanlou" => "soroush@khanlou.com" } + s.source = { :git => "https://github.com/khanlou/Promise.git", :tag => "2.0.0" } + s.social_media_url = 'https://twitter.com/khanlou' + s.source_files = 'Sources/*.swift' + s.cocoapods_version = '>= 1.0' + s.ios.deployment_target = '9.0' + s.osx.deployment_target = '10.11' + s.frameworks = 'Foundation' +end \ No newline at end of file diff --git a/Promise.xcodeproj/project.pbxproj b/Promise.xcodeproj/project.pbxproj index d2bfe3a..af5fe30 100644 --- a/Promise.xcodeproj/project.pbxproj +++ b/Promise.xcodeproj/project.pbxproj @@ -14,15 +14,15 @@ 1A2A8CFC1D5D743100421E3E /* PromiseRecoverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A8CFB1D5D743100421E3E /* PromiseRecoverTests.swift */; }; 1A2A8CFE1D5D764600421E3E /* PromiseRetryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A8CFD1D5D764600421E3E /* PromiseRetryTests.swift */; }; 1A7CC22F1DF4D37400929E7C /* PromiseEnsureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A7CC22E1DF4D37400929E7C /* PromiseEnsureTests.swift */; }; - 1AE9F56F1D526F8A00185453 /* Promise+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AE9F56E1D526F8A00185453 /* Promise+Extras.swift */; }; 1AF54F3B1D67D60000557CCB /* PromiseZipTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AF54F3A1D67D60000557CCB /* PromiseZipTests.swift */; }; 1AFA1FA01D8A0C9500E4F76E /* PromiseThrowsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AFA1F9F1D8A0C9500E4F76E /* PromiseThrowsTests.swift */; }; 1AFF80FA1D5166C000C55D5A /* delay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AFF80F91D5166C000C55D5A /* delay.swift */; }; 1AFF80FC1D51676700C55D5A /* PromiseAllTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AFF80FB1D51676700C55D5A /* PromiseAllTests.swift */; }; + 2648083B1E54221900F01140 /* Promise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 264808391E54221900F01140 /* Promise.swift */; }; + 2648083C1E54221900F01140 /* Promise+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2648083A1E54221900F01140 /* Promise+Extras.swift */; }; 3454F9D21D4FACD000985BBF /* Promise.h in Headers */ = {isa = PBXBuildFile; fileRef = 3454F9D11D4FACD000985BBF /* Promise.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3454F9D91D4FACD000985BBF /* Promise.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3454F9CE1D4FACD000985BBF /* Promise.framework */; }; 3454F9DE1D4FACD000985BBF /* PromiseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3454F9DD1D4FACD000985BBF /* PromiseTests.swift */; }; - 3454F9E91D4FACFB00985BBF /* Promise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3454F9E81D4FACFB00985BBF /* Promise.swift */; }; 72B61D3C1E00E5830008E829 /* Wrench.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72B61D3B1E00E5830008E829 /* Wrench.swift */; }; /* End PBXBuildFile section */ @@ -44,18 +44,18 @@ 1A2A8CFB1D5D743100421E3E /* PromiseRecoverTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromiseRecoverTests.swift; sourceTree = ""; }; 1A2A8CFD1D5D764600421E3E /* PromiseRetryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromiseRetryTests.swift; sourceTree = ""; }; 1A7CC22E1DF4D37400929E7C /* PromiseEnsureTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromiseEnsureTests.swift; sourceTree = ""; }; - 1AE9F56E1D526F8A00185453 /* Promise+Extras.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Promise+Extras.swift"; sourceTree = ""; }; 1AF54F3A1D67D60000557CCB /* PromiseZipTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromiseZipTests.swift; sourceTree = ""; }; 1AFA1F9F1D8A0C9500E4F76E /* PromiseThrowsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromiseThrowsTests.swift; sourceTree = ""; }; 1AFF80F91D5166C000C55D5A /* delay.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = delay.swift; sourceTree = ""; }; 1AFF80FB1D51676700C55D5A /* PromiseAllTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromiseAllTests.swift; sourceTree = ""; }; + 264808391E54221900F01140 /* Promise.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Promise.swift; path = Sources/Promise.swift; sourceTree = SOURCE_ROOT; }; + 2648083A1E54221900F01140 /* Promise+Extras.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Promise+Extras.swift"; path = "Sources/Promise+Extras.swift"; sourceTree = SOURCE_ROOT; }; 3454F9CE1D4FACD000985BBF /* Promise.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Promise.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 3454F9D11D4FACD000985BBF /* Promise.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Promise.h; sourceTree = ""; }; 3454F9D31D4FACD000985BBF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 3454F9D81D4FACD000985BBF /* PromiseTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PromiseTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3454F9DD1D4FACD000985BBF /* PromiseTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromiseTests.swift; sourceTree = ""; }; 3454F9DF1D4FACD000985BBF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 3454F9E81D4FACFB00985BBF /* Promise.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Promise.swift; sourceTree = ""; }; 72B61D3B1E00E5830008E829 /* Wrench.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Wrench.swift; sourceTree = ""; }; 76E25E381D8483D0000A58DF /* Promise.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Promise.playground; sourceTree = ""; }; /* End PBXFileReference section */ @@ -101,9 +101,9 @@ 3454F9D01D4FACD000985BBF /* Promise */ = { isa = PBXGroup; children = ( + 264808391E54221900F01140 /* Promise.swift */, + 2648083A1E54221900F01140 /* Promise+Extras.swift */, 3454F9D11D4FACD000985BBF /* Promise.h */, - 3454F9E81D4FACFB00985BBF /* Promise.swift */, - 1AE9F56E1D526F8A00185453 /* Promise+Extras.swift */, 3454F9D31D4FACD000985BBF /* Info.plist */, ); path = Promise; @@ -191,7 +191,7 @@ TargetAttributes = { 3454F9CD1D4FACD000985BBF = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0820; }; 3454F9D71D4FACD000985BBF = { CreatedOnToolsVersion = 7.3.1; @@ -239,8 +239,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 1AE9F56F1D526F8A00185453 /* Promise+Extras.swift in Sources */, - 3454F9E91D4FACFB00985BBF /* Promise.swift in Sources */, + 2648083C1E54221900F01140 /* Promise+Extras.swift in Sources */, + 2648083B1E54221900F01140 /* Promise.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -411,6 +411,7 @@ 3454F9E61D4FACD000985BBF /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; INFOPLIST_FILE = PromiseTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.khanlou.PromiseTests; @@ -422,6 +423,7 @@ 3454F9E71D4FACD000985BBF /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; INFOPLIST_FILE = PromiseTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.khanlou.PromiseTests; diff --git a/Promise/Info.plist b/Promise/Info.plist index d3de8ee..7e7479f 100644 --- a/Promise/Info.plist +++ b/Promise/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 2.0.0 CFBundleSignature ???? CFBundleVersion diff --git a/README.md b/README.md index 00741ab..b382bac 100644 --- a/README.md +++ b/README.md @@ -18,16 +18,52 @@ Using a special type to represent values that will exist in the future means tha Promises are suited for any asynchronous action that can succeed or fail exactly once, such as HTTP requests. If there is an asynchronous action that can "succeed" more than once, or delivers a series of values over time instead of just one, take a look at [Signals](https://github.com/JensRavens/Interstellar/) or [Observables](https://github.com/ReactiveX/RxSwift). -## Basic Usage +## Installation -To access the value once it arrives, you call the `then` method with a block. +### [CocoaPods](http://cocoapods.org/) + +1. Add the following to your [Podfile](http://guides.cocoapods.org/using/the-podfile.html): + + ```rb + pod 'Promise' + ``` + +2. Integrate your dependencies using frameworks: add `use_frameworks!` to your Podfile. +3. Run `pod install`. + +### [Carthage](https://github.com/Carthage/Carthage) + +1. Add the following to your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile): + + ``` + github "khanlou/Promise" + ``` + +2. Run `carthage update` and follow the steps as described in Carthage's [README](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application). + +### [Swift Package Manager](https://swift.org/package-manager/) + +The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. It is in early development, but Promise does support its use on supported platforms. + +Once you have your Swift package set up, adding AlamPromiseofire as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. ```swift -let usersPromise = fetchUsers() // Promise<[User]> -usersPromise.then({ users in - self.users = users -}) +dependencies: [ + .Package(url: "https://github.com/khanlou/Promise.git", majorVersion: 2) +] ``` + +## Basic Usage + +To access the value once it arrives, you call the `then` method with a block. + + ```swift + let usersPromise = fetchUsers() // Promise<[User]> + usersPromise.then({ users in + self.users = users + }) + ``` + All usage of the data in the `users` Promise is gated through the `then` method. In addition to performing side effects (like setting the `users` instance variable on `self`), `then` enables you do two other things. First, you can transform the contents of the Promise, and second, you can kick off another Promise, to do more asynchronous work. To do either of these things, return something from the block you pass to `then`. Each time you call `then`, the existing Promise will return a new Promise. diff --git a/Promise/Promise+Extras.swift b/Sources/Promise+Extras.swift similarity index 100% rename from Promise/Promise+Extras.swift rename to Sources/Promise+Extras.swift diff --git a/Promise/Promise.swift b/Sources/Promise.swift similarity index 100% rename from Promise/Promise.swift rename to Sources/Promise.swift From f645c792e492e8de5677fd56a9d2ad385abefdec Mon Sep 17 00:00:00 2001 From: Joe Fabisevich Date: Sat, 30 Sep 2017 15:24:17 -0400 Subject: [PATCH 2/5] Bumping .swift-version to 4.0 --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index f398a20..389f774 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.0 \ No newline at end of file +4.0 \ No newline at end of file From 41099f504e01d7da23d64fd3d26f7f75471bc245 Mon Sep 17 00:00:00 2001 From: Joe Fabisevich Date: Sat, 30 Sep 2017 15:24:47 -0400 Subject: [PATCH 3/5] Updating podspec tag and name --- Package.swift | 4 ++-- Promise.podspec => Promises.podspec | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename Promise.podspec => Promises.podspec (90%) diff --git a/Package.swift b/Package.swift index 95a44a1..bd7c96e 100644 --- a/Package.swift +++ b/Package.swift @@ -1,5 +1,5 @@ import PackageDescription let package = Package( - name: "Promise" -) \ No newline at end of file + name: "Promises" +) diff --git a/Promise.podspec b/Promises.podspec similarity index 90% rename from Promise.podspec rename to Promises.podspec index aed557c..8450e9b 100644 --- a/Promise.podspec +++ b/Promises.podspec @@ -1,13 +1,13 @@ Pod::Spec.new do |s| s.name = "Promise" - s.version = "2.0.0" + s.version = "v2.0" s.summary = "A Promise library for Swift" s.description = "A Promise library for Swift, based partially on Javascript's A+ spec" s.module_name = "Promise" s.homepage = "https://github.com/khanlou/Promise" s.license = 'MIT' s.author = { "Soroush Khanlou" => "soroush@khanlou.com" } - s.source = { :git => "https://github.com/khanlou/Promise.git", :tag => "2.0.0" } + s.source = { :git => "https://github.com/khanlou/Promise.git", :tag => "#{spec.version}" } s.social_media_url = 'https://twitter.com/khanlou' s.source_files = 'Sources/*.swift' s.cocoapods_version = '>= 1.0' From 0822a8ac2027b8807393d53bb80ecba5cd62a908 Mon Sep 17 00:00:00 2001 From: Joe Fabisevich Date: Sat, 30 Sep 2017 15:25:31 -0400 Subject: [PATCH 4/5] Updating xcodeproj to Swift 4.0 --- Promise.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Promise.xcodeproj/project.pbxproj b/Promise.xcodeproj/project.pbxproj index af5fe30..55ce880 100644 --- a/Promise.xcodeproj/project.pbxproj +++ b/Promise.xcodeproj/project.pbxproj @@ -385,7 +385,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -404,7 +404,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; From e1bee354304e9c9fab0e0ade69ec3fb0eca7cf82 Mon Sep 17 00:00:00 2001 From: Joe Fabisevich Date: Sat, 30 Sep 2017 15:25:42 -0400 Subject: [PATCH 5/5] Moving installation instructions to the bottom of the README --- README.md | 70 +++++++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index b382bac..f9eaee1 100644 --- a/README.md +++ b/README.md @@ -18,41 +18,6 @@ Using a special type to represent values that will exist in the future means tha Promises are suited for any asynchronous action that can succeed or fail exactly once, such as HTTP requests. If there is an asynchronous action that can "succeed" more than once, or delivers a series of values over time instead of just one, take a look at [Signals](https://github.com/JensRavens/Interstellar/) or [Observables](https://github.com/ReactiveX/RxSwift). -## Installation - -### [CocoaPods](http://cocoapods.org/) - -1. Add the following to your [Podfile](http://guides.cocoapods.org/using/the-podfile.html): - - ```rb - pod 'Promise' - ``` - -2. Integrate your dependencies using frameworks: add `use_frameworks!` to your Podfile. -3. Run `pod install`. - -### [Carthage](https://github.com/Carthage/Carthage) - -1. Add the following to your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile): - - ``` - github "khanlou/Promise" - ``` - -2. Run `carthage update` and follow the steps as described in Carthage's [README](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application). - -### [Swift Package Manager](https://swift.org/package-manager/) - -The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. It is in early development, but Promise does support its use on supported platforms. - -Once you have your Swift package set up, adding AlamPromiseofire as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. - -```swift -dependencies: [ - .Package(url: "https://github.com/khanlou/Promise.git", majorVersion: 2) -] -``` - ## Basic Usage To access the value once it arrives, you call the `then` method with a block. @@ -323,6 +288,41 @@ Promise(work: { fulfill, reject in }) ``` +## Installation + +### [CocoaPods](http://cocoapods.org/) + +1. Add the following to your [Podfile](http://guides.cocoapods.org/using/the-podfile.html): + + ```rb + pod 'Promise' + ``` + +2. Integrate your dependencies using frameworks: add `use_frameworks!` to your Podfile. +3. Run `pod install`. + +### [Carthage](https://github.com/Carthage/Carthage) + +1. Add the following to your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile): + + ``` + github "khanlou/Promise" + ``` + +2. Run `carthage update` and follow the steps as described in Carthage's [README](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application). + +### [Swift Package Manager](https://swift.org/package-manager/) + +The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. It is in early development, but Promise does support its use on supported platforms. + +Once you have your Swift package set up, adding AlamPromiseofire as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. + +```swift +dependencies: [ + .Package(url: "https://github.com/khanlou/Promise.git", majorVersion: 2) +] +``` + ## Playing Around To get started playing with this library, you can use the included `Promise.playground`. Simply open the `.xcodeproj`, build the scheme, and then open the playground (from within the project) and start playing.