【Xcode】UserInterfaceState.xcuserstateってなに?コミットしていいの?

Xcode

Xcodeでアプリ開発をするときにGit等でソース管理している方が多いと思いますが、身に覚えのない変更がUserInterfaceState.xcuserstateにかかっていることはありませんか?

今回はそのUserInterfaceState.xcuserstateについて説明していきます。

UserInterfaceState.xcuserstateとは?

Xcodeのプロジェクトを作ると自動で作成されるファイルです。Xcode内のどのファイルを開いて、どこにカーソルを当てている状態かを記録するためのファイルのようで、プロジェクト内をクリックするだけでも更新がかかり、頻繁にコミット対象となってしまいます。

コミット/プッシュしていいの?

結論、コミットしなくていいです。というか、複数人で開発をしていると思わぬ競合の元になるので、コミットしないようにしたほうがいいです。

UserInterfaceState.xcuserstateを無視する方法

.gitignoreファイルに記載する

もしプロジェクトを作ったばかりで、まだコミットもしていないのであれば、.gitignoreファイルにUserInterfaceState.xcuserstateと記載するだけです。

UserInterfaceState.xcuserstate
キャッシュを消す

もしも既にコミットしてしまっていたら、UserInterfaceState.xcuserstateのキャッシュを消す必要があります。

$ git rm --cached  自分のプロジェクト名.xcodeproj/xcuserdata/自分のアカウント名.xcuserdatad/UserInterfaceState.xcuserstate
$ git commit -m "UserInterfaceState.xcuserstateのキャッシュを消す"

コメント

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny

タイトルとURLをコピーしました