First, let's assume that all the environments and parameters are configured.
General Packaging: Open Unity-> File-> Building Setting-> Click the Build button.
Script Packaging: Do not need to open unity, through the script to complete the manual click the Build button operation.
Jenkins Packaging: You do not need to operate on a computer with a project deployed, or you can perform a packaged script by accessing the Web or by setting up automatic packaging commands. Script Packaging apk
Unity provides a command-line packaged interface, and the MAC packs an Android script as follows:
#!/bin/sh
# Unity App Path
unity_path=/applications/unity/unity.app/contents/macos/unity
# project Path
proj_path=/users/david/proj/unityautobuild/autobuild
echo "============== Unity build APK Begin =========== = = "
$UNITY _path-projectpath $PROJ _path-executemethod batchmode.buildandroid-logfile $PROJ _path/android/ Android.log-batchmode-quit
echo "============== Unity build APK Finish =============="
Among them, Buildandroid is a static method in Batchmode.cs, the most important method is
foreach (Editorbuildsettingsscene scene in Editorbuildsettings.scenes)
{
if (!scene.enabled) continue;
Levels. ADD (Scene.path);
}
string res = Buildpipeline.buildplayer (levels. ToArray (), "testautobuild.apk", Buildtarget.android, Buildoptions.none);
Script Package IOS
The script packages IOS, which is divided into two steps:
The first step is similar to the Android package, but the Xcode project is generated.
The second step is to package the Xcode project into IPA. (Personal free account cannot generate IPA, need to purchase application developer account)
The IOS package script is as follows:
#!/bin/sh
# Unity App Path
unity_path=/applications/unity/unity.app/contents/macos/unity
# project Path
project_path=/users/david/workspace/proj/unityautobuild/autobuild
#IOS打包脚本路径 #
build_ios_path=${ project_path}/ios/ipa_build.sh
#生成的Xcode工程相对路径 #
Xcode_path=ios/xcode
xcode_true_path=${project_ Path}/${xcode_path}
#生成的ipa的相对路径 #
Ipa_path=ipa
#将unity导出成xcode工程 #
Echo ============== Unity Build XCode Project Begin ============== "
$UNITY _path-projectpath $PROJECT _path-executemethod Batchmode.buildios project-$XCODE _path-quit
echo "============== Unity build XCODE project Finish =============="
#开始生成ipa #
echo "============== Unity build IPA Begin =============="
echo $XCODE _true_path
echo $ Ipa_path
echo $BUILD _ios_path
$BUILD _ios_path $XCODE _true_path $IPA _path
echo "============== Unity Build IPA Finish ============== "
ipa_build.sh
#!/bin/sh
# parameter judgment
if [$#!= 2];then
echo "Need two Params:1.path of Project 2.name of IPA file"
exit
elif [! d-];then
echo ' The ' param ' is ' not a ' dictionary.
Exit
Fi
# Engineering path
xcode_project_path=$1
# IPA name
ipa_name=$2
# Build folder path
build_path= ${xcode_project_path}/build
archive_path=${build_path}/archive/autobuild.xcarchive #
Clean Up #
Xcodebuild Clean
# Compile Engineering
CD $xcode _project_path
xcodebuild | | | exit
xcodebuild archive \
- Project ${xcode_project_path}/unity-iphone.xcodeproj \
-scheme unity-iphone \
-configuration "release" \
-archivepath ${archive_path}
xcodebuild-exportarchive \
-exportoptionsplist ${xcode_project_path} /info.plist \
-archivepath ${archive_path} \
-exportpath ${xcode_project_path}
Jenkins Packaging:
The general release is only on a single machine, it is not possible to go to the computer each time to double click on the packaging script, you can use Jenkins to build a packaged environment. To put it simply, Jenkins implemented the package script above through Web Access.
Jenkins is a rich graphical platform for building. Provide scripting command tools (BAT, Shell, Perl, Python, ant, etc.), Code management tools (SVN CVS, etc.) and account rights management, and other thousands of auxiliary plug-ins. Provide the perfect support for the continuous integration of the software workflow.
Benefits of Unity Packaging using Jenkins:
1. Through the web to carry out packaging commands, very convenient
2. Auto-build packaging, such as 12 o'clock every night to pack
3. Packaging results notification can be sent to the mail QQ group, etc., because he has a wealth of plug-ins to support
Jenkins official website https://jenkins.io/, the concrete plan here will not unfold.
If there is a mistake, please note.
Email:dxmdxm1992#gmail.com
blog:http://blog.csdn.net/david_dai_1108