How to make Universal Static library (.a file) in iOs using xCode
来源:互联网 发布:柳天捏脸数据 编辑:程序博客网 时间:2024/05/18 01:40
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
Step 4 : Create New Target
Create New Target from File Menu.
New TargetSelect Cocoa Touch Static Library
Select Cocoa Touch Static LibStep 5 : Add files to Compile Resource
Build Phases
Step 6 : Compile Project with Static Library Target
Find .a file
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
Step 4 : Create New Target
Create New Target from File Menu.
New TargetSelect Cocoa Touch Static Library
Select Cocoa Touch Static LibStep 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.
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.
Thanks for Reading the Article !!
Follow me @ Just iOS
Contact Us @ Solution Analysts Pvt. Ltd.
转自:
How to make Universal Static library (.a file) in iOs using xCode
0 0
- How to make Universal Static library (.a file) in iOs using xCode
- Using a static library in Xcode
- How to make awesome UI components in iOS 8 using Swift and XCode 6
- How to make a custom keyboard in iOS 8 using Swift
- [IOS] how to make ipa in xcode 4.3
- How to make a KML/KMZ file in Google Earth?
- How to make a direct download link to a static file
- how to make a JAR file
- how to force global variable which define in a static library to initialize?
- How to make an image move in a circular path using jquery?
- How to import a C library in Swift using the Swift Package Manager
- how to make a authorware file in an environment without authorware
- Creating a Static Library in iOS Tutorial
- Creating a Static Library in iOS Tutorial
- Creating a Static Library in iOS Tutorial
- Creating a Static Library in iOS Tutorial
- How to Make Dynamic Hyperlinks Using C# in ASP.NET
- How to make a Web crawler using Java?
- 利用开源组件commons-fileupload上传图片文件(1)
- 【Git学习笔记】将文件放入仓库只需两步add和commit
- shape的使用总结
- extern
- jFinal中报对应模型不存在的错误(The Table mapping of model: demo.User not exists)
- How to make Universal Static library (.a file) in iOs using xCode
- Java的运行时数据存储机制
- 第9周 项目6-6 “都要学C”
- webkit/chromuim/CEF3介绍
- 哈尔滨耳鼻喉
- zlib库剖析(4):使用示例example.c
- 谷歌前员工一语道破皮查伊和佩奇最大不同点
- 程序猿之-创业执行力
- AIR 15.0 提交 APPSTORE 错误 ERROR ITMS-9000: INVALID SEGMENT ALIGNMENT