Unity打包IOS自動發佈fir.im

打包流程

  1. 配置fir-cli,可以到github查看圍擋
  2. Unity中,設置AutoSign爲false
    • 後邊autosign下會導致shell指定ProvisioningProfile失敗,從而導致簽名失敗
  3. Unity中,導出xcode項目
  4. 使用shell腳本,使用xcodebuildArchive,導出ipa包,並使用fir-cli上傳到fir.im
    • 打包需要指定exportOptionsPlist參數,可以通過xcode的新建一個plist進行填寫

腳本

shell文件

shell文件保存爲xxx.sh。需要用chmod +x xxx.sh附加權限
根據自己的需求,修改下邊的路徑和參數。

!如果unity打包出來的是workspace工程,如GVR項目。需要對Archive部分進行修改

# 項目名
project_name="Unity-iPhone"

# 打包出來的根目錄
build_root="/Users/xx/xxxxxxxx/xxxxx/Build"

# xcodeproj所在的相對目錄
build_dir="xxxxx"

# exportOptionsPlist
export_plist="xxx/xxxx.plist"

# 證書
# 在keychain複製標題即可
code_sign="iPhone Distribution: xxx xx (xxxxxxxxxx)"

# Provisioning Profile uuid
# 建議通過顯示xcodeproj包內容,在其中的project.pbxproj中查找
# PROVISIONING_PROFILE相關字段,找到對應的UUID
ppuuid="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

# fir短地址
fir_shot="xxxx"

# fir開發Token
fir_token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"


# 進入xcode目錄下
cd ${build_root}/${build_dir}

echo "*************"
echo "clean start"
echo "*************"

# 清理打包過程中間產物
xcodebuild clean

echo "*************"
echo "clean start"
echo "*************"

echo "*************"
echo "Build start"
echo "*************"

# archive
xcodebuild archive \
-project ./${project_name}.xcodeproj \
-scheme ${project_name} \
-archivePath ../build_output/${project_name}.xcarchive \
CODE_SIGN_IDENTITY="${code_sign}" \
PROVISIONING_PROFILE="${ppuuid}"

echo "*************"
echo "Build Finished"
echo "*************"

echo "*************"
echo "exportArchive start"
echo "*************"

# export ipa
xcodebuild \
-exportArchive \
-archivePath ../build_output/${project_name}.xcarchive \
-exportPath ../build_output/${project_name} \
-exportOptionsPlist ${export_plist} \
CODE_SIGN_IDENTITY="${code_sign}" \
PROVISIONING_PROFILE="${ppuuid}"

echo "*************"
echo "exportArchive Finished"
echo "*************"

echo "*************"
echo "fir start"
echo "*************"

# 上傳fir
fir p ../build_output/${project_name}/${project_name}.ipa -s ${fir_shot} -Q -v --token=${fir_token}

echo "*************"
echo "fir Finished"
echo "*************"

Export配置plist

xcodebuild -exportArchive命令現在要求必須要有-exportOptionsPlist參數用來設置Export的配置。
下邊是一份ad-hoc的配置表。

<?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>teamID</key>
    <string>xxxxxxxxxx</string>
    <key>method</key>
    <string>ad-hoc</string>
    <key>uploadBitCode</key>
    <false/>
    <key>compileBitcode</key>
    <false/>
</dict>
</plist>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章