public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) { if (target != BuildTarget.iOS) { return; } if (!LineSDKSettings.GetOrCreateSettings().UseCarthage) { return; } projectRoot = pathToBuiltProject; ShellCommand.AddSearchPath("/usr/local/bin/"); ShellCommand.AddPossibleRubySearchPaths(); if (!CheckCarthage()) { // Carthage is required for install LINE SDK on iOS. return; } PrepareCartfile(); CarthageUpdate(); ConfigureXcodeForCarthage(); AddCarthageCopyPhase(); }
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) { if (target != BuildTarget.iOS) { return; } if (!LineSDKSettings.GetOrCreateSettings().UseCocoaPods) { return; } // Add usual ruby runtime manager path to process. ShellCommand.AddPossibleRubySearchPaths(); var podExisting = ShellCommand.Run("which", "pod"); if (string.IsNullOrEmpty(podExisting)) { var text = @"LINE SDK integrating failed. Building LINE SDK for iOS target requires CocoaPods, but it is not installed. Please run ""sudo gem install cocoapods"" and try again."; UnityEngine.Debug.LogError(text); var clicked = EditorUtility.DisplayDialog("CocoaPods not found", text, "More", "Cancel"); if (clicked) { Application.OpenURL("https://cocoapods.org"); } } var currentDirectory = Directory.GetCurrentDirectory(); var podFileLocation = Path.Combine(pathToBuiltProject, "Podfile"); if (File.Exists(podFileLocation)) { var text = @"A Podfile is already existing under Xcode project root. Skipping copying of LINE SDK's Podfile. Make sure you have setup Podfile correctly if you are using another package also requires CocoaPods."; UnityEngine.Debug.Log(text); } else { #if UNITY_2019_3_OR_NEWER var bundledPodfile = "Assets/LineSDK/Editor/CocoaPods/Podfile_2019_3"; #else var bundledPodfile = "Assets/LineSDK/Editor/CocoaPods/Podfile_2017_4"; #endif var podfilePath = Path.Combine(currentDirectory, bundledPodfile); UnityEngine.Debug.Log(podfilePath); File.Copy(podfilePath, podFileLocation); } Directory.SetCurrentDirectory(pathToBuiltProject); var log = ShellCommand.Run("pod", "install"); UnityEngine.Debug.Log(log); Directory.SetCurrentDirectory(currentDirectory); ConfigureXcodeForCocoaPods(pathToBuiltProject); }
static void CarthageUpdate() { var currentDirectory = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(projectRoot); var log = ShellCommand.Run("carthage", "update --cache-builds"); UnityEngine.Debug.Log(log); Directory.SetCurrentDirectory(currentDirectory); }
static void AddCarthageCopyPhase() { var currentDirectory = Directory.GetCurrentDirectory(); var gemFile = Path.Combine(currentDirectory, "Assets/LineSDK/Editor/Carthage/Gemfile"); var installScript = Path.Combine(currentDirectory, "Assets/LineSDK/Editor/Carthage/copy_carthage_framework.rb"); File.Copy(gemFile, Path.Combine(projectRoot, "Gemfile"), true); File.Copy(installScript, Path.Combine(projectRoot, "copy_carthage_framework.rb"), true); Directory.SetCurrentDirectory(projectRoot); ShellCommand.Run("gem", "install bundler --no-ri --no-rdoc"); ShellCommand.Run("bundle", "install --path vendor/bundle"); ShellCommand.Run("bundle", "exec ruby copy_carthage_framework.rb"); Directory.SetCurrentDirectory(currentDirectory); }
static bool CheckCarthage() { var carthageExisting = ShellCommand.Run("which", "carthage"); if (string.IsNullOrEmpty(carthageExisting)) { var text = @"LINE SDK integrating failed. Building LINE SDK for iOS target requires Carthage, but it is not installed. Please run ""brew install carthage"" and try again."; UnityEngine.Debug.LogError(text); var clicked = EditorUtility.DisplayDialog("Carthage not found", text, "More", "Cancel"); if (clicked) { Application.OpenURL("https://github.com/Carthage/Carthage"); } return(false); } return(true); }