Xcode7制做framework教程 iOS9


Demo地址:https://github.com/ma762614600/iOS_Framework
javascript


第一步:制做frameworkjava

原文连接:打包本身的framework(Xcode7&OSX10.11)兼容各类cpu类型git



第一步:新建Framework项目github


第二步:编写代码,构建完成项目xcode


第三步:新建一个咱们用来运行编译脚本的Targetbash


第四步:在新建的Target里边添加一个脚本app


第五步:填入脚本iphone


第六步:运行并根据须要编译ui

# 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 -arch armv7 -arch armv7s -arch arm64 clean build
xcodebuild -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/"

检测类库支持的版本(注意指向framework内部)

lipo -info ~/Documents/SFMapKit/Products/SFMapKit.framework/SFMapKit




第二步:解决会遇到的问题:spa

原文连接:XCode6添加自定义framework运行真机出现dyld: Library not loaded的解决方法


一、直接添加上面制做好的framework,会发报以下错误:

dyld: Library not loaded: @rpath/RLLibrary.framework/RLLibrary
  Referenced from: /var/mobile/Applications/AE92B234-A818-445E-9D69-96E232BD50EB/RLProjectDemo.app/RLProjectDemo
  Reason: image not found
(lldb) 

讨论:看网上很多人说是将上图Link Binary With Libraries中的Required改成Optional就没事了,实际真机运行发现不是回事,即便不报错了,可是也是没法运行程序。

解决方法:仔细看错误缘由,应该是没有找到framework文件包,So,怎么编译时打包进去呢?以下图,点击那个+号:

添加Copy Files节点,在Destination中选Frameworks,再点击下面+号,选择自定义的framework,ok,真机 Build,Run,这个世界美好了。



二、即便上面都已经配置好了,程序运行ok,可是当引用库中.h文件时,会警告“missing submodule 'XXXframework'”

解决方法:建立库文件时,只要在库文件中与库同名.h文件中添加要暴露的.h文件,有点绕,能够看下图:



注:稍后我会把我本身的demo传到github,再把整个流程细细梳理一遍,分享给你们!


-------------------------------------------------2015年11月27日编辑以下:--------------------------------------------------

Demo地址:https://github.com/ma762614600/iOS_Framework

相关文章
相关标签/搜索