summerlabs / punic

Punic is a remote cache CLI built for Carthage and Apple .xcframework
https://andrewaquino118.medium.com/remote-caching-apples-xcframework-2fcf574392c5
28 stars 2 forks source link
amazon apple aws aws-s3 cache caching carthage cli cloud homebrew infra infrastructure ios punic remote rome s3 tooling xcframework

Punic

elephant

Punic is a remote caching CLI built for Carthage that exclusively supports Apple's .xcframeworks.

Features

Please give us a ⭐️ if you find this CLI useful!

Example Usage

elephant

Installation

brew tap summerlabs/homebrew-punic
brew install punic

AWS Credentials

Make sure you have your AWS config and credentials setup.

They are keys that Punic uses to upload your frameworks into AWS and will be automatically setup for you when you run aws configure.

Here is an example after you run the setup successfully.

~/.aws/config

[default]
region = us-west-1
output = json

~/.aws/credentials

[default]
aws_access_key_id = {SOME_ACCESS_KEY_ID}
aws_secret_access_key = {SOME_SECRET_KEY}

Documentation

Punfile

Punic looks for a Punfile in your top-level project to determine which dependencies to download as well as configuring the path of your local cache.

Example Punfile

# Configure Punic
configuration:
  # save dependencies into this AWS bucket directory
  #
  # ie. //some-remote-bucket/1.0.1/Alamofire/Alamofire.xcframework
  #
  # defaults to `output`
  #
  prefix: 1.0.1
  # local cache location
  local: ~/Library/Caches/Punic
  # output cache location
  output: Carthage/Build
  # aws bucket location
  s3Bucket: some-remote-bucket

# Search your output directory for these .xcframeworks
dependencies:
# single framework definition
- AlamoFire:
  - name: AlamoFire
  # support for explicit versioning
    version: 0.1.9
# multiple frameworks definition sometimes created by one library
- CocoaLumberjack:  
  # having no version defaults to a versionless dependency cache
  - name: CocoaLumberjack
  - name: CocoaLumberjackSwift
  - name: CocoaAsyncSocket
    version: {COCOA_VERSION}

we also support basic templating with environment variables the best way to do this is create a .env file and source it before running punfile

Commands

After building your .xcframeworks using

carthage update --use-xcframeworks

They will be located in the top level Carthage/Build directory.

Download .xcframeworks

punic download

Upload .xcframeworks

punic upload

Miscellaneous

# The `output cache` is the Carthage/Build folder

# ignore the local cache and zip directly from the output cache 
punic upload --ignore-local

# ignore the local cache and download anyway then copy
punic download --ignore-local

# ignore the output cache and copy anyway
punic download --ignore-output

# use an override cache prefix
punic {command} --cache-prefix {some_other_path_key}

# target specific dependencies
punic {command} --dependencies Alamofre,CocoaLumberjack

Carthage-less Support

Punic is capable of copying the downloaded/cached frameworks into a separate folder, you don't have to necessarily use Carthage/Build if you want to copy the files into a separate directory for your own reasons.

Feel free to change the output key in the Punfile to achieve this.

Developer Support

Punic is a new framework that was made to help our team achieve remote caching with Apple's latest .xcframework change. If you find any issues using the CLI, don't hesitate to open one up to help us bug splash.

For all you Rust developers, feel free to contribute to this framework and help us grow the CLI.