iOS 动态库制作与调用

1.创建动态库

2.新建一个类 Person

#import@interface Person : NSObject

-(void)run;

@end

#import "Person.h"#import@implementation Person

-(void)run{

NSLog(@"let's run.");

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"动态库调用成功了.." message:@"😄😄" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"done", nil];

[alert show];

}

@end

头文件设置为Public

3.添加Target Aggregate 插入shell脚本保证可以在真机和模拟器可以使用

# Sets the target folders and the final framework product.

FMK_NAME=${PROJECT_NAME}

# 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.

# 分别编译生成真机和模拟器使用的framework

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命令将其合并成一个通用framework

# 最后将生成的通用framework放置在工程根目录下新建的Products目录下

lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/${FMK_NAME}"

rm -r "${WRK_DIR}"

run后就show finder 找到就可以用了



测试导入FrameWork 导入头文件 调用成功OK

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,029评论 19 139
  • 转载请注明出处:http://www.jianshu.com/p/04a7e28f11b9作者:纪小衰 frame...
    纪小衰阅读 11,553评论 3 16
  • 原贴地址 有没有写SDK或者要将一些常用的工具类做成Framework的经历? 你或许自己写脚本完成了这项工作,相...
    godgnay阅读 2,900评论 0 1
  • 前言 前面的两遍文章分别介绍了制作真机上面的静态库和动态库,但是问题又来了,真机上面的库是不能在模拟器上面运行的,...
    践行者_Leng阅读 5,010评论 0 0
  • 戏言 正月十五元宵夜。 晚风微凉,我独自走在街上,熙熙攘攘,恍然一惊,才察觉我已经来到了花市。元宵节的花市仿若白昼...
    9807115ff8e3阅读 3,101评论 0 0

友情链接更多精彩内容