fastlane 编译 framework

下面为使用fastlane编译framework的片段:

def ios_build_framework( project_path, target ,code_path)
  #build for iphonesimulator
  xcodebuild(
      project: project_path,
      target: target,
      configuration: "Release",
      silent: false,
      clean: true,
      build: true,
      xcargs: "-UseModernBuildSystem=0 -sdk 'iphonesimulator'"
  )
  #build for iphone
  xcodebuild(
      project: project_path,
      target: target,
      configuration: "Release",
      silent: false,
      clean: true,
      build: true,
      xcargs: "-UseModernBuildSystem=0",
  )
  # Two libraries are combined into one, support x86_64, armv7 ,arm64
  command = "lipo -create #{code_path}/build/Release-iphoneos/#{target}.framework/#{target} #{code_path}/build/Release-iphonesimulator/#{target}.framework/#{target} -output #{code_path}/build/Release-iphoneos/#{target}.framework/#{target} "
  result = `#{command}`
end
shell命令生成:
func_build_framework(){

  FMK_NAME=$1
  cd "./$1"
  BUILD_CONFIGURATION="Release"
  # 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="./Products/${FMK_NAME}.framework"
  # Working dir will be deleted after the framework creation.
  DEVICE_DIR="./build/${BUILD_CONFIGURATION}-iphoneos/${FMK_NAME}.framework"
  SIMULATOR_DIR="./build/${BUILD_CONFIGURATION}-iphonesimulator/${FMK_NAME}.framework"

  xcodebuild clean -target "${FMK_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${BUILD_CONFIGURATION} -sdk iphoneos -UseModernBuildSystem=NO
  xcodebuild build -target "${FMK_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${BUILD_CONFIGURATION} -sdk iphoneos -UseModernBuildSystem=NO
  xcodebuild clean -target "${FMK_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${BUILD_CONFIGURATION} -sdk iphonesimulator -UseModernBuildSystem=NO
  xcodebuild build -target "${FMK_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${BUILD_CONFIGURATION} -sdk iphonesimulator -UseModernBuildSystem=NO

  # 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 (x86_64 + armv64/armv7) into one Universal final product.
  lipo -create ${DEVICE_DIR}/${FMK_NAME} ${SIMULATOR_DIR}/${FMK_NAME} -output ${INSTALL_DIR}/${FMK_NAME}
}

func_build_framework "native_plugin"

你可能感兴趣的:(fastlane 编译 framework)