Because a static library file (. A file) is used in a project that is being developed, it is designed to be simple to learn. Static library files are packaged with common code that is often used to facilitate the reuse of code.
1. Generate Static library file. The main steps include the following:
(1) Create a static library project
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/25/wKiom1Xdd8iTXsMiAAFq3ICkesI772.jpg "title=" QQ20150826-1@2x.png "alt=" Wkiom1xdd8itxsmiaafq3ickesi772.jpg "/>
Named Stone, and added a class method +printinfo to the generated stone class,
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/25/wKiom1XdeX-SvQCiAAIG0e6CVKo709.jpg "style=" float: none; "title=" QQ20150826-2@2x.png "alt=" Wkiom1xdex-svqciaaig0e6cvko709.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/21/wKioL1Xde5fiL7VvAAI3UmOn2r4992.jpg "style=" float: none; "title=" QQ20150826-3@2x.png "alt=" Wkiol1xde5fil7vvaai3umon2r4992.jpg "/>
Before compiling, the Libstone.a in the Products folder is red, the compilation turns black,
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/22/wKioL1XdfRbw4UOoAAFxmnI2kf0490.jpg "title=" QQ20150826-4@2x.png "alt=" Wkiol1xdfrbw4uooaafxmni2kf0490.jpg "/>
Note at the top select "iOS device" to generate a static library file for the real machine, select any emulator to generate a static library file for the emulator, and libstone.a from red to black as long as you select iOS device.
(2) Set release, such as:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/22/wKioL1Xdf8fT8GCLAAKSRSQZdTw502.jpg "title=" QQ20150826-10@2x.png "alt=" Wkiol1xdf8ft8gclaaksrsqzdtw502.jpg "/>
Select the red circle on the left side of the chart, then select Edit Scheme and select release in the Pop-up dialog box.
(3) After compiling, enter the folder:
/users/layne/library/developer/xcode/deriveddata
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/22/wKioL1XdgGeCNdvfAAI8qHrlNEQ571.jpg "title=" QQ20150826-11@2x.png "alt=" Wkiol1xdggecndvfaai8qhrlneq571.jpg "/>
Locate the corresponding item in the folder, Stone-efgkvmcmovsnfcelruigvapvtvwl/build/products, You can see that 2 folders have been generated Release-iphone and Release-iphonesimulator, the former libstone.a used in the real machine, the latter inside the Libstone.a for the simulator.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/22/wKioL1XdgaCyxZUQAABz7qTC4YA613.jpg "title=" QQ20150826-12@2x.png "alt=" Wkiol1xdgacyxzuqaabz7qtc4ya613.jpg "/>
2, for the use of LIBSTONE.A projects to configure.
Using the created project Uimenucontroller, the. A file used for the simulator has been renamed and copied to the desktop for demonstration purposes. Such as:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/22/wKioL1XdgujBwrI4AAEFOfsLHjM527.jpg "title=" QQ20150826-14@2x.png "alt=" Wkiol1xdgujbwri4aaefofslhjm527.jpg "/>
(1) Build Phases->link Binary with libraries add libstoneforiphone.a to the Uimenucontroller project and add Stone.h to the project,
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/22/wKioL1XdhFyBpwGBAAIMUOzbQo8366.jpg "title=" QQ20150826-15@2x.png "alt=" Wkiol1xdhfybpwgbaaimuozbqo8366.jpg "/>
(2) use.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/26/wKiom1XdgrbyRhwUAAiOPXCmqys017.jpg "title=" QQ20150826-17@2x.png "alt=" Wkiom1xdgrbyrhwuaaiopxcmqys017.jpg "/>
Attention:
(1) What kind of. A files are added can only be run in a corresponding way. Add the LIBSTONEFORSIMULATOR.A, you can only run with the simulator, add Libstoneforiphone.a, you can only run with the real machine. Otherwise, there will be an error.
(2) There are two ways to solve this problem:
① adds two. A files into the project.
② merge two. A into one. a file.
The method of merging two. A files into one is as follows:
You can use the command line. The terminal switches to the desktop, and then executes the following command
Lipo-create Libstoneforiphone.a libstoneforsimulator.a-output LIBSTONEFORALL.A
This way, you can just introduce the LIBSTONEFORALL.A file.
This article is from the "Layne Learning Corner" blog, please be sure to keep this source http://laynestone.blog.51cto.com/9459455/1688537
The iOS project references a static library file. A