Make carthage portable

Mar 23, 2019 • 预计阅读时间 1 分钟

I wanna run carthage without install CarthageKit.framework to system library.

Download latest release

get latest carthage pkg form https://github.com/Carthage/Carthage/releases

Extract pkg file

pkgutil --expand-full Carthage.pkg Carthage

Copy to system path

cp Carthage/CarthageApp.pkg/Payload/usr/local/bin/carthage /usr/local/bin
mkdir -p /usr/local/Library/Frameworks
cp -r Carthage/CarthageApp.pkg/Payload/Library/Frameworks/CarthageKit.framework /usr/local/Library/Frameworks

Add rpath for carthage

install_name_tool -add_rpath @executable_path/../Library/Frameworks /usr/local/bin/carthage
install_name_tool -add_rpath @executable_path/../Library/Frameworks/CarthageKit.framework/Versions/Current/Frameworks /usr/local/bin/carthage

All done.

I using a shell script make it easy

#!/bin/bash

set -e

if [ ! -f Carthage.pkg ]; then
  echo Carthage.pkg not found.
  exit -1
fi

if [ -d Carthage ]; then
  echo found Carthage, removed
  rm -rf Carthage
fi

pkgutil --expand-full Carthage.pkg Carthage

mkdir -p Carthage_portable/bin
mkdir -p Carthage_portable/Library/Frameworks
cp Carthage/CarthageApp.pkg/Payload/usr/local/bin/carthage Carthage_portable/bin
cp -r Carthage/CarthageApp.pkg/Payload/Library/Frameworks/CarthageKit.framework Carthage_portable/Library/Frameworks

rm -rf Carthage

install_name_tool -add_rpath @executable_path/../Library/Frameworks Carthage_portable/bin/carthage
install_name_tool -add_rpath @executable_path/../Library/Frameworks/CarthageKit.framework/Versions/Current/Frameworks Carthage_portable/bin/carthage

echo Make Carthage portable at Carthage_portable
echo Testing Carthage_portable/bin/carthage version
Carthage_portable/bin/carthage version

GNU auto tools

fatal: cannot run gpg: No such file or directory

comments powered by Disqus