IOS development-Create framework static library tutorial, iosframework

Source: Internet
Author: User

IOS development-Create framework static library tutorial, iosframework
Environment:

Hardware: macbook air

System: osx ei Capitan version: 10.11.3

Xcode: Version 7.2.1 (7C1002)

Recently, I have done a static library for ios (it is said that the framework dynamic library cannot be uploaded to app store). a and framework have done it. Here I will first talk about the framework production process:

1. Create a cocoa touch framework project under xcode:

2. After creating a new project, add the code to be encapsulated and include the header containing the public api in the automatically generated header file.

Or put the public header file in Headers under Build Phases to public.

3. Find Mach-O Type in Build Setting --> Linking and change the value of Dynamic Library to Static Library. If the framework generated in this step is missing, it is the Dynamic Library.

4. Locate Edit scheme and change the value of build configure from default Debug to Release under run --> info.

5. select the hardware environment to be compiled: compile it once under Generic IOS Device and iPhone 6 s Plus (select the latest simulator, after compilation, You can see xxx under the products file of the project. the framework is changed from red to black (Note: if only the iphone 6 s Plus simulator is compiled and the Generic IOS Device is not compiled, then xxx. the framework is still not black)

6. After the xxx. framework turns black, right-click xxx. framework and right-click show in finder to view the generated framework static library. Release-iphoneos real-machine and Release-iphonesimulator simulators are available respectively. That is to say, the generated versions can only be used in their respective hardware environments.

7. merge the static libraries of the real machine and simulator framework, so that they can be used in the simulator and the real machine, however, pay attention to the fact that the size of the generated static library is equal to the sum of the size of the real machine version and the Simulator version. To reduce the size of the program, you can use only one of the versions.

You can use the lipo that comes with xcode to merge two versions: Use the command "lipo-create/User/" on the terminal /..... /release-iphoneos/xxx. framework/xxx/User /..... /release-iphonesimular/xxx. framework/xxx-output. /xxx

Here, xxx is the name of your library, and the path is the path of the generated static library. Then, place the generated xxx in the real machine or Simulator version xxx. framework to replace the original xxx library.

 

Related Article

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.