若き研究者の日常

技術寄りの事かポエムを書く。

SwiftでCommand CodeSign failed with a nonzero exit codeが出る原因と対処

Swiftのチュートリアルを行っていたのですが,以下のエラーメッセージがいつの間にか(厳密には画像をプロジェクトにインポートした際に)出てしまい,どのタイミングで何がトリガーになってこうなった?って結構混乱してました.

Resource fork, Finder information, or similar detritus not allowed
Command CodeSign failed with a nonzero exit code

謎のビルド失敗,なんかサインイン失敗してる?権限の問題のようにも見える,が,,,?

原因を調べてみると,以下のようなネットの記事が出てきます.

shunichiro.net

teratail.com

が,んー.宣言してない関数はなさそうだし,指定されたコマンドを打ってみても以下のような感じ.2020年からxattrコマンドの仕様が変わった?

xattr -cr /hogehoge/Landmarks.app
option -r not recognized

usage: xattr [-slz] file [file ...]
       xattr -p [-slz] attr_name file [file ...]
       xattr -w [-sz] attr_name attr_value file [file ...]
       xattr -d [-s] attr_name file [file ...]
       xattr -c [-s] file [file ...]

The first form lists the names of all xattrs on the given file(s).
The second form (-p) prints the value of the xattr attr_name.
The third form (-w) sets the value of the xattr attr_name to attr_value.
The fourth form (-d) deletes the xattr attr_name.
The fifth form (-c) deletes (clears) all xattrs.

options:
  -h: print this help
  -s: act on symbolic links themselves rather than their targets
  -l: print long format (attr_name: attr_value)
  -z: compress or decompress (if compressed) attribute value in zip format

最新の情報を探してみると以下の情報がヒット

forum.openframeworks.cc

どうやらiCloud同期の設定をしてるディレクトリで作業したらビルド失敗しちゃうっぽい?まあ確かに,iCloudの同期を設定してるところでgit操作してたら,なんか変な隠しファイルがトラックされちゃったりしてだるくなるのは経験してた.

詳しく読んでみるとどうやらやっぱiCloudの同期設定があるディレクトリで作業してるのが原因っぽい. github.com

同期設定されてないディレクトリで最初から作業し直したらこのエラーは出なくなった. 画像をインポートした際にこのエラーが出始めて,画像を消してみてもエラーが消えなかったので,画像の参照がどこかしらのファイルに記述されててそれが原因なのか?とか考えてしまっていた.どうやらインポートのタイミングでiCloudの同期が始まっちゃったのが原因っぽいね.

結論

iCloudの同期設定があるディレクトリではコーディングしない方がいい(Swiftでも何でも).