Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds support for CocoaPods and Swift PM #12

Merged
merged 1 commit into from Sep 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .swift-version
@@ -0,0 +1 @@
3.0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be 3.1 now?

6 changes: 6 additions & 0 deletions Gemfile
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

gem 'cocoapods', '~> 1.2.0'
gem 'cocoapods-keys'
gem 'xcpretty'
gem 'xcodeproj'
90 changes: 90 additions & 0 deletions 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
5 changes: 5 additions & 0 deletions Package.swift
@@ -0,0 +1,5 @@
import PackageDescription

let package = Package(
name: "Promise"
)
17 changes: 17 additions & 0 deletions Promise.podspec
@@ -0,0 +1,17 @@
Pod::Spec.new do |s|
s.name = "Promise"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you change the to Promises?

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" }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you update the tag to v2.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
20 changes: 11 additions & 9 deletions Promise.xcodeproj/project.pbxproj
Expand Up @@ -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 */

Expand All @@ -44,18 +44,18 @@
1A2A8CFB1D5D743100421E3E /* PromiseRecoverTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromiseRecoverTests.swift; sourceTree = "<group>"; };
1A2A8CFD1D5D764600421E3E /* PromiseRetryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromiseRetryTests.swift; sourceTree = "<group>"; };
1A7CC22E1DF4D37400929E7C /* PromiseEnsureTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromiseEnsureTests.swift; sourceTree = "<group>"; };
1AE9F56E1D526F8A00185453 /* Promise+Extras.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Promise+Extras.swift"; sourceTree = "<group>"; };
1AF54F3A1D67D60000557CCB /* PromiseZipTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromiseZipTests.swift; sourceTree = "<group>"; };
1AFA1F9F1D8A0C9500E4F76E /* PromiseThrowsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromiseThrowsTests.swift; sourceTree = "<group>"; };
1AFF80F91D5166C000C55D5A /* delay.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = delay.swift; sourceTree = "<group>"; };
1AFF80FB1D51676700C55D5A /* PromiseAllTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PromiseAllTests.swift; sourceTree = "<group>"; };
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 = "<group>"; };
3454F9D31D4FACD000985BBF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
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 = "<group>"; };
3454F9DF1D4FACD000985BBF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3454F9E81D4FACFB00985BBF /* Promise.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Promise.swift; sourceTree = "<group>"; };
72B61D3B1E00E5830008E829 /* Wrench.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Wrench.swift; sourceTree = "<group>"; };
76E25E381D8483D0000A58DF /* Promise.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Promise.playground; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -191,7 +191,7 @@
TargetAttributes = {
3454F9CD1D4FACD000985BBF = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0820;
};
3454F9D71D4FACD000985BBF = {
CreatedOnToolsVersion = 7.3.1;
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Promise/Info.plist
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>2.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
48 changes: 42 additions & 6 deletions README.md
Expand Up @@ -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)
]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think installation instructions should go at the end of the README. ime people have more problems understanding how they work than how to install a cocoapod. can you please update the cocoapod name here as well?

```

## 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.
Expand Down
File renamed without changes.
File renamed without changes.