美文网首页
Unity 打包IOS(自动化构建)

Unity 打包IOS(自动化构建)

作者: fat___lin | 来源:发表于2019-01-29 22:21 被阅读45次

打包流程

  • unity导出xcode工程
  • xcode 生成 archive包
  • 生成ipa包

自动化构建

tool_path=$(cd "$(dirname "$0")"; pwd)

native_project_name=Unity-iPhone
output_path=${tool_path}/output
native_ios_project=${output_path}/${native_project_name}/ios

#clean一下工程
#-project TestAutoPacking.xcodeproj:编译项目名称
#-scheme TestAutoPacking:scheme名称(一般会与你的项目名称相同)
#-configuration Release:(Debug/Release)
xcodebuild clean -project ${native_ios_project}/${native_project_name}/${native_project_name}.xcodeproj -scheme ${native_project_name} -configuration Release

#archive导出.xcarchive文件
#-project TestAutoPacking.xcodeproj:同clean步骤中一样
#-scheme TestAutoPacking:同clean步骤中一样
#-archivePath /dandy/xmeAutoArchive/TestAutoPacking.xcarchive:导出.xcarchive文件的目录以及文件名称
#PROVISIONING_PROFILE=${provisionName}
xcodebuild archive -project ${native_ios_project}/${native_project_name}/${native_project_name}.xcodeproj -configuration Release -scheme ${native_project_name} -archivePath ${output_path}/${native_project_name}.xcarchive 
#生成ipa
#-archivePath /dandy/xmeAutoArchive/TestAutoPacking.xcarchive:刚刚导出的.xcarchive文件的目录
#-exportPath /dandy/xmeAutoArchive/TestAutoPacking:将要导出的ipa文件的目录以及文件名
xcodebuild -exportArchive -archivePath ${output_path}/${native_project_name}.xcarchive -exportPath ${output_path} -exportOptionsPlist ${tool_path}/exportOptions.plist

exportOptions.plist:

  • YOUR BUNDLEID 包名
  • YOUR PROVISIONINGPROFILE 证书
<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">  
<plist version="1.0">  
<dict>  
    <key>compileBitcode</key>  
    <false/>  
    <key>method</key>  
    <string>ad-hoc</string>  
    <key>provisioningProfiles</key>  
    <dict>  
        <key>YOUR BUNDLEID</key>  
        <string>YOUR PROVISIONINGPROFILE</string> 
    </dict>  
</dict>  
</plist> 

备注:

自动化:在没有人或较少人的直接参与下,按照要求,实现预期的目标。
命令行脚本shell(mac/linux)、批处理(windows)
由于命令行处理复杂逻辑相对别扭,大型项目一般使用命令行执行pythonjava等语言实现自动化需求。

相关文章

网友评论

      本文标题:Unity 打包IOS(自动化构建)

      本文链接:https://www.haomeiwen.com/subject/iegxsqtx.html