Current location - Quotes Website - Signature design - How to compile and generate archive files and export signature IPA files using Shell scripts
How to compile and generate archive files and export signature IPA files using Shell scripts
1. build script description

This Shell script is used in the workspace source code project of build and XCode, and exported as a signable IPA file, which is used to distribute test installation files and files submitted to appstore for review. Realize the configuration management of auxiliary product development and testing.

The following environment is required to use this script.

- Mac OS 10.9+

-XCode 6.0 or later and command line tools

-Used for workspace projects, such as those managed by the Cocoapods dependency library.

-* Configure the development certificate and ad ho certificate (for debugging) and (for publishing).

-Configure the scheme name and build in the source code project.

-Set the certificate name for debugging configuration and publishing configuration.

-Confirm that it can be completely built in Xcode UI interface, and generate Archive and IPA through the environment, and sign it 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 the workspace directory.

4. Grant script execution permission

chmod 777。 /build_one_target.sh

5. Modify the script parameters, with comments in the source code.

Need to modify

Workspace name

Set configuration file

Scheme name

Build configuration

encode block

The code block syntax follows the standard price reduction code.

#! /bin/bash

# Initialize build configuration

# Archive and ipa output path

build_path= "。 /build "

# Workspace name

build _ workspace = " workspace name . xc workspace "

# Project name and path

project_path=$(pwd)

project _ name = $(ls | grep xcode proj | awk-f . xcode proj“{ print $ 1 }”)

# Provisioning profile name

ProvisioningProfile='"XC temporary: com.xxxxx.yyyy "'

# Time stamp of output file name

timeStamp = " $(date+" % Y % M % d _ % H % M % S ")"

Echo "$project_path/$build_workspace"

If [! -d " $ project _ path/$ build _ workspace "]; then

Echo "error! The current path is not an xcode workspace. Please check or do not use the -w option.

Exit 2

The ship does not bear the loading fee.

# Get information. plist

app _ info plist _ path = $ { project _ path }/$ { project _ name }/$ { project _ name }-app store-info . plist

echo ${app_infoplist_path}

# Get the major version

bundleShortVersion = $(/usr/libexec/plist buddy-c " print CFBundleShortVersionString " " $ { app _ info plist _ path } ")

# Get build

bundle version = $(/usr/libexec/plist buddy-c " print cfbundle version " " $ { app _ info plist _ path } ")

# Get svn version

Svn_revision=$(svn information |grep revision: | awk“{ print $2} ")

# `svversion-c | sed's/.*:/'| sed's/[a-z] * $/''s

#svn Info |grep Revision: | awk“{ print $2} "

#workspace_name='*。' xcworkspace '

# ls $ project _ path/$ build _ workspace & amp; & gt/dev/null

#rtnValue=$?

# If [! $ RTN value = 0]; then

# # build _ workspace = $(echo $(basename $ project _ path/$ workspace _ name))

# echo "error! The current path is not an xcode workspace. Please check or do not use the -w option.

# 2 exit

#fi

# Scheme name

build_scheme="schemename "

# buidl configuration. The default is debug | publish.

Build_config= "publish"

# Build from scratch

clean_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 and publish. Archive, generate archive files

archive _ name = " target name _ QA _ $ { timeStamp }。 xcarchive "

Archive path = ". /build/" $ archive name

build_cmd='xcodebuild '

Build _ cmd = $ {build _ cmd} '- Workspace' $ {build _ workspace} '- Scheme' $ {build _ scheme} '- Target Generic/Platform =iOS Archive-Configuration' $ {build _ config}' Only _ Active _ arch = no-archivepath' $ {archive _.

Echo "* * archive QA ** to $ ${ archive _ path}"

echo ${build_cmd}

$ build _ cmd & gt。 /build/build_archive_qa.log || Exit.

If [! -d "$ {archive path}"]; then

Echo "** error! Archive quality assurance failed * * Please check. /build/build_archive_qa.log。

Exit 2

other

Echo "* * Archive QA succeeded * * to $ ${ ARCHIVE _ path}"

The ship does not bear the loading fee.

# Export to ipa using QA server

IPA _ name = " target name _ QA _ ad hoc _ v $ { bundle short version } _ b $ { bundle version } _ rev $ { SVN _ revision } _ t $ { timeStamp }。 International phonetic alphabet "

ipa_path= "。 /build/"$ipa_name

ipa_cmd='xcodebuild '

IPA _ cmd = $ { IPA _ cmd } '-export archive-export format IPA-archive path ' $ { archive _ path } '-export path ' $ { IPA _ path } '-exportProvisioningProfile ' $ { provisioningProfile }

Echo "** Export QA ** to $ ${ IPA _ path} "

echo ${ipa_cmd}

eval $ { ipa _ cmd } & gt。 /build/export_ipa_qa.log || Exit.

If [! -f " $ { IPA _ path } "]; then

Echo "** error! Failed to export IPA QA * * Please check. /build/export_ipa_qa.log。

Exit 2

other

Echo "** Export IPA QA successfully * * to $ ${ IPA _ path} "

The ship does not bear the loading fee.

123456789 10 1 1 12 13 14 15 16 17 18 19202 1 2223242526272829303 132333435363738 39404 14243444546474849505 15253545556575859606 16263646566676869707 1 7273747576777879808 18283848586878889909 19293949596979899 100

Execute script

. /build_one_target.sh

Larger projects take about 3-5 minutes to complete.

When completed, there will be the following two main files in the build directory under the workspace directory.

target name _ QA _ 20 150420 _ 09473 1 . xc archive

target name _ QA _ ad hoc _ v 2. 1. 1 _ b44 _ rev 7849 _ t 20 150420 _ 09473 1 . IPA

The Xcarchive file is very important and can be used for ipa files signed by different certificates.

Ipa file is exported by adhoc certificate and used for real machine testing and distribution. The certificate name is configured in the source code. According to the bundle id of different products, make corresponding modifications. The name and certificate here are for demonstration only and have no commercial significance.