How to build a archive file using shell scripting and export the signed IPA file.

Source: Internet
Author: User
Tags shebang

How to build a archive file using shell scripting and export the signed IPA file.

1. Build Script Description

This shell script is used for Build,xcode workspace source code engineering and is exported as a re-signed IPA file for distributing test installation files and files for submitting AppStore audits. Implement auxiliary product development, test configuration management work.

Using this script requires the following environments
- Mac OS 10.9+
- XCode 6.0 or later and command line tools
- for workspace projects, such as those using cocoapods-dependent library management
- * Configuration of development certificate and AD Ho certificate (for Debug) and (for Release)
- the scheme name and build are configured in the source code project .
- Set the certificate name for the Debug configuration and Release configuration.
- Verify that the Xcode UI interface is able to build completely and generate archive and IPA through the environment and sign correctly.
- Create a Build folder under the workspace folder

2. Copy the script file to the workspace directory 3. Open the Terminal tool and enter workspace directory 4. To execute permissions on a script

chmod 777./build_one_target.sh

5. Modify the script parameters, there are already comments in the source code

Need to modify the
Workspace name
Provisioningprofile
Scheme name
Build_config

code block

code block syntax follows standard markdown code

#!/bin/bash# init build configuration# Archive and IPA output pathBuild_path="./build"# Workspace NameBuild_workspace="Workspacename.xcworkspace" # project name and pathproject_path=$ (pwd) project_name=$ (ls | grep xcodeproj | awk-f.xcodeproj' {print '} ')# Provisiong Profile nameprovisioningprofile=' XC Ad Hoc:com.xxxxxx.yyyyyy '# Timestamp for ouput file nametimestamp="$ (date +"%y%m%d_%h%m%s ")"Echo "$project _path/$build _workspace"if[ !- D "$project _path/$build _workspace"]; Then    Echo  "error! Current path was not a Xcode workspace. Please check, or does not use-w option. "    Exit 2fi # get the Info.plistApp_infoplist_path=${project_path}/${project_name}/${project_name}-appstore-info.plistEcho ${app_infoplist_path}# Get the main versionbundleshortversion=$ (/usr/libexec/plistbuddy-c"Print cfbundleshortversionstring" "${app_infoplist_path}")# Get the build versionbundleversion=$ (/usr/libexec/plistbuddy-c"Print Cfbundleversion" "${app_infoplist_path}")# Get the SVN revisionsvn_revision=$ (SVN info |grep revision: |awk' {print $} ')# ' svnversion-c |sed ' s/^.*://' |sed ' s/[a-z]*$// '#svn Info |grep Revision: |awk ' {print $} '#workspace_name = ' *.xcworkspace '#ls $project _path/$build _workspace &>/dev/null#rtnValue =$?#if [! $rtnValue = 0];then# #build_workspace =$ (echo $ (basename $project _path/$workspace _name))# echo "error! Current path was not a Xcode workspace. Please check, or does not use-w option. "# exit 2#fi# scheme nameBuild_scheme="Schemename" # buidl CONFIG. The default is Debug| Releasebuild_config="Release"# Clean BuildClean_cmd=' Xcodebuild 'Clean_cmd=${clean_cmd}' Clean-workspace '${build_workspace}'-scheme '${build_scheme}'-configuration '${build_config}$clean _cmd>$build _path/clean_qa.txt | |Exit# Build & archive, generate the archive fileArchive_name="Targetname_qa_${timestamp}. xcarchive"Archive_path="./build/"$archive _nameBuild_cmd=' Xcodebuild 'Build_cmd=${build_cmd}'-workspace '${build_workspace}'-scheme '${build_scheme}'-destination generic/platform=ios archive-configuration '${build_config}' Only_active_arch=no-archivepath '${archive_path}Echo "* * Archiving QA * * to the ${archive_path}"Echo ${build_cmd}$build _cmd>./build/build_archive_qa.log | |Exitif[ !- D "${archive_path}"]; Then    Echo  "* * error! ARCHIVE QA FAILED * * please check./build/build_archive_qa.log. "    Exit 2Else    Echo "* * ARCHIVE QA succeeded * * to the ${archive_path}"fi # Export to IPA with QA serverIpa_name="Targetname_qa_adhoc_v${bundleshortversion}_b${bundleversion}_rev${svn_revision} _t${timestamp}. IPA "Ipa_path="./build/"$ipa _nameIpa_cmd=' Xcodebuild 'Ipa_cmd=${ipa_cmd}'-exportarchive-exportformat ipa-archivepath '${archive_path}'-exportpath '${ipa_path}'-exportprovisioningprofile '${provisioningprofile}Echo "* * Exporting QA * * to the ${ipa_path}"Echo ${ipa_cmd}Eval ${ipa_cmd}>./build/Export_ipa_qa.log | |Exitif[ !- F "${ipa_path}"]; Then    Echo  "* * error! Export IPA QA FAILED * * Please check/build/export_ipa_qa.log. "    Exit 2Else    Echo "* * Export IPA QA succeeded * * to the ${ipa_path}"fi 
6. Execute the Script

./build_one_target.sh

A larger project, about 3-5 minutes to complete.
After completion, in the workspace directory under the build directory, there will be the following two main files.
Targetname_qa_20150420_094731.xcarchive
Targetname_qa_adhoc_v2.1.1_b44_rev7849_t20150420_094731.ipa

Xcarchive files are important and can be used with IPA files that are signed by different certificates
The IPA file uses the Adhoc certificate export for the real-machine test distribution. The certificate name is configured in the source code. According to the different product bundle ID, make the corresponding modification, here the name and certificate, only to do the demonstration reference, does not have any commercial significance.

Directory

Use [TOC] to generate a directory:

    • Build Script Description
      • Copy the script file to the workspace directory
      • Open the Terminal tool and enter the workspace directory
      • To execute permissions on a script
      • Modify script parameters The source code already has comments
        • code block
      • Execute script
        • Directory

How to build a archive file using shell scripting and export the signed IPA file.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.