Create aggregate to merge the simulator with the generic framework of the real machine
Then create the merge script under build phases new Run script phase:
# Constantssf_target_name=${project_name} #自定义的用来存放最后合并的frameworkUNIVERSAL_OUTPUTFOLDER=${build_dir}/${configuration}-Universal#iphone_device_build_dir=${build_dir}/${configuration}-Iphoneosworkspace_name=${project_name}.xcworkspaceyo_scheme=${project_name} #clean build is the first to clear the original Buildxcodebuild-workspace ${workspace_name}-scheme ${yo_scheme}-sdk iphonesimulator-configuration"${configuration}"Clean buildxcodebuild-workspace ${workspace_name}-scheme ${yo_scheme}-sdk iphoneos-configuration"${configuration}"Clean build# Build Project#xcodebuild-project"${project_file_path}"-target"${target_name}"-configuration"${configuration}"-SDK Iphoneos build_dir="${build_dir}"objroot="${objroot}"build_root="${build_root}"Configuration_build_dir="${iphone_device_build_dir}/arm64"symroot="${symroot}"archs='arm64'valid_archs='arm64'$ACTION #xcodebuild-project"${project_file_path}"-target"${target_name}"-configuration"${configuration}"-SDK Iphoneos build_dir="${build_dir}"objroot="${objroot}"build_root="${build_root}"Configuration_build_dir="${iphone_device_build_dir}/armv7"symroot="${symroot}"archs='armv7 armv7s'valid_archs='armv7 armv7s'$ACTION # Copy of the framework structure to the Universal folder (clean it first) #因为framework的合并, Lipo just merged the final binary executable file, We're going to have to copy it by ourselves. # Remove the original RM-rf"${universal_outputfolder}"mkdir-P"${universal_outputfolder}"CP-R"${build_dir}/${configuration}-iphonesimulator/${project_name}.framework" "${universal_outputfolder}/${project_name}.framework"#合并模拟器和真机的架构lipo-create"${build_dir}/${configuration}-iphonesimulator/${project_name}.framework/${project_name}""${build_dir}/${configuration}-iphoneos/${project_name}.framework/${project_name}"-output"${universal_outputfolder}/${project_name}.framework/${project_name}"Open"${universal_outputfolder}"
For the above script, which uses a lot of Xcode predefined variables, how do these variables come from? You can enter it at the command line
Xcodebuild-workspace yohunlutilslib.xcworkspace-scheme yohunlutilslib-sdk iphonesimulator-configuration Debug- Showbuildsettings > Xcodebuild_showbuildsettings.txt
To import all of the Xcode pre-defined variables into the text xcodebuild_showbuildsettings.txt, and then you can choose what you want.
Of course, we should generally merge the release mode, not the framework of the debug mode
View information about the. Framework:
Lipo-info AA.FRAMEWORK/AA
Show:
Architectures in the Fat File:aa.framework/aa are:armv7 arm64
Shows that the real machine framework:aa.framework we generated contains two architectures armv7 arm64
Separation architecture (as an example of separating armv7)
The current directory establishes a folder for separating the schemas, and the isolated. o Files
mkdir armV7
Detach the ARMV7 schema into the folder armV7:
Lipo Aa.framework/aa-thin Armv7-output./armv7/aa_armv7
Detach all. o files from the ARMV7 schema
-X AA_ARMV7
iOS. A and. Framework