iOS开发自己的sdk

来源:互联网 发布:尔雅网络课程登录 编辑:程序博客网 时间:2024/05/20 14:42

xcode7.3 ios7.0


一、(创建framework)

  1. 直接添加target,选择Framework & Library,选择Cocoa Touch Framework,命名创建
  2. 点击创建的framework,进行配置,在build setting中选择mach-0 选择static library;在build phase中的headers中public有暴露给外部使用的.h文件,需要配置
  3. 选择新创建 的target点击cmd + B在模拟器中生成framework,发现 侧边栏的products文件夹中创建的framework从红色变成黑色                    
二、直接添加target选择other,创建aggregate并进行配置,添加脚本run,这样生成的framework就会在项目的products文件中中不仅仅在模拟器中

      

# Sets the target folders and the final framework product.

# 如果工程名称和FrameworkTarget名称不一样的话,要自定义FMKNAME,一样的话用${SRCROOT}

# 例如: FMK_NAME = "MyFramework"

FMK_NAME="MyFramework“

# 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}"


三、将生成的framework直接拖出去使用,但如果自己的framwork中有类目的情况下,则应该配置新项目中的other flag link 为-ObjC



   




1 0
原创粉丝点击