こんにちは!UI デザインの松野です。
フェンリルのデザイナーはみんな思い思いのアプリケーションで作業します。私はというと、何にでも Adobe Illustrator を使います。理由は色々あるのですが、Illustrator はアートボードに別のファイルを配置できるのもその理由のひとつです。
Illustrator の配置は、ファイルを参照として扱います。これによって、
・リソース画像の共通部分を別ファイルに分けて使い回す
・アプリの画面サンプルに実際のリソース画像を入れて組み立てる
ということをしています。ファイルが別になっていれば、あとからの修正にも柔軟ですし、管理も楽になります。
しかも、実は Illustrator 書類に Illustrator 書類を配置することもできる(PDF 互換機能を応用)ので、Illustrator で作業を完結できます。
このアイコンの馬や地球は共通パーツにして、Mac 版でも iOS 版でも同じものを使っています。
で、これらの共通パーツは色んなプロジェクトで使うので、別のフォルダに分けているんですが、色々とつまずいたことがありました。
配置ファイルを動かさない
Illustrator を使ったことがある人なら大抵、リンク切れを体験していると思います。配置ファイルのリンクが切れないように気を使う必要があります。
Illustrator 書類と同じ階層に置いたときだけはリンク切れが起こらないため、そうしておくのが一般的ですが、別のフォルダに置くなら常に決まった場所にしなくてはなりません。まあ、場所が変わらなければ問題ないので運用でカバーします。しかし、今度はデータのバックアップ時にまた困りました。
共通パーツごとバックアップしたい
プロジェクトが終わったときなどにデータをバックアップしますよね。そうなると、配置しているファイルまでバックアップする必要があります。
共通パーツはたびたび更新されて、最新のものが反映されます。しかし、バックアップ時にはその時点での共通パーツを “使ったものだけ” 保存したいわけです。ところが、そもそも数ある共通パーツのどれを配置しているのかを把握するのも大変です。
そこでシンボリックリンク
色んな解決策を考えましたが、今はシンボリックリンクを使う方法に落ち着いています。
シンボリックリンクは「ファイルがあたかもその場所にあるかのように振る舞う」ファイルです。共通パーツはどこかにまとめておいて、使う分のシンボリックリンクだけ Illustrator 書類と同じ階層に入れておきます。そして、このシンボリックリンクから実体をコピーできるスクリプトを用意して、バックアップに使っています。
これで、共通パーツごとバックアップできるようになりました。どの共通パーツを使っているかの把握もできますし、もちろん配置ファイルを開くこともできます。
まず、Mac OS X にはシンボリックリンクをコマンドライン以外からつくる方法がなかったので、AppleScript を書きました。
on run
tell application "Finder"
set selectedItems to selection
if length of selectedItems is 0 then return
--
makeSymbolicLinks(selectedItems, path to the desktop) of me
--
end tell
end run
on makeSymbolicLinks(theseItems, targetFolder)
tell application "Finder"
set resultItems to {}
--
repeat with thisItem in theseItems
set thisName to name of (info for thisItem as alias)
set resultName to uniqueItemName(thisName, targetFolder, "-") of me
set thisPath to "\"" & (POSIX path of (thisItem as alias)) & "\""
set resultPath to "\"" & (POSIX path of (targetFolder)) & resultName & "\""
do shell script "ln -s " & thisPath & " " & resultPath
set the end of resultItems to alias file resultName of targetFolder
end repeat
--
return resultItems
end tell
end makeSymbolicLinks
on uniqueItemName(thisName, targetFolder, suffixDelimiter)
tell application "Finder"
if not (item thisName in targetFolder exists) then return thisName
set countNumber to 1
--
repeat until not (item (thisName & suffixDelimiter & countNumber as text) in targetFolder exists)
set countNumber to countNumber + 1
end repeat
set resultName to thisName & suffixDelimiter & countNumber as text
--
return resultName
end tell
end uniqueItemName
Finder で選択している項目のシンボリックリンクをデスクトップにつくります。これを Automator でサービスか何かにしておけば、コンテキストメニューからシンボリックリンクをつくれます。
また、バックアップ時には、シンボリックリンクをオリジナルのコピーと置き換える AppleScript を使っています。実は Finder はシンボリックリンクとエイリアスを区別しないので、エイリアスにも使えます。
on run
tell application "Finder"
set selectedItems to selection
if length of selectedItems is 0 then return
--
set selection to replaceWithOriginals(selectedItems) of me
--
end tell
end run
on replaceWithOriginals(theseItems)
tell application "Finder"
set parentFolder to parent of the first item of theseItems
set aliasItems to {}
set originalItems to {}
set resultItems to {}
--
repeat with thisItem in theseItems
if class of thisItem is alias file then
set the end of originalItems to original item of thisItem
set the end of aliasItems to thisItem
end if
end repeat
--
delete aliasItems
set resultItems to duplicate originalItems to parentFolder with replacing
--
return resultItems
end tell
end replaceWithOriginals
この記事の AppleScript はご自身の責任において、ご自由にお使いください。
自分用に書いたものなので最低限の動作しかしません。あしからずご了承ください。
最新の OS X Lion と Mac OS X Snow Leopard で動作確認しています。









