Bundleはリソースとコードを隠蔽したもの
from iOS開発わからないことリスト
Bundle | Apple Developer Documentation
Bundles are a fundamental technology in macOS and iOS that are used to encapsulate code and resources.
https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/Introduction/Introduction.html#//apple_ref/doc/uid/10000123i
packageと混同されることがあるが、意味が違う
A package is any directory that the Finder presents to the user as if it were a single file.
A bundle is a directory with a standardized hierarchical structure that holds executable code and the resources used by that code.
A representation of the code and resources stored in a bundle directory on disk.
Apple uses bundles to represent apps, frameworks, plug-ins, and many other specific types of content. Bundles organize their contained resources into well-defined subdirectories, and bundle structures vary depending on the platform and the type of the bundle.
https://developer.apple.com/documentation/foundation/bundle
バンドルの構造は隠蔽されている
構造がtarget platformによって異なる
自動的に検索してくれるようになっている
iSO/macOSのバンドル構造が知りたいなら Bundle Programming Guideを読む
Bundleは色々考慮した上でitmeにアクセスするインタフェースを提供
Bundle.mainはmainというバンドルの指定
現在実行中のコードを含むBundleのディレクトリを表す
つまり、Bundle.mainを使うとアプリに入れたリソースにアクセスできる
バンドルオブジェクトの検索
globalが優先されるので、localizeされたリソースとglobalのリソースの療法があるとlocalizeが無視される
バンドルの検索
https://developer.apple.com/documentation/foundation/bundle/1416712-url
Objective-C時代
NSBundle - iPhoneアプリ開発の虎の巻
NSBundleはアプリケーションのリソース(クラス、Xib、画像などのファイル)をまとめて管理してくれる仕組みを提供するクラスです。
NSBundleを使用することにより、ファイルのパスを指定したいような時でも、バンドルが教えてくれるのでファイル管理が大変便利に行えたりします。