explaingit

mxcl/promisekit

14,243SwiftAudience · developerComplexity · 2/5Setup · easy

TLDR

PromiseKit is a Swift and Objective-C library that replaces messy nested callbacks with readable promise chains for background tasks like network requests and location lookups on Apple platforms.

Mindmap

mindmap
  root((repo))
    What it does
      Async code chains
      Replaces callbacks
      Promise placeholders
    Platforms
      iOS and macOS
      tvOS and watchOS
      Linux
    Apple API wrappers
      URLSession
      CoreLocation
      MapKit
    Installation
      CocoaPods
      Carthage
      Swift Package Manager
    Audience
      iOS developers
      macOS developers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Replace deeply nested callback handlers in an iOS app with a clean readable chain of async steps.

USE CASE 2

Chain a location lookup, image download, and UI update in sequence without nesting completion handlers.

USE CASE 3

Add promise-based wrappers around Apple APIs like URLSession and CoreLocation in an existing Swift project.

Tech stack

SwiftObjective-C

Getting it running

Difficulty · easy Time to first run · 30min

In plain English

PromiseKit is a Swift and Objective-C library that makes it easier to write code that runs tasks in the background, like fetching data from the internet or asking for a user's location. Normally, this kind of code requires writing functions inside functions inside functions, which quickly becomes difficult to read and maintain. PromiseKit offers a cleaner approach: you describe each step in a chain, and the library takes care of running them in order, passing results from one step to the next. The idea behind a "promise" is simple: it is a placeholder for a value that will arrive later. When you fetch an image from a URL, for example, the network call returns a promise. You can then describe what to do when the image arrives, what to do when everything is finished regardless of success or failure, and what to do if something goes wrong. This reads more like a list of instructions than a tangle of nested callbacks. PromiseKit works on iOS, macOS, tvOS, watchOS, and Linux. It includes ready-made promise wrappers for many of Apple's own APIs, so instead of writing the usual callback boilerplate for a network request or a location lookup, you get a single promise back. Optional extensions cover areas like MapKit, CoreLocation, and URLSession. You can install it with CocoaPods, Carthage, or Swift Package Manager. The library has been available for many years and appears in many widely used apps. The README notes that as of Swift 5.5, Apple added its own built-in system for background tasks called async/await, and it points toward a separate project called Async+ for developers who want a similar style using that newer approach. PromiseKit itself continues to be maintained for codebases that have not yet moved to async/await.

Copy-paste prompts

Prompt 1
I'm fetching user data from an API in my iOS app and the callback nesting is getting messy. Rewrite this using PromiseKit promise chains with proper error handling.
Prompt 2
Show me how to use PromiseKit to request location permission and then fetch the user's current coordinates, handling both success and error cases.
Prompt 3
I need to chain three async operations in Swift using PromiseKit: authenticate, fetch data, then save to Core Data. Show me the full chain.
Prompt 4
My app uses PromiseKit but I want to migrate to Swift async/await. What is the recommended migration path and what is the Async+ project?
Open on GitHub → Explain another repo

← mxcl on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.