This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let UnityPath = | |
if isUnix then @"/Applications/Unity/Unity.app/Contents/MacOS/Unity" else @"C:\Program Files (x86)\Unity\Editor\Unity.exe" | |
let Unity args = | |
let fullPath = Path.GetFullPath(".") | |
let result = Shell.Exec(UnityPath, "-quit -batchmode -logFile -projectPath \"" + fullPath + "\" " + args) | |
if result < 0 then failwithf "Unity exited with error %d" result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Target "android" (fun () -> | |
Unity "-executeMethod BuildScript.Android" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Environment variables | |
let version = "1.0.0" | |
let build = environVarOrDefault "BUILD_NUMBER" "1" | |
let versionNumber = (version + "." + build) | |
setEnvironVar "VERSION_NUMBER" versionNumber |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BuildScript | |
{ | |
private static readonly string _versionNumber; | |
private static readonly string _buildNumber; | |
static BuildScript() | |
{ | |
_versionNumber = Environment.GetEnvironmentVariable("VERSION_NUMBER"); | |
if (string.IsNullOrEmpty(_versionNumber)) | |
_versionNumber = "1.0.0.0"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Android() | |
{ | |
int versionCode; | |
int.TryParse(_buildNumber, out versionCode); | |
PlayerSettings.Android.bundleVersionCode = versionCode; | |
PlayerSettings.Android.keyaliasName = "YourAlias"; | |
PlayerSettings.Android.keyaliasPass = | |
PlayerSettings.Android.keystorePass = "YourPassword"; | |
PlayerSettings.Android.keystoreName = Path.GetFullPath(@"path\to\your.keystore").Replace('\\', '/'); | |
BuildPipeline.BuildPlayer(GetScenes(), "build/android.apk", BuildTarget.Android, BuildOptions.None); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void CheckDir(string dir) | |
{ | |
if (!Directory.Exists(dir)) | |
Directory.CreateDirectory(dir); | |
} | |
static void iOS() | |
{ | |
CheckDir("Scratch/Xcode"); | |
PlayerSettings.SetPropertyInt("ScriptingBackend", (int)ScriptingImplementation.Mono2x, BuildTargetGroup.iPhone); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void iOS64() | |
{ | |
CheckDir("Scratch/Xcode"); | |
PlayerSettings.SetPropertyInt("ScriptingBackend", (int)ScriptingImplementation.IL2CPP, BuildTargetGroup.iPhone); | |
PlayerSettings.SetPropertyInt("Architecture", (int)iPhoneArchitecture.Universal, BuildTargetGroup.iPhone); | |
BuildPipeline.BuildPlayer(GetScenes(), "Scratch/Xcode", BuildTarget.iPhone, BuildOptions.None); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Exec command args = | |
let result = Shell.Exec(command, args) | |
if result <> 0 then failwithf "%s exited with error %d" command result | |
let Xcode args = | |
Exec "xcodebuild" args |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Variables to change in future | |
let provisioningId = "GUID-HERE" | |
let provisioningName = "YourProfileName" | |
Target "ios-player" (fun () -> | |
Unity "-executeMethod BuildScript.iOS" | |
) | |
Target "ios-archive" (fun () -> | |
DeleteDir "Scratch/Xcode/YourGame.xarchive/" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Target "ios64-player" (fun () -> | |
Unity "-executeMethod BuildScript.iOS64" | |
) | |
Target "ios64" (fun () -> | |
DeleteFile "build/YourGame-64.ipa" | |
CreateDir "build" | |
Xcode ("-exportArchive -archivePath Scratch/Xcode/YourGame.xcarchive -exportPath build/YourGame-64.ipa -exportProvisioningProfile " + provisioningName) | |
) |