How to make Universal Static library (.a file) in iOs using xCode

Tutorial for Creating Universal Static Lib,

In this tutorial we are creating Static Library for Logger class.

Step 1 : Create a New Project, Named it "Logger"

Step 2 : Create Classes

You can create as many classes you wants, In our tutorial we will create one class named "Logger". 
So, now two files should be in our resource.
1. Logger.h
2. Logger.m

Step 3 : Put some useful code into Classes


src="http://pastebin.com/embed_iframe.php?i=vJgx3enu" style="display: block; margin: 10px auto; max-width: 100%; border-style: none; height: 340px; width: 750px;">




Step 4 : Create New Target

Create New Target from File Menu.


New Target
New Target
Select Cocoa Touch Static Library


Select Cocoa Touch Static Lib
Select Cocoa Touch Static Lib
Step 5 : Add files to Compile Resource


  • Select "Logger" Target of Static Library
  • Go to Build Phases
  • In Complied Sources section, Add all the .m and .mm files.
  • In Copy Files section, Add all the .h files and resource files.

Build Phases

Step 6 : Compile Project with Static Library Target


  • Compile Project for iOS Device
  • Compile Project for Simulator
You can find two different .a files generated in build foders.

Find .a file
Find .a file

Step 7: Make Static Library Universal 

You can find two different library now, one is for simulator and one is for iOs devices.

  • Create a New Folder and name it LoggerMerge.
  • Copy libLogger.a file of Debug-iphoneos folder to "LoggerMerge" rename it to libLogger_device.a
  • Copy libLogger.a file of Debug-iphonesimulator folder to "LoggerMerge" rename it to libLogger_simulator.a
  • Open LoggerMerge folder with Terminal
  • Fire below command
lipo -create "libLogger_simulator.a" "libLogger_device.a" -output "libLogger.a"

Now, you can find libLogger.a in  LoggerMerge folder, this is Universal static library file.
Now, Just one thing you need is headers, See above screenshot there is folder called include in both build folder. Just copy header file from this folder.

Step 8 : Test Static Library

  • Create New Project, name it TestLogger
  • Import libLogger.a and header files
  • Import header file "Logger.h" anywhere you want to use
  • Now, Use this Logger class as default practice.
  • In our case, [Logger log:@"Test String"];
  • Run Project in Simulator and Device both
Thats's it!! You have your own static Library!! 

Thanks for Reading the Article !!

Follow me @ Just iOS

Contact Us @ Solution Analysts Pvt. Ltd.


allowtransparency="true" frameborder="0" scrolling="no" src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2FTheiOSOnly&width=292&height=290&show_faces=true&colorscheme=light&stream=false&border_color&header=true&appId=178990018860814" style="display: block; margin: 10px 0px; max-width: 100%; color: rgb(51, 51, 51); font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19.6000003814697px; border-style: none; height: 290px; overflow: hidden; width: 292px; background-color: rgb(250, 250, 250);">

转自:

How to make Universal Static library (.a file) in iOs using xCode

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。、可私 6信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 、可私信6博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 、可私信6博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值