原文
iOS SDK~ 打包framework、开发与调试
iOS项目中SDK的开发与调试
iOS 中的 armv7,armv7s,arm64,i386,x86_64 都是什么
Undefined symbols for architecture x86_64: "OBJC_CLASS$_EditRecordViewController", referenced fr
一、创建一个workspace项目
1.现在桌面创建文件夹 SHTestSDk
2.打开Xcode,创建一个workspace 流程: Xcode---File---New---Workspace 快捷键 :command +N = 创建项目
3.把创建好的添加到 文件名为 SHTestSDK 里面
图1:

图2:

图3:创建成功效果

二、创建SDK
1、打开SHTestSDK.xcworkspace文件,创建project
图4:

图5:

图6:

图7:

图8:成功效果图

三、创建Demo
图9:

图10:

图11:成功效果图

四、SHTestDemo的关联以及SDK的开发调试
1.这里创建一个SHView类,继承于UIView,简单的重写了初始化方法,设置了颜色
图12:

2.设置Build Setting参数 将Build Active Architecture only设置为NO,
图13:

3.设置Build Setting参数 在Architectures下增加armv7s
图14:

4.设置Headers,将要公开的头文件拖到Public下,要隐藏的放到Private或Project下,隐藏的头文件不能被引用,效果图:
图15:

5.在SHTestSDK.h(必须是公开的,否则无法引用)中将所有要公开的.h引入
图16:

6.创建一个Aggregare
图17:

图18:

7.嵌入脚本,选中刚刚创建的Aggregare,然后选中右侧的Build Phases,点击左边的+号,选择New Run Script Phases
图19:

图20:

8.下面把这段脚本复制进去(格式不要错,格式错编译不通过)
# Sets the target folders and the final framework product.
# 如果工程名称和Framework的Target名称不一样的话,要自定义FMKNAME
# 例如: FMK_NAME ="MyFramework"
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.
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}"
图21:效果图:

9.最后编译,command + B,编译通过在finder中找到framework,拷贝出来
图22:

图23:效果图

五、SHTestDemo与SHTestSDK的关联
1.把打包好的framework拖到demo里面
图24:

2.使用SDK,运行demo
图25:

图26:

图27:效果图:
注意:以上功能就是SDK 和 demo 相关联好了.
六、SHTestSDK 调试
1.修改下面SDK中的代码,运行demo就是修改后的效果,然后就可以愉快的在这个工程里面开发调试SDK了,如果我把MyView的颜色设置为yellow,再去运行demo,看一下效果
图27 :

谢谢!!!
作者:石虎132
来源:CSDN
原文:https://blog.csdn.net/shihuboke/article/details/78450955
版权声明:本文为博主原创文章,转载请附上博文链接!
网友评论