关于ios静态库framework使用cocoapods引入第三
1、创建静态库,我们这里只介绍使用framework类型,首先打开xcode -->菜单new-->project-->选择右下角的静态库:

2.1、进入到项目目录,创建podfile,(前提本地得先配置好cocoapods环境)
填写需要导入的第三方:
target "YHAlertSDK" do
platform :ios,'8.0'
#useframeworks
#to avoid other people pod again, must point thirty version except UM
pod 'SVProgressHUD', '2.1.2'
end
2.2 、cd到podfile目录,并执行在命令窗口 pod install命令,结果如下图:


3、打开xcworkspace,Ctr + B,即可生成framework库

4.1、使用脚本进行打包,先选择file-->new-->target ,顶部选择cross-platform,点击Aggregate:

4.2 、此时项目界面如图4一样,我们选择Build phase ,再点击左上角的 + 号,然后添加脚本,把脚本复制,粘贴上去。脚本可以直接全真机与模拟器的包,脚本代码如下:
#!/bin/sh
#UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
UNIVERSAL_OUTPUTFOLDER=${SRCROOT}/Products
WORKSPACE_NAME=${PROJECT_NAME}.xcworkspace
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -workspace "${WORKSPACE_NAME}" -scheme "${PROJECT_NAME}"-configuration ${CONFIGURATION} -sdk iphoneos ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -workspace "${WORKSPACE_NAME}" -scheme "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
# Step 2. Copy the framework structure (from iphoneos build) to the universal folder
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"
# Step 4. Create universal binary file using lipo and place the combined executable in the copied framework directory
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"
# Step 5. Convenience step to copy the framework to the project's directory
#cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework" "${PROJECT_DIR}"
# Step 6. Convenience step to open the project's directory in Finder
open "${UNIVERSAL_OUTPUTFOLDER}"
5、xcode左上角,选择目标,genearteSDK, 运行 或者Ctr + B便可脚本生成framework。如下图:


总结,文章介绍比较简单,需要对cocoapod有一定的了解。