iOS 自定义库文件
来源:互联网 发布:淘宝联盟规则 编辑:程序博客网 时间:2024/06/05 11:15
第一步:创建framworking工程
第二步
在工程里封装一个自定义类;
#import <UIKit/UIKit.h>
@interface imageview :UIImageView
-(instancetype)initWithFrame:(CGRect)frame urlString:(NSString *)_urlString;
@end
#import "imageview.h"
@implementation imageview
-(instancetype)initWithFrame:(CGRect)frame urlString:(NSString *)_urlString{
self = [superinit];
if (self) {
self.layer.cornerRadius =10;
self.layer.masksToBounds =YES;
self.frame = frame;
NSURL *url = [NSURLURLWithString:_urlString];
dispatch_queue_t queuewww=dispatch_queue_create("test",NULL);
dispatch_async(queuewww, ^{
NSData *data = [NSDatadataWithContentsOfURL:url];
UIImage *imga = [UIImageimageWithData:data];
dispatch_sync(dispatch_get_main_queue(), ^{
self.image = imga;
});
});
}
return self;
}
将 Header / Project中的.h文件拖入Public中
如下图
设置Build Settings
a.将Linking / Mach Type 设置为 Static Library
b.将Packaging / Defines Module 设置为NO;
如下图
第三步,添加Aggregate
在Aggregate 的Build Phase添加Run Script并修改其中的shell 对话框内容
如图
内容如下:修改FMK_NAME值为自己自定义类名;如FMK_NAME = ...
# Sets the target folders and the final framework product.
# 如果工程名称和Framework的Target名称不一样的话,要自定义FMKNAME
# 例如: FMK_NAME = "MyFramework"
FMK_NAME=Myframworking
# Install dir will be the final output to the framework.
# The following line create it in the root folder of the current project.
INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework
# Working dir will be deleted after the framework creation.
WRK_DIR=build
DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.framework
SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.framework
# -configuration ${CONFIGURATION}
# Clean and Building both architectures.
xcodebuild -configuration"Release" -target "${FMK_NAME}" -sdk iphoneos clean build
xcodebuild -configuration"Release" -target "${FMK_NAME}" -sdk iphonesimulator clean build
# Cleaning the oldest.
if [ -d "${INSTALL_DIR}" ]
then
rm -rf "${INSTALL_DIR}"
fi
mkdir -p "${INSTALL_DIR}"
cp -R "${DEVICE_DIR}/""${INSTALL_DIR}/"
# Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.
lipo -create "${DEVICE_DIR}/${FMK_NAME}""${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/${FMK_NAME}"
rm -r "${WRK_DIR}"
open "${INSTALL_DIR}"
第四步:
(将模拟器调为Generic IOS Device模式)
1.先运行framworking
2.在运行Aggregate
之后会弹出新创建的自定义库文件夹。
恭喜你已经成功创建属于自己的框架。
若需调用框架,只需要将自定义库文件夹中product中的程序拖入你的X-code工程就可以使用了;
- iOS 自定义库文件
- iOS Class Prefix自定义类,文件前缀
- IOS:IOS自定义xib文件的使用笔记
- iOS菜鸟学习——通过nib文件自定义Cell
- iOS study Day15-自定义文件的解档和归档
- iOS开发~自定义Xcode工程模版与文件模版
- iOS开发~自定义Xcode工程模版与文件模版
- iOS开发------使用自定义.bundle中的资源文件
- iOS开发------使用自定义.bundle中的资源文件
- python自定义库文件路径
- python自定义库文件路径
- iOS 库文件创建
- [iOS]实现了一套自定义动画库
- 在IOS中如何读取系统产生的plist文件和自定义的plist文件
- 在IOS中如何读取系统产生的plist文件和自定义的plist文件
- 在IOS中如何读取系统产生的plist文件和自定义的plist文件
- IOS 文件操作类库
- iOS Podfile文件常用库
- jsp文件上传(图片上传)
- JDK环境变量设置
- 本地计算机上的服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止。
- 常见排序算法小结
- 关于一些 iOS 面试问题的解答
- iOS 自定义库文件
- 斯坦福大学机器学习——EM算法求解高斯混合模型
- PopupWindow的动画效果
- C#使用ODBCl连接MySql详细教程
- hibernate jpa manyToOne级联操作时,update时报出identifier of an instance of 问题的解决方案及update问题
- HDOJ 2098 分拆素数和
- WebAPI GET和POST请求的几种方式
- Snapdragon Flight
- 经济基础知识三