Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NSCacheMigration

NSCache の key として Swift の Hashable だけを実装した class を使った場合と、NSObject を継承して hash / isEqual(_:) を override した class を使った場合の挙動を比較する Swift Package です。

目的は、同じ値を持つ別インスタンスの wrapped key で NSCache.object(forKey:) が取得できるかを、Xcode 26 / Xcode 27 など複数 toolchain で確認することです。

実行

現在選択されている Xcode で実行します。

swift run NSCacheMigrationCompare

複数の Xcode を比較する場合は、.app のパスを渡します。

scripts/compare-xcodes.sh /Applications/Xcode-26.6.0.app /Applications/Xcode-27.0.0-beta.app

DEVELOPER_DIR を直接使っても確認できます。

DEVELOPER_DIR=/Applications/Xcode_27.app/Contents/Developer swift run NSCacheMigrationCompare

見るべき行

Hashable WrappedKey / equal distinct instance

この行が MISS になる環境では、Swift の Hashable 実装だけに依存した wrapped key では、同じ値を持つ別インスタンスから NSCache の値を取得できません。

移行後の期待値は次の行です。

NSObject WrappedKey / equal distinct instance

この行は HIT になる想定です。パッケージ内の Cache はこの実装に合わせて、WrappedKey: NSObject とし、hashisEqual(_:) を override しています。

テスト

swift test

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages