OsXシステム上でJenkinsを使用してUnity 3 dのiOSバージョンをfir.に自動的に構築する.im


一、OsXシステムにJenkinsをインストールする
二、端末を開き、XCodeのコマンドラインツールをインストールする
xcode-select --install
三、xcodeprojとfir-cliツールの追加
gem install xcodeproj
gem install fir-cli

四、~ディレクトリにUnityを新規作成する.rbファイルは、エクスポートされたiOSエンジニアリングを修正する必要があるスクリプトです.
releaseTarget.frameworks_build_phase.add_file_referenceはリンクライブラリを追加するため、次のような内容です.
require 'xcodeproj'
project = Xcodeproj::Project.open("Unity-iPhone.xcodeproj");
targets = project.native_targets();
releaseTarget = targets[0];
usrLibPath="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/usr/lib/";
libs = ["libstdc++.tbd", "libstdc++.6.0.9.tbd", "libz.1.2.5.tbd"];
libs.each do |name| 
  r = project.frameworks_group.new_file(usrLibPath+name, :sdk_root);
  releaseTarget.frameworks_build_phase.add_file_reference(r, true);
end
sysPath="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/";
syslibs=["Security.framework", 
"AVFoundation.framework",
"SystemConfiguration.framework", 
"AudioToolbox.framework", 
"CoreLocation.framework", 
"AddressBook.framework",
"CoreTelephony.framework"];
syslibs.each do |name|
 project.frameworks_group.new_file(sysPath+name, :sdk_root);
end
project.save();

五、JenkinsにUnity 3 dの構築を追加する
currtime=`date "+%Y%m%d_%H.%M.%S"`
/Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -projectPath /User/myproj -logFile /tmp/1.log -executeMethod MyBuild.BuildIOS ${currtime}

もしそうならBuildIOSの構築に成功すると、iOSプロジェクトを現在の新しいディレクトリ${currtime}にエクスポートします.
六、ruby unityを実行する.rb,XCode工程の修正
七、XCodeコマンドラインツールArchive及びExport ipaの実行
xcodebuild clean -project ./Unity-iPhone.xcodeproj -configuration Release -alltargets
xcodebuild archive -project ./Unity-iPhone.xcodeproj -scheme Unity-iPhone -archivePath ./build_output/Unity-iPhone.xcarchive
xcodebuild -exportArchive -archivePath ./build_output/Unity-iPhone.xcarchive -exportPath ./build_output/Unity-iPhone -exportFormat ipa -exportProvisioningProfile "XCAd Hoc: com.my.game"

八、fir.をアップロードするim
fir login --token=XXXXXXXX
fir publish ./Unity-iPhone.ipa
そのうちXXXXはfir.im API Token