davedelong / time

Robust and type-safe date and time calculations for Swift
MIT License
2.31k stars 77 forks source link

Carthage supports #9

Open shoheiyokoyama opened 6 years ago

shoheiyokoyama commented 6 years ago

Hi

Thanks for this great library.

The Chronology release version is not available now. I installed with master branch by using Carthage, but it is useful to release the current version. Thanks.

elitalon commented 4 years ago

There is ongoing work (Carthage/Carthage#1945) to support this from Carthage's side, but it seems to be a tricky problem to solve.

In the meantime we could attach pre-built frameworks to releases, which Carthage can pick up instead of building the library from scratch. Some automation would be needed for that, though.

elitalon commented 4 years ago

This script shows how we could build a universal framework for iOS:

#!/usr/bin/env bash

set -o nounset
set -o errexit

readonly FRAMEWORK=Time
readonly BUILD=build
readonly FRAMEWORK_PATH=${FRAMEWORK}.framework

function prepare_environment {
    swift package generate-xcodeproj

    rm -rf ${BUILD}
    rm -f ${FRAMEWORK}-iOS.framework.tar.gz

    xcodebuild clean
}

function archive_platform_frameworks {
    xcodebuild archive -sdk iphoneos SYMROOT=${BUILD}
    xcodebuild build -sdk iphonesimulator SYMROOT=${BUILD}

    cp -RL ${BUILD}/Release-iphoneos ${BUILD}/Release-universal
    cp -RL ${BUILD}/Release-iphonesimulator/${FRAMEWORK_PATH}/Modules/${FRAMEWORK}.swiftmodule/* \
        ${BUILD}/Release-universal/${FRAMEWORK_PATH}/Modules/${FRAMEWORK}.swiftmodule
}

function generate_universal_framework {
    lipo -create \
        ${BUILD}/Release-iphoneos/${FRAMEWORK_PATH}/${FRAMEWORK} \
        ${BUILD}/Release-iphonesimulator/${FRAMEWORK_PATH}/${FRAMEWORK} \
        -output ${BUILD}/Release-universal/${FRAMEWORK_PATH}/${FRAMEWORK}
}

function package_framework_and_dsym {
    tar -czv -C ${BUILD}/Release-universal -f ${FRAMEWORK}-iOS.tar.gz \
        ${FRAMEWORK_PATH} ${FRAMEWORK_PATH}.dSYM
}

function main {
    prepare_environment
    archive_platform_frameworks
    generate_universal_framework
    package_framework_and_dsym
}

main

I attached the resulting framework to the 0.9.0 release of my fork and tested using an example iOS project.

@davedelong Do you think it's worth continuing in this direction?

davedelong commented 4 years ago

This would be a great addition! If you could get this to work via Github Actions (perhaps with this? https://github.com/actions/create-release) I'll merge it in.