IOS automatic packaging script creation

Create two new files in the project root directory

<? xml version="1.0" encoding="UTF-8"? > <! DOCTYPE plist PUBLIC"- / / / / DTD PLIST Apple 1.0 / / EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>compileBitcode</key>
	<false/>
	<key>destination</key>
	<string>export</string>
	<key>method</key>
	<string>enterprise</string>
	<key>signingStyle</key>
	<string>automatic</string>
	<key>stripSwiftSymbols</key>
	<true/> <key>teamID</key> <string>KV6556Y343</string> <key>thinning</key> <string>&lt; none&gt; </string> </dict> </plist>Copy the code

Method is of type String, which specifies the type of ipA to package. The options are app-store, Enterprise, ad-hoc, and development. The default is development

The xcodebuild.sh file contains parameters to be configured, such as project_name, development_mode, and scheme_name.

There are two types of packaged project files (with or without Cocoapods) : If project and workspace need to be packaged, replace -workspace with -project in Archieve, and replace the path of.xcworkspace with.xcodeproj

# Project name (custom)
project_name=eHRmobile

Debug/Release (custom)
development_mode=Release

#scheme name (custom, usually the same as project name)
scheme_name=eHRmobile

# path to the plist file
exportOptionsPlistPath=./DevelopmentExportOptionsPlist.plist

Export. Ipa file path
exportFilePath=~/Desktop/$project_name-ipa

echo '*** cleaning works ***'
xcodebuild \
clean -configuration ${development_mode} -quiet  || exit 
echo '*** clean up ***'


echo 'compiling project For'${development_mode}
xcodebuild \
archive -workspace ${project_name}.xcworkspace \
-scheme ${scheme_name} \
-configuration ${development_mode} \
-archivePath build/${project_name}.xcarchive -quiet  || exit
echo '*** compiled ***'


echo '*** * packing ***'
xcodebuild -exportArchive -archivePath build/${project_name}.xcarchive \
-configuration ${development_mode} \
-exportPath ${exportFilePath} \
-exportOptionsPlist ${exportOptionsPlistPath} \
-quiet || exit

# delete build package
if [[ -d build ]]; then
    rm -rf build -r
fi

if [ -e $exportFilePath/$scheme_name.ipa ]; then
    echo Ipa file has been exported ***"
    cd ${exportFilePath}
    echo "*** Start uploading.IPA file ***"
    # Upload and distribute applications here
    echo "Ipa file uploaded successfully ***"
else
    echo "*** failed to create. Ipa file ***"
fi
echo '*** * packed ***'
Copy the code

Automatic package (description file and developer certificate need to be configured in the project) Usage mode: Enter./ xcodeBuild. sh in the *. Xcodeproj directory in the terminal to automatically package. If you do not have the execution permission, run chmod +x xcodebuild.sh first

Finally, the packaged IPA folder is generated on the desktop.

Note: 1, if the following error is reported, it indicates that your Xcode installation directory has a problem

xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
Copy the code

Copy xcode to Applications and execute the following command:

xcode-select -switch /Applications/Xcode.app/Contents/Developer
Copy the code

2. If the error is as follows

 The project named "" does not contain a scheme named ""
Copy the code

Choose Scheme > Manage Schemes (from the Product Menu)

Refer to the article