Bundle files in Xcode project

What is bundle?

A bundle is a directory in the file system that groups executable code and related resources such as images and sounds together in one place.In iOS and OS X, applications, frameworks, plug-ins, and other types of software are bundles. A bundle is a directory with a standardized hierarchical structure that holds executable code and resources used by that code. Foundation and Core Foundation include facilities for locating and loading code and resources in bundles.

How to create a bundle?

  1. Create a test.txt file and add the text “testing✌️” to it then put it in a folder named temp.bundle
  2. Drag and drop it next to your ".app" file in xcode (tick the copy if need checkbox)
  3. Test if it works: Swift.print(Bundle.main.resourcePath!+"/temp.bundle/test.txt")

Why use .bundle folders?

Dragging a folder with resources into xcode will also work but the content will not have hierarchical folder structure once you build. .bundle folders on the other hand will retain the hierarchical folder structure

Ref: