First of all, I am a rookie, just in the work need to provide other companies SDK so learned how to package to build their own SDK, there is no shortage of places, but also hope that you can correct.
All right, nonsense. First, I use the Xcode version is 7.2, create a new project, after entering the page, select the Cocoa Touch framework in the Framework & Libray options.
Because I want to package the required files, I created the cvenies.h,cvenies.m file myself, and I customized an initialization method, called the-(void) getString: (NSString *) string method in the initialization method, and printed a word, in order to prove that the framework after the creation of the method, and in the actual work process, directly to the packaging of all the files to the project can be,
Then check target, check build phases-Headers, you can see that there are three options, namely public,private,project; drag the. h file that needs to be exposed to the public, and the rest is not exposed, is a hidden file, placed in project,
After completing the above steps, in the LittleCveniEs.h file, all the. h files that need to be exposed are introduced with #import <littleCveniEs/PublicHeader.h> Remember to make sure that all of the. h files that need to be exposed are written at a given location, or generated after compilation. The framework will have a warning when referenced;
Create a new target, select Other->aggregate, rename, PS: The markup in the diagram is too ugly to ignore,--!
Select the new target, click Build Pharas, and select +,new Run Script Phase in the upper-left corner;
Click Run script to add the following scripts;
Select the first target in targets, which is littlecvenies, click Build Setting, Mach-o Type, select the static Library, there will be a problem here, It is impossible to use on iphone5c. Framework, which we need to add armv7s in build Setting-architectures->architectures
We have done all the work, can choose Command + B, but before compiling, according to the selection of the correct target, after the completion of the compilation will automatically popup has been created. Framework;
Here we have completed 99% steps to import the. Framework can implement method calls, however, if you need to hide the file containing the class created by category, when you run the program will find a crash phenomenon, such as, I was creating my own. Framework when I wrote a nsstring category, and in the initialization method called the method in the category, the program appears directly unrecognized selector sent to instance 0x10008c098 error, when we need to quote us. In the framework of the project set Build Pharse and other Linker flags plus-all_load is OK, run the project again, you can complete all the printing process.
Cvenies
Links: https://www.jianshu.com/p/305b716df620
Script code:
# Sets the target folders and the final framework product.# if the project name and the framework's target name are different, customize the fmkname# for example: Fmk_name = "Myframework"Fmk_name=${project_name}# Install dir 'll is the final output to the framework.# the following line create itinchThe root folder of the current project. Install_dir=${srcroot}/products/${fmk_name}.framework# Working dir would be a 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 Clean buildxcodebuild-configuration "Release"-target "${fmk_name}"-SDK Iphonesimulator 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"${install_dir}"
Add version number:
To get version information, set the Info.plist file first, set it in build settings, and, of course, set it in the aggregate you created.
The script code at this point is
# Sets the target folders and the final framework product.# if the project name and the framework's target name are different, customize the fmkname# for example: Fmk_name /c0>= "Myframework"Fmk_name=${project_name} # Install dir 'll is the final output to the framework.# the following line create itinchThe root folder of the current project.#${sdk_name} #SDK_VERSION=$ (Echo ${sdk_name} | grep-o '. {3}$ ')#/${dylib_current_version}#/${current_project_version}#版本获取echo"${project_dir}/${infoplist_file}"BuildNumber=$ (/usr/libexec/plistbuddy-c "Print:cfbundleversion" "${project_dir}/${infoplist_file}") buildnumber="$buildNumber"Echo"BuildNumber = $buildNumber"shortversion=$ (/usr/libexec/plistbuddy-c"Print:cfbundleshortversionstring" "${project_dir}/${infoplist_file}") shortversion= "$shortVersion"Echo"Shortversion = $shortVersion"#自增build版本buildVersion=$ (Echo ${buildnumber} | grep-o-e ' \d{1,3}$ ') Buildversion=$ (($buildVersion + 1)) Buildversion= ". $buildVersion"Echo"Buildversion = $buildVersion"#设置build版本newBuildNumber= "$shortVersion $buildversion"Echo"Newbuildnumber = $newBuildNumber"/usr/libexec/plistbuddy-c "set:cfbundleversion $newBuildNumber" "${project_dir}/$ {Infoplist_file} "install_dir=${srcroot}/products/${buildnumber}/${fmk_name}.framework# working DIR would be a deleted after the Framework creation. work_dir=builddevice_dir=${work_dir}/release-iphoneos/${fmk_name}.frameworksimulator_dir=${work_dir}/ release-iphonesimulator/${fmk_name}.framework#-configuration ${configuration}"Release"# Clean and Building both architectures.xcodebuild-configuration"Release"-target "${fmk_name}"-sdk Iphoneos Clean buildxcodebuild-configuration"Release"-target "${fmk_name}"-sdk iphonesimulator Clean build# Cleaning the oldest.if [-D"${install_dir}"]THENRM-RF"${install_dir}"fimkdir-p"${install_dir}"Cp-r"${device_dir}/" "${install_dir}/"Cp-r"${simulator_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 "${WORK_DIR}"RM-rf "${install_dir}/_codesignature"RM-rf "${install_dir}/info.plist"Open"${install_dir}"
IOS Packaging Framework