Joke Collection Website - Public benefit messages - iOS SDK (2): Bundle creation amp; use

iOS SDK (2): Bundle creation amp; use

Generally, bundle files are used to archive resource files used by the SDK, such as images, multi-language files, storyboard compiled files, etc.

Create a new folder

Modify the file name with the suffix .bundle:

In this way, a bundle file is created, and the resources can be used after placing them in it. .

Create a bundle project

Name it NiceBundle, the name here is the name of the bundle compiled later

To facilitate management, combine the project with the Framework Put the projects together

Set the support type to iOS

Set the minimum supported version and supported device type

Compile and obtain the bundle file

Import the image and compile it

It can be found that in the bundle project, the image is placed under the image folder, and appears in the NiceBundle.bundle root directory after compilation, indicating that even if the folder is nested, the compiled resource The files will be in the bundle file root directory. This is very important and involves the path issue when we read the bundle file later.

Like the Framework project, it can be added to xcworkspace for easier management.

Import NiceBundle.bundle into the Demo project, compile it, and check where the bundle file is in the application.

From this, you can get how to read the bundle according to the path when using it. Way.

You can see that the image was successfully read through the above method

In the same way, other types of files can also be read through the above method.

Please give it a thumbs up if you understand, friends!