Sketch.app のなかに install.sh というファイルがある時期があるんだけど、バージョン 48 から、そのファイルがなくなるようになりました。 2018/9/21 現在使ってる最新バージョン (51.3) にもそういうファイルはもう存在していない。
試したことと解決方法は下記のようになります。
手動でバイナリーファイルを移動してみる
cli ツールのローケーションはここに収納されています。
/Applications/Sketch.app/Contents/Resources/sketchtool/
.
├── README.txt
├── bin
│ ├── sketchmigrate
│ └── sketchtool
└── share
└── sketchtool
└── resources.bundle
次のコマンドでコピーするのができます:
cp bin/* /usr/local/bin/
cp share/* /usr/local/share
が、 sketchtool を実行してみると、こういう問題が出てきました:
dyld: Library not loaded: @rpath/BCFoundation.framework/Versions/A/BCFoundation
Referenced from: /usr/local/bin/sketchtool
Reason: image not found
Abort trap: 6
Sketch社の人によると:
Yes sorry about that. Since 48, we changed how we organize some stuff in our repo and the Libraries are now frameworks so when you install
sketchtool, the frameworks are missing because they are not copied.We are looking a nice solution but in the meantime, you can use
/Applications/Sketch.app/Contents/Resources/sketchtool/bin/sketchtooldirectly
(https://sketchplugins.com/d/502-dyld-library-not-loaded/4)
とにかく、今は直接そのバイナリーファイルを使ってくださいっていうことになりました。
バイナリーのローケーションを PATH に追加する
毎回フルパスを使ったらちょっとアレなんで、 PATH に追加して見みました。
cat << EOF >> ~/.zshrc
# Add Sketch related tools
export PATH="\$PATH:/Applications/Sketch.app/Contents/Resources/sketchtool/bin/sketchtool"
EOF
* zsh 使ってない人は ./zshrc を ./bash_profile とかに書き換えてください。
そして次のコメントを実行するとこの変更がすぐに反映してくれます。
source ~/.zshrc
下記のように、実行して、問題なければこういうようなバージョンのアウトプットがプリントアウトしてくれます。
$ sketchtool -v
sketchtool Version 51.3 (57544)
以上です!