Use xib and picture resources in the IOS framework static Library

Source: Internet
Author: User

First, the new bundle

The first 2 articles describe the latest iOS framework and. A static library production and use of full-solution iOS engineering covers, Master Engineering and framework Engineering or. A library static library project linking

I am now in the main project of the sub-project, of course, you create a static library project (sub-project) is also possible. Before I was too lazy to build the project, and then ready-made main project project.

1. Follow the steps

2. Because there is no bundle in the iOS framework, select the OS X framework to find the bundle, as

Second, the bundle plus resource files

Add the project's resource files to the bundle you just built, such as xib, pictures. Click the + sign or drag all the lines directly. Steps such as.

Third, set bundle

1.iOS Deployment Target change to the minimum version you support

2. Set the base SDK to latest IOS

Iv. Compiling bundles

If you choose your bundle as target to compile

V. Using the resource files in the bundle

1. If you drag your bundle to the master project's copy bundle resources

2. Use the Xib code as follows

NSBundle *bundle = [NSBundle bundlewithurl:[[nsbundle mainbundle] Urlforresource:@ "appbasesdkbundle" Withextension:@ "bundle"]; Nsarray *nibs = [Bundle loadnibnamed:@ "zlftabbar" Owner:nil Options:nil];       

3. Use the image code as follows

NSBundle *bundle = [NSBundle bundlewithurl:[[nsbundle mainbundle] Urlforresource:@"Appbasesdkbundle "Withextension:@"  Bundle "@ "zhuanqian " Inbundle:bundle Compatiblewithtraitcollection:nil]; // or Uiimageview *v2 = [[Uiimageview alloc] initWithFrame : CGRectMake (0,100, 50 , 50@ " Appbasesdkbundle.bundle/zhuanqian       
Vi. processing after modifying a resource file

1. For a static library has been made, each time the resource file has been modified to recompile the bundle.

2. There is another way to do the case of the main engineering project without recompiling the bundle. If you add a dependency on the project to the main project, you will compile the sub-project each time you compile the main project.

Add a dependency on the bundle to the sub-project so that the bundle is compiled each time the child project is compiled.

After a 2-tier dependency, the resource file is compiled when the main project is compiled.

Use xib and picture resources in the IOS framework static Library

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.