Adding Images and Other Files to the App

In the previous section, you saw how the Bundle class lets you read values from the app’s Info.plist. Actually, it offers much more than that. You can use the Xcode project to include any kind of file inside your app bundle, then find and read it at runtime.

Finding Arbitrary Files in the App Bundle

For example, let’s say you add a new file to a project, using the Property List template. In the File Inspector () on the right, under “Target Membership”, the check box for the app target will be checked, meaning this file will automatically be copied into the app at runtime. The following figure shows the plist’s target membership:

The way you find it is with the Bundle class. The app itself is the “main” ...

Get Xcode Treasures now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.