← Back to mxcl/PromiseKit

How to Deploy & Use mxcl/PromiseKit

PromiseKit Deployment and Usage Guide

Prerequisites

  • Swift 5.0+ (PromiseKit 8 requires recent Xcode versions, 13+)
  • macOS, iOS, tvOS, watchOS, or Linux (PromiseKit supports all these platforms)
  • Xcode (for iOS/macOS development) or Swift toolchain (for Linux)
  • CocoaPods (recommended for iOS/macOS) or Carthage/Accio/SwiftPM (alternatives)

Installation

Using CocoaPods (Recommended for iOS/macOS)

  1. Install CocoaPods if not already installed:

    sudo gem install cocoapods
    
  2. Create a Podfile in your project directory:

    use_frameworks!
    
    target "YourTargetName" do
      pod "PromiseKit", "~> 8"
    end
    
  3. Install the pod:

    pod install
    
  4. Open the generated .xcworkspace file in Xcode.

Using Carthage

  1. Create a Cartfile:

    github "mxcl/PromiseKit" ~> 8
    
  2. Install dependencies:

    carthage update --platform iOS
    
  3. Drag the built framework from Carthage/Build into your Xcode project.

Using Swift Package Manager

  1. Add to your Package.swift:

    dependencies: [
        .package(url: "https://github.com/mxcl/PromiseKit.git", from: "8.0.0")
    ]
    
  2. Add the package to your target dependencies.

Configuration

PromiseKit requires no special configuration files or API keys. However:

  • Optional Extensions: PromiseKit provides extensions for Apple's APIs. To use them, add the appropriate subspecs to your Podfile:

    pod "PromiseKit/MapKit"          # For MKDirections().calculate().then { /*…*/ }
    pod "PromiseKit/CoreLocation"    # For CLLocationManager.requestLocation().then { /*…*/ }
    
  • Foundation Extensions: The default CocoaPod includes extensions for Foundation and UIKit.

  • No Extensions: If you don't want any extensions:

    pod "PromiseKit/CorePromise", "~> 8"
    

Build & Run

iOS/macOS Development

  1. Open your project in Xcode:

    open YourProject.xcworkspace
    
  2. Build and run:

    • Press Cmd + R to run on a simulator or device
    • Press Cmd + B to build

Testing

PromiseKit includes comprehensive test suites. To run tests:

# For iOS/macOS
xcodebuild test -workspace YourProject.xcworkspace -scheme YourScheme -destination 'platform=iOS Simulator,name=iPhone 14'

# For Linux
swift test

Deployment

iOS/macOS Apps

  • App Store: Build your app normally and submit through Xcode's Organizer.
  • Enterprise Distribution: Use Xcode's archive and export features.
  • Ad Hoc: Use Xcode's archive and export features with ad hoc provisioning.

Swift Packages

  • Publish to Swift Package Index by hosting your package on GitHub.
  • Use SwiftPM for dependency management in other Swift projects.

Linux/Server-Side Swift

  • Deploy to any Linux server that supports Swift.
  • Use Docker containers for consistent deployment environments.

Troubleshooting

Common Issues

  1. "PromiseKit/CorePromise" not found

    • Ensure you've run pod install and opened the .xcworkspace file, not .xcodeproj.
    • Check your Podfile syntax.
  2. Swift version compatibility

    • PromiseKit 8 requires Xcode 13+. For older Xcode versions, use PromiseKit 6, 5, or 4.
    • Check the Installation Guide for version-specific instructions.
  3. Build errors with extensions

    • Some extensions may conflict with other libraries. Try using only PromiseKit/CorePromise if you encounter issues.
  4. Linux compilation issues

    • PromiseKit supports Linux, but some extensions may not be available. Check the CI Matrix for supported configurations.

Debugging

  • Use PromiseKit's built-in error handling with .catch { error in } blocks.
  • Check the Troubleshooting Guide for common compile errors and solutions.

Performance

  • PromiseKit is designed for performance. If you experience issues, check your promise chains for unnecessary nesting.
  • Use .ensure { } for cleanup code that should always execute.

Migration