2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

TIL: Podfile.lockのSPEC CHECKSUMSに差分がでる

Posted at

概要

Flutterを使ったprojectで「Podfile.lockのCHECKSUMSに差分が出るんだけど」と言われた。
最初はキャッシュかな~~と思いながら対応するも一向に解決しない。チームメンバー全員が最新のcodeで pod install すると差分が出る。自分は出ない。

Podfile.lock とは

文字通りlock fileなので、package-lock.json のような認識で概ね問題ない。
Podfile に対しての lock fileである。
つまり、実際に入れた Pods(ライブリ) に関する情報がまとめられている。

SPEC CHECKSUMS とは

これなんぞや??
と思った人も多いと思います。自分も今回の件があるまではちゃんと調べてなかった。
同じような機構は他のpackage managerにもあるような気がする。多分。

SPEC CHECKSUMS が生成される仕組み

すごく雑な理解だと、

  • pod install を実行する
  • ios/Pods/Local Podspecs/<lib_name>.podspec.json をhashにして変更があれば書き換える

という理解。なので、
shasum ios/Pods/Local\ Podspecs/<lib_name>.podspec.json とすると SPEC CHECKSUMSに書かれている値と同じ値が出力されるはず。
(ちなみにですが sha256ではなく、sha1らしい。意外だ)

原因

半日ほど費やして cocoapods のcodeを覗いて理解しました。
https://github.com/CocoaPods/Core/blob/a53e235aa4d1eec8a21042e022ba7bcaca14ae56/lib/cocoapods-core/specification/json.rb#L11-L16

      # @return [String] the pretty json representation of the specification.
      #
      def to_pretty_json(*a)
        require 'json'
        JSON.pretty_generate(to_hash, *a) << "\n"
      end

gem json を使ってるわけですね。でこのjsonのversionはlocal環境に左右されます。
チームメイトと自身のversionを確認したところversionに差分があり、updateすることで解決しました。

余談

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?