I'm using SwiftUI to create an IOS application. I have some binary files that I need to read from within the application. What is the best way to add these files to my application?
I can always convert them to constant binary arrays in a swift file, but that seems a bit silly to me. I'd much prefer to load the binary file from the bundle (bundle.main.path()) if that's possible. I just can't figure out how to get the files added to the bundle.
I'm using XCode 14.3.1 if it matters.
Place the binary files in the app target's Copy Bundle Resources build phase to add the files to the app bundle.
- Open the project editor by choosing the project from the left side of the project window.
- Select the app target from the target list on the left side of the project editor.
- Click the Build Phases button at the top of the project editor.
- Click the disclosure triangle next to the Copy Bundle Resources build phases to see the files that are in the build phase.
- Click the Add button below the file list to add the binary files to the build phase.