故事的开端:
今天研究 PLCrashReporter
的时候,试着想把内部的源码打包 framework
,试着扣出核心代码,结果失败,后来在想,能不能在我的 framework
里面包含 PLCrashReporter
的 framework
呢,然后就去研究了,一直在失败,结果我搜 PLCrashReporter
的时候,发现 hockeyapp
也在内部使用了,然后试着研究了 OneAPM
, 蒲公英 SDK
,Newrelic
等内部都使用到了,但是实在不知道他们是怎么内置的.然后研究了一个下午 + 晚上终于搞定
过程,废话不多说,直接开搞
新建文件
这里随便写啦,记录详细点
新建完成是这样子滴☺️
把 Demo.h 这个文件删除,导入自己想要的 Framework 文件
下面添加一个这个,看图
搜索 other link
最好把 UIKit 也包含进去了
$(inherited) -framework CrashReporter -framework UIKit
注意是这里!!!!也要这么搞
然后这里选择你想要暴露出去的文件
然后下面配置一下脚本
DEBUG 脚本
# 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=buildDEVICE_DIR=${WRK_DIR}/Debug-iphoneos/${FMK_NAME}.frameworkSIMULATOR_DIR=${WRK_DIR}/Debug-iphonesimulator/${FMK_NAME}.framework# -configuration ${CONFIGURATION}# Clean and Building both architectures.xcodebuild -configuration "Debug" -target "${FMK_NAME}" -sdk iphoneos -arch armv7 -arch armv7s -arch arm64 clean buildxcodebuild -configuration "Debug" -target "${FMK_NAME}" -sdk iphonesimulator -arch x86_64 clean build# Cleaning the oldest.if [ -d "${INSTALL_DIR}" ]thenrm -rf "${INSTALL_DIR}"fimkdir -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 "${SRCROOT}/Products/"
Release 脚本
# 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=buildDEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.frameworkSIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.framework# -configuration ${CONFIGURATION}# Clean and Building both architectures.xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos -arch armv7 -arch armv7s -arch arm64 clean buildxcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator -arch x86_64 clean build# Cleaning the oldest.if [ -d "${INSTALL_DIR}" ]thenrm -rf "${INSTALL_DIR}"fimkdir -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 "${SRCROOT}/Products/"
然后看图,直接运行,OK
然后再新建个工程测试一下
欧尼,奔溃了!!!!
很好解决,这里也添加一下,然后再运行, OK
Plcrashreporter 下载地址:
https://www.plcrashreporter.org/download/