WEB开发网
开发学院手机开发iPhone 开发 How to (almost) create your own iPhone OS fram... 阅读

How to (almost) create your own iPhone OS framework

 2010-04-19 16:13:00 来源:WEB开发网   
核心提示:As of iPhone SDK version 2.1, it doesn't seem to be possible to package your own code into an iPhone OS framework. Messing around with OS X 10.5 framework b

As of iPhone SDK version 2.1, it doesn't seem to be possible to package your own code into an iPhone OS framework. Messing around with OS X 10.5 framework build options didn't yield any useful results for us. The closest we got is a static library built for each platform (iPhone OS and the Aspen simulator), bundled up into one file (using a command line tool called 'lipo') and a set of header files that you would reference in order to use the library.

Setting: You have several implementation files with the corresponding header files that you'd like to reuse in another iPhone app project.

Step 1: Create static libraries for iPhone OS and iPhone Simulator.

You need to create one "static library" build target for each platform in an empty project. Create a new "Window-Based Application" project for iPhone OS. Delete all source and NIB files and remove all references to frameworks that your library won't be using. Keep the .pch file. Remove the existing build target. At this point, your project should look something like this:

In order to bundle lib files for different platforms into one, we need to build them separately first. To do that, create 2 new "Static Library" build targets, we'll call them 'PseudoFramework sim' and 'PseudoFramework dev' for Simulator and device, respectively. Add your library source and header files. In the build settings for target 'PseudoFramework sim', click on 'Base SDK' and select 'Simulator - iPhone OS'; 'PseudoFramework dev' should be using the 'Device - iPhone OS' Base SDK. At this point you should be able to build separate .a files by selecting "Active SDK"->"Use project settings" from the dropdown box on top, selecting your desired configuration (debug or release) and right-clicking on each target and selecting "Build" from the menu. At this

1 2 3  下一页

Tags:How to almost

编辑录入:coldstar [复制链接] [打 印]
赞助商链接