예제 #1
0
        public static void AddOrUpdateForAllBuildProducts(IIgorModule ModuleInst, string ProjectPath, string Key, string Value)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                foreach (KeyValuePair <string, XCBuildConfiguration> CurrentConfig in CurrentProject.buildConfigurations)
                {
                    object        BuildSettingsObj  = CurrentConfig.Value.data["buildSettings"];
                    PBXDictionary BuildSettingsDict = (PBXDictionary)BuildSettingsObj;

                    if (BuildSettingsDict.ContainsKey(Key))
                    {
                        BuildSettingsDict[Key] = Value;

                        IgorDebug.Log(ModuleInst, "Updated KeyValuePair (Key: " + Key + " Value: " + Value + ") to build target GUID " + CurrentConfig.Key);
                    }
                    else
                    {
                        BuildSettingsDict.Add(Key, Value);

                        IgorDebug.Log(ModuleInst, "Added new KeyValuePair (Key: " + Key + " Value: " + Value + ") to build target GUID " + CurrentConfig.Key);
                    }
                }

                CurrentProject.Save();
            }
        }
예제 #2
0
        public virtual bool UpdateAndroidProj()
        {
            List <string> BuildProducts = IgorCore.GetModuleProducts();

            if (IgorAssert.EnsureTrue(this, BuildProducts.Count > 0, "Attempting to update the Android project, but one was not generated in the build phase!"))
            {
                string RootJavaPluginSource = Path.Combine("Assets", Path.Combine("Plugins", Path.Combine("Android", Path.Combine("src", "com"))));
                string RootJavaDest         = Path.Combine(BuildProducts[0], Path.Combine(PlayerSettings.productName, Path.Combine("src", "com")));

                CopyJavaFilesAndReplacePackageName(RootJavaPluginSource, RootJavaDest);

                string ResourcePath = Path.Combine(BuildProducts[0], Path.Combine(PlayerSettings.productName, "res"));
                string AppID        = GetParamOrConfigString(FacebookAndroidAppIDFlag, "Android Facebook ID isn't set, but we've enabled Facebook!  This will probably cause the app to crash on startup!");

                IgorBuildAndroid.SwapStringValueInStringsXML(Path.Combine(Path.Combine(ResourcePath, "values"), "strings.xml"), "fbapp_id", AppID, "FACEBOOKAPPIDTOREPLACE");
                IgorBuildAndroid.SwapStringValueInStringsXML(Path.Combine(Path.Combine(ResourcePath, "values-es"), "strings.xml"), "fbapp_id", AppID, "FACEBOOKAPPIDTOREPLACE");
                IgorBuildAndroid.SwapStringValueInStringsXML(Path.Combine(Path.Combine(ResourcePath, "values-he"), "strings.xml"), "fbapp_id", AppID, "FACEBOOKAPPIDTOREPLACE");
                IgorBuildAndroid.SwapStringValueInStringsXML(Path.Combine(Path.Combine(ResourcePath, "values-iw"), "strings.xml"), "fbapp_id", AppID, "FACEBOOKAPPIDTOREPLACE");

                if (IgorBuildAndroid.RunAndroidCommandLineUtility(this, Path.Combine(BuildProducts[0], "facebook"), "update project --path ."))
                {
                    IgorBuildAndroid.AddNewLibrary("facebook");
                }
            }

            return(true);
        }
예제 #3
0
        public static string GetZipAlignPath(IIgorModule ModuleInst)
        {
            string AndroidSDKPath = GetAndroidSDKPath(ModuleInst);
            string ZipAlignPath   = "";

            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(AndroidSDKPath), "The Android SDK path " + AndroidSDKPath + " doesn't exist!"))
            {
                string BuildToolsPath = Path.Combine(AndroidSDKPath, "build-tools");

                if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(BuildToolsPath), "The Android build tools path " + BuildToolsPath + " doesn't exist!"))
                {
                    List <string> BuildToolVersions = IgorRuntimeUtils.GetListOfFilesAndDirectoriesInDirectory(BuildToolsPath, false, true, false, true, true);

                    foreach (string CurrentVersion in BuildToolVersions)
                    {
                        string ZipAlignVersionPath = Path.Combine(BuildToolsPath, Path.Combine(CurrentVersion, "zipalign"));

                        if (File.Exists(ZipAlignVersionPath))
                        {
                            ZipAlignPath = ZipAlignVersionPath;

                            break;
                        }
                    }

                    IgorAssert.EnsureTrue(ModuleInst, ZipAlignPath != "", "ZipAlign couldn't be found!  Have you downloaded the android build-tools?");
                }
            }

            return(ZipAlignPath);
        }
예제 #4
0
        public static bool RunAnt(IIgorModule ModuleInst, string ProjectDirectory, string Targets)
        {
            string ANT_ROOT   = IgorRuntimeUtils.GetEnvVariable("ANT_ROOT");
            string AntCommand = "";

            string FinalParams = "";

#if UNITY_EDITOR_OSX
            if (ANT_ROOT != "")
            {
                AntCommand = Path.Combine(ANT_ROOT, Path.Combine("bin", "ant"));
            }
            else
            {
                AntCommand = "/usr/bin/ant";
            }

            FinalParams += Targets + " -lib " +
                           Path.Combine(EditorApplication.applicationPath, Path.Combine("Contents", Path.Combine("PlaybackEngines", Path.Combine("AndroidPlayer", Path.Combine("bin", "classes.jar")))));
#else
            AntCommand = "C:\\Windows\\System32\\cmd.exe";

            FinalParams += "/C " + ANT_ROOT + "bin\\ant.bat " + Targets + " -lib " +
                           Path.Combine(EditorApplication.applicationPath, Path.Combine("Data", Path.Combine("PlaybackEngines", Path.Combine("androidplayer", Path.Combine("bin", "classes.jar")))));
#endif // UNITY_EDITOR_OSX

            if (!IgorAssert.EnsureTrue(ModuleInst, File.Exists(AntCommand), "Can't find the Ant executable!  Did you set your ANT_ROOT?"))
            {
                return(false);
            }

//			IgorCore.LogError(ModuleInst, "Ant params are " + FinalParams);

            return(IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, AntCommand, AntCommand, FinalParams, ProjectDirectory, "Running Ant build") == 0);
        }
예제 #5
0
        public static void HandleJobStatus(IgorCore.JobReturnStatus Status)
        {
            if (Status.bDone)
            {
                if (IgorAssert.HasJobFailed())
                {
                    IgorDebug.CoreLogError("Job failed!");
                }
                else
                {
                    IgorDebug.CoreLog("Job's done!");
                }
            }

            if (!Status.bWasStartedManually && (Status.bFailed || Status.bDone))
            {
                if (Status.bFailed)
                {
                    Application.Quit();
                }
                else
                {
                    Application.Quit();
                }
            }
        }
예제 #6
0
파일: IgorUtils.cs 프로젝트: fbizuneh/Igor
        public static void ReplaceStringsInFile(IIgorModule ModuleInst, string FilePath, string OriginalString, string NewString)
        {
            string FullFilePath = FilePath;

            if (!File.Exists(FullFilePath))
            {
                FullFilePath = Path.Combine(Path.GetFullPath("."), FilePath);
            }

            if (File.Exists(FullFilePath))
            {
                File.SetAttributes(FullFilePath, System.IO.FileAttributes.Normal);
            }

            if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(FullFilePath), "Replace string in file failed because " + FullFilePath + " doesn't exist."))
            {
                string FileContents = File.ReadAllText(FilePath);

                FileContents = FileContents.Replace(OriginalString, NewString);

                IgorRuntimeUtils.DeleteFile(FileContents);

                File.WriteAllText(FilePath, FileContents);
            }
        }
예제 #7
0
        public static void AddRequiredDeviceCapability(IIgorModule ModuleInst, string PlistPath, string NewRequiredDeviceCapability)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(PlistPath), "Plist " + PlistPath + " doesn't exist!"))
            {
                FileInfo PlistFileInfo = new FileInfo(PlistPath);

                NSObject PlistRoot = PropertyListParser.Parse(PlistFileInfo);

                if (IgorAssert.EnsureTrue(ModuleInst, PlistRoot != null, "Plist " + PlistPath + " could not be parsed!"))
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(PlistRoot.GetType()), "Plist " + PlistPath + " root object is not a dictionary."))
                    {
                        NSDictionary RootDictionary = (NSDictionary)PlistRoot;

                        if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary != null, "Plist root is not a dictionary."))
                        {
                            if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary.ContainsKey("UIRequiredDeviceCapabilities"), "Can't find UIRequiredDeviceCapabilities in plist."))
                            {
                                NSObject DeviceCapabilities = RootDictionary.Get("UIRequiredDeviceCapabilities");

                                if (IgorAssert.EnsureTrue(ModuleInst, DeviceCapabilities != null, "Plist does not contain UIRequiredDeviceCapabilities."))
                                {
                                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSArray).IsAssignableFrom(DeviceCapabilities.GetType()), "Plist UIRequiredDeviceCapabilities is not an array."))
                                    {
                                        NSArray CapabilitiesArray = (NSArray)DeviceCapabilities;

                                        if (IgorAssert.EnsureTrue(ModuleInst, CapabilitiesArray != null, "UIRequiredDeviceCapabilities is not an array."))
                                        {
                                            if (CapabilitiesArray.ContainsObject(new NSString(NewRequiredDeviceCapability)))
                                            {
                                                IgorDebug.Log(ModuleInst, "UIRequiredDeviceCapabilities already contains " + NewRequiredDeviceCapability);
                                            }
                                            else
                                            {
                                                NSSet NewCapabilitiesSet = new NSSet(CapabilitiesArray.GetArray());

                                                NewCapabilitiesSet.AddObject(new NSString(NewRequiredDeviceCapability));

                                                NSArray NewCapabilitiesArray = new NSArray(NewCapabilitiesSet.AllObjects());

                                                RootDictionary["UIRequiredDeviceCapabilities"] = NewCapabilitiesArray;

                                                IgorRuntimeUtils.DeleteFile(PlistPath);

                                                PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo);

                                                IgorDebug.Log(ModuleInst, NewRequiredDeviceCapability + " added to UIRequiredDeviceCapabilities.");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #8
0
        public static void SortGUIDIntoGroup(IIgorModule ModuleInst, string ProjectPath, string FileGUID, string GroupPath)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                if (IgorAssert.EnsureTrue(ModuleInst, CurrentProject != null, "XCodeProj couldn't be loaded."))
                {
                    bool bFoundGroup = false;

                    foreach (KeyValuePair <string, PBXGroup> CurrentGroup in CurrentProject.groups)
                    {
                        if (CurrentGroup.Value.path == GroupPath)
                        {
                            if (IgorAssert.EnsureTrue(ModuleInst, CurrentGroup.Value.ContainsKey("children"), "XCodeProj PBXGroup " + GroupPath + " doesn't have a children array."))
                            {
                                object GroupChildrenObj = CurrentGroup.Value.data["children"];

                                if (IgorAssert.EnsureTrue(ModuleInst, GroupChildrenObj != null, "XCodeProj PBXGroup " + GroupPath + " has a children key, but it can't be retrieved."))
                                {
                                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(PBXList).IsAssignableFrom(GroupChildrenObj.GetType()), "XCodeProj PBXGroup " + GroupPath + " has a children key, but it can't be cast to PBXList."))
                                    {
                                        PBXList GroupChildrenList = (PBXList)GroupChildrenObj;

                                        if (IgorAssert.EnsureTrue(ModuleInst, GroupChildrenList != null, "XCodeProj casted Children List is null."))
                                        {
                                            if (GroupChildrenList.Contains(FileGUID))
                                            {
                                                IgorDebug.Log(ModuleInst, "FileGUID " + FileGUID + " has already been added to the Group " + CurrentGroup.Key + ".");
                                            }
                                            else
                                            {
                                                GroupChildrenList.Add(FileGUID);

                                                CurrentGroup.Value.data["children"] = GroupChildrenList;

                                                IgorDebug.Log(ModuleInst, "Added the " + FileGUID + " file to the Group " + CurrentGroup.Key + ".");
                                            }
                                        }
                                    }
                                }

                                bFoundGroup = true;

                                break;
                            }
                        }
                    }

                    IgorAssert.EnsureTrue(ModuleInst, bFoundGroup, "Couldn't find a PBXGroup with path " + GroupPath + " in the XCodeProj.");

                    CurrentProject.Save();
                }
            }
        }
예제 #9
0
        public virtual bool Build()
        {
            string BuiltName     = GetBuiltNameForTarget(JobBuildTarget);
            string BuiltBaseName = BuiltName;

            if (BuiltBaseName.Contains("."))
            {
                BuiltBaseName = BuiltName.Substring(0, BuiltBaseName.LastIndexOf('.'));
            }

            string DataFolderName = BuiltBaseName + "_Data";

            if (File.Exists(BuiltName))
            {
                IgorRuntimeUtils.DeleteFile(BuiltName);
            }

            if (Directory.Exists(DataFolderName))
            {
                IgorRuntimeUtils.DeleteDirectory(DataFolderName);
            }

#if !UNITY_4_3
            BuiltName = System.IO.Path.Combine(System.IO.Path.GetFullPath("."), BuiltName);
#endif
            BuildPipeline.BuildPlayer(IgorUtils.GetLevels(), BuiltName, JobBuildTarget, IgorBuildCommon.GetBuildOptions());

            Log("Destination file is: " + BuiltName);

            List <string> BuiltFiles = new List <string>();

            if (Directory.Exists(DataFolderName))
            {
                if (IgorAssert.EnsureTrue(this, File.Exists(BuiltName), "The built file " + BuiltName + " doesn't exist.  Something went wrong during the build step.  Please check the logs!"))
                {
                    BuiltFiles.Add(BuiltName);
                }

                if (IgorAssert.EnsureTrue(this, Directory.Exists(DataFolderName), "The built data directory for the Windows build " + DataFolderName + " doesn't exist.  Something went wrong during the build step.  Please check the logs!"))
                {
                    BuiltFiles.Add(DataFolderName);
                }
            }
            else
            {
                if (IgorAssert.EnsureTrue(this, Directory.Exists(BuiltName), "The built app directory for the Mac build " + BuiltName + " doesn't exist.  Something went wrong during the build step.  Please check the logs!"))
                {
                    BuiltFiles.Add(BuiltName);
                }
            }

            IgorCore.SetNewModuleProducts(BuiltFiles);

            return(true);
        }
예제 #10
0
파일: IgorZip.cs 프로젝트: fbizuneh/Igor
        public virtual bool UnzipProducts()
        {
            List <string> ZipFilename = IgorCore.GetModuleProducts();

            if (IgorAssert.EnsureTrue(this, ZipFilename.Count == 1, "Unzipping expected exactly 1 built product, but we found " + ZipFilename.Count))
            {
                Log("Unzipping file " + ZipFilename[0]);

                UnzipArchiveCrossPlatform(this, ZipFilename[0], Path.GetFullPath("."), true);
            }

            return(true);
        }
예제 #11
0
        public virtual bool UpdateXCodeProj()
        {
            List <string> BuildProducts = IgorCore.GetModuleProducts();

            if (IgorAssert.EnsureTrue(this, BuildProducts.Count > 0, "Attempting to update the XCode project, but one was not generated in the build phase!"))
            {
                string ProjectPath = Path.Combine(BuildProducts[0], "Unity-IPhone.xcodeproj");

                IgorXCodeProjUtils.AddFramework(this, ProjectPath, "StoreKit.framework", TreeEnum.SDKROOT, "System/Library/Frameworks/StoreKit.framework", -1, "wrapper.framework", "StoreKit.framework");
            }

            return(true);
        }
예제 #12
0
        public static bool ExecuteSteps()
        {
            if (IgorAssert.HasJobFailed())
            {
                IgorDebug.CoreLogError("Job failed so we are bailing out early and not finishing the remaining steps!");

                return(false);
            }

            List <StepID> SortedSteps = new List <StepID>(JobSteps.Keys);

            SortedSteps.Sort();

            IgorJobConfig.SetIsRunning(true);

            int StartingPriority        = IgorJobConfig.GetLastPriority();
            int StartingIndexInPriority = IgorJobConfig.GetLastIndexInPriority();

            foreach (StepID CurrentStep in SortedSteps)
            {
                if (CurrentStep.StepPriority > StartingPriority)
                {
                    IgorJobConfig.SetLastPriority(CurrentStep.StepPriority - 1);

                    int LastIndex = 0;

                    List <JobStep> CurrentStepFuncs = JobSteps[CurrentStep];

                    foreach (JobStep CurrentFunction in CurrentStepFuncs)
                    {
                        if (LastIndex > StartingIndexInPriority)
                        {
                            if (CurrentFunction.StepFunction())
                            {
                                IgorJobConfig.SetLastIndexInPriority(LastIndex);
                            }

                            return(false);
                        }

                        ++LastIndex;
                    }

                    StartingIndexInPriority = -1;
                    IgorJobConfig.SetLastIndexInPriority(-1);
                }
            }

            return(true);
        }
예제 #13
0
        public static void AddFrameworkSearchPath(IIgorModule ModuleInst, string ProjectPath, string NewPath)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                CurrentProject.AddFrameworkSearchPaths(NewPath);

                IgorDebug.Log(ModuleInst, "Added framework search path " + NewPath);

                CurrentProject.Save();
            }
        }
예제 #14
0
        public static int RunProcessCrossPlatform(IIgorModule ModuleInst, string OSXCommand, string WindowsCommand, string Parameters, string Directory, string CommandLogDescription, ref string ProcessOutput, ref string ProcessError, bool bUseShell = false)
        {
            int RunProcessExitCode = RunProcessCrossPlatform(OSXCommand, WindowsCommand, Parameters, Directory, ref ProcessOutput, ref ProcessError, bUseShell);

            IgorRuntimeUtils.PlatformNames CurrentPlatform = IgorRuntimeUtils.RuntimeOrEditorGetPlatform();

            if (!IgorAssert.EnsureTrue(ModuleInst, RunProcessExitCode == 0, CommandLogDescription + " failed!\nCommand: " + (
                                           (CurrentPlatform == IgorRuntimeUtils.PlatformNames.Editor_OSX || CurrentPlatform == IgorRuntimeUtils.PlatformNames.Standalone_OSX) ? OSXCommand : WindowsCommand
                                           ) + " " + Parameters + "\nDirectory: " + Directory + "\nOutput:\n" + ProcessOutput + "\n\n\nError:\n" + ProcessError))
            {
                return(RunProcessExitCode);
            }

            IgorDebug.Log(ModuleInst, CommandLogDescription + " succeeded!\nOutput:\n" + ProcessOutput + "\n\n\nError:\n" + ProcessError);

            return(RunProcessExitCode);
        }
예제 #15
0
        public static void SetStringValue(IIgorModule ModuleInst, string PlistPath, string StringKey, string Value)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(PlistPath), "Plist " + PlistPath + " doesn't exist!"))
            {
                FileInfo PlistFileInfo = new FileInfo(PlistPath);

                NSObject PlistRoot = PropertyListParser.Parse(PlistFileInfo);

                if (IgorAssert.EnsureTrue(ModuleInst, PlistRoot != null, "Plist " + PlistPath + " could not be parsed!"))
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(PlistRoot.GetType()), "Plist " + PlistPath + " root object is not a dictionary."))
                    {
                        NSDictionary RootDictionary = (NSDictionary)PlistRoot;

                        if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary != null, "Plist root is not a dictionary."))
                        {
                            if (RootDictionary.ContainsKey(StringKey))
                            {
                                RootDictionary[StringKey] = new NSString(Value);

                                IgorRuntimeUtils.DeleteFile(PlistPath);

                                PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo);

                                IgorDebug.Log(ModuleInst, "Plist key " + StringKey + " updated to " + Value);
                            }
                            else
                            {
                                RootDictionary.Add(StringKey, new NSString(Value));

                                IgorRuntimeUtils.DeleteFile(PlistPath);

                                PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo);

                                IgorDebug.Log(ModuleInst, "Plist key " + StringKey + " added with value of " + Value);
                            }
                        }
                    }
                }
            }
        }
예제 #16
0
        public static string AddNewBuildFile(IIgorModule ModuleInst, string ProjectPath, string FileRefGUID)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                foreach (KeyValuePair <string, PBXBuildFile> CurrentBuildFile in CurrentProject.buildFiles)
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, CurrentBuildFile.Value.ContainsKey("fileRef"), "PBXBuildFile doesn't contain a key for fileRef."))
                    {
                        if (CurrentBuildFile.Value.data["fileRef"] == FileRefGUID)
                        {
                            IgorDebug.Log(ModuleInst, "The file GUID " + FileRefGUID + " already has an associated BuildFile in the XCodeProj.");

                            return(CurrentBuildFile.Value.guid);
                        }
                    }
                }

                foreach (KeyValuePair <string, PBXFileReference> CurrentFileRef in CurrentProject.fileReferences)
                {
                    if (CurrentFileRef.Value.guid == FileRefGUID)
                    {
                        PBXBuildFile NewBuildFile = new PBXBuildFile(CurrentFileRef.Value);

                        CurrentProject.buildFiles.Add(NewBuildFile);

                        IgorDebug.Log(ModuleInst, "BuildFile for FileRefGUID " + FileRefGUID + " has been added to the XCodeProj.");

                        CurrentProject.Save();

                        return(NewBuildFile.guid);
                    }
                }
            }

            return("");
        }
예제 #17
0
        public virtual bool UpdateXCodeProj()
        {
            string FacebookID          = GetParamOrConfigString(FacebookIDFlag, "Your Facebook ID hasn't been set!  Facebook functionality will probably not work correctly.");
            string FacebookDisplayName = GetParamOrConfigString(FacebookDisplayNameFlag, "Your Facebook Display Name hasn't been set!  Facebook functionality will probably not work correctly.");

            List <string> BuildProducts = IgorCore.GetModuleProducts();

            if (IgorAssert.EnsureTrue(this, BuildProducts.Count > 0, "Attempting to update the XCode project, but one was not generated in the build phase!"))
            {
                string ProjectPath = Path.Combine(BuildProducts[0], "Unity-IPhone.xcodeproj");

                string FacebookIntegrationGUID = IgorXCodeProjUtils.AddNewFileReference(this, ProjectPath, "FacebookIntegration.h", TreeEnum.GROUP);

                IgorXCodeProjUtils.SortGUIDIntoGroup(this, ProjectPath, FacebookIntegrationGUID, "Libraries");

                IgorXCodeProjUtils.AddFramework(this, ProjectPath, "FacebookSDK.framework", TreeEnum.GROUP, "Libraries/FacebookSDK.framework", -1, "wrapper.framework", "FacebookSDK.framework");

                IgorXCodeProjUtils.AddFrameworkSearchPath(this, ProjectPath, "$(SRCROOT)/Libraries");

                string PlistPath = Path.Combine(BuildProducts[0], "Info.plist");

                IgorPlistUtils.SetStringValue(this, PlistPath, "FacebookAppID", FacebookID);

                IgorPlistUtils.SetStringValue(this, PlistPath, "FacebookDisplayName", FacebookDisplayName);

                IgorPlistUtils.AddBundleURLType(this, PlistPath, "fb" + FacebookID);

                IgorZip.UnzipArchiveCrossPlatform(this, Path.Combine(Path.GetFullPath("."), Path.Combine("Assets", Path.Combine("Plugins", Path.Combine("iOS", Path.Combine("FacebookSDK", "FacebookSDK.framework.zip"))))), Path.Combine(BuildProducts[0], "Libraries"));

                IgoriOSSourceUtils.AddHeaderToAppControllerSource(this, BuildProducts[0], "../Libraries/FacebookIntegration.h");

                IgoriOSSourceUtils.AddFunctionToAppControllerSource(this, BuildProducts[0], "/* Pre iOS 4.2 support */\n- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url\n{\n\treturn [FBSession.activeSession handleOpenURL:url];\n}\n");

                IgorUtils.ReplaceStringsInFile(this, Path.Combine(BuildProducts[0], Path.Combine("Classes", "UnityAppController.mm")), "AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);\n\treturn YES;", "AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData); return [FBSession.activeSession handleOpenURL:url];");

                IgoriOSSourceUtils.AddSourceToApplicationDidBecomeActive(this, BuildProducts[0], "[FBSession.activeSession handleDidBecomeActive];");
            }

            return(true);
        }
예제 #18
0
        public static string GetStringValue(IIgorModule ModuleInst, string PlistPath, string StringKey)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(PlistPath), "Plist " + PlistPath + " doesn't exist!"))
            {
                FileInfo PlistFileInfo = new FileInfo(PlistPath);

                NSObject PlistRoot = PropertyListParser.Parse(PlistFileInfo);

                if (IgorAssert.EnsureTrue(ModuleInst, PlistRoot != null, "Plist " + PlistPath + " could not be parsed!"))
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(PlistRoot.GetType()), "Plist " + PlistPath + " root object is not a dictionary."))
                    {
                        NSDictionary RootDictionary = (NSDictionary)PlistRoot;

                        if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary != null, "Plist root is not a dictionary."))
                        {
                            if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary.ContainsKey(StringKey), "Plist does not contain " + StringKey + " in root dictionary."))
                            {
                                NSObject StringObj = RootDictionary.ObjectForKey(StringKey);

                                if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSString).IsAssignableFrom(StringObj.GetType()), "Plist key " + StringKey + " is not a string type."))
                                {
                                    NSString StringValue = (NSString)StringObj;

                                    if (IgorAssert.EnsureTrue(ModuleInst, StringValue != null, "Plist key " + StringKey + " could not be cast to an NSString."))
                                    {
                                        return(StringValue.GetContent());
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return("");
        }
예제 #19
0
        public static void EditorHandleJobStatus(IgorCore.JobReturnStatus Status)
        {
            if (Status.bDone)
            {
                if (IgorAssert.HasJobFailed())
                {
                    IgorDebug.CoreLogError("Job failed!");
                }
                else
                {
                    IgorDebug.CoreLog("Job's done!");
                }

                float time = IgorUtils.PlayJobsDoneSound();
                System.Threading.Thread t = new System.Threading.Thread(() => WaitToExit(time));
                t.Start();

                while (t.IsAlive)
                {
                }
            }

            if (Status.bFailed)
            {
                IgorJobConfig.SetIsRunning(false);

                if (!Status.bWasStartedManually)
                {
                    EditorApplication.Exit(-1);
                }
            }

            if (!Status.bWasStartedManually && Status.bDone)
            {
                EditorApplication.Exit(0);
            }
        }
예제 #20
0
        public virtual bool UploadToFTP()
        {
            List <string> BuiltProducts = IgorCore.GetModuleProducts();

            IgorAssert.EnsureTrue(this, BuiltProducts.Count == 1, "This module requires exactly one built file, but we found " + BuiltProducts.Count + " instead.  Please make sure you've enabled a package step prior to this one.");

            string FileToCopy = "";

            if (BuiltProducts.Count > 0)
            {
                FileToCopy = BuiltProducts[0];
            }

            if (IgorAssert.EnsureTrue(this, File.Exists(FileToCopy), "JenkinsFTP upload was looking for the file " + FileToCopy + " to upload, but the file couldn't be found."))
            {
                Cleanup();

                IgorRuntimeUtils.CopyFile(FileToCopy, GetParamOrConfigString(UploadToFTPFlag, "Destination file for JenkinsFTP isn't set so we can't copy it to the right location."));

                Log("File copied to requested location for Jenkins post build FTP uploading.");
            }

            return(true);
        }
예제 #21
0
        public static string AddNewFileReference(IIgorModule ModuleInst, string ProjectPath, string Filename, TreeEnum TreeBase, string Path = "", int FileEncoding = -1, string LastKnownFileType = "", string Name = "")
        {
            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                foreach (KeyValuePair <string, PBXFileReference> CurrentFileRef in CurrentProject.fileReferences)
                {
                    if (CurrentFileRef.Value.name == Filename)
                    {
                        IgorDebug.Log(ModuleInst, "The file " + Filename + " is already referenced in the XCodeProj.");

                        return(CurrentFileRef.Value.guid);
                    }
                }

                PBXFileReference NewFile = new PBXFileReference(Filename, TreeBase);

                if (Path != "")
                {
                    if (NewFile.ContainsKey("path"))
                    {
                        NewFile.Remove("path");
                    }

                    NewFile.Add("path", Path);
                }

                if (FileEncoding != -1)
                {
                    if (NewFile.ContainsKey("fileEncoding"))
                    {
                        NewFile.Remove("fileEncoding");
                    }

                    NewFile.Add("fileEncoding", FileEncoding);
                }

                if (LastKnownFileType != "")
                {
                    if (NewFile.ContainsKey("lastKnownFileType"))
                    {
                        NewFile.Remove("lastKnownFileType");
                    }

                    NewFile.Add("lastKnownFileType", LastKnownFileType);
                }

                if (Name != "")
                {
                    if (NewFile.ContainsKey("name"))
                    {
                        NewFile.Remove("name");
                    }

                    NewFile.Add("name", Name);
                }

                CurrentProject.fileReferences.Add(NewFile);

                IgorDebug.Log(ModuleInst, "File " + Filename + " has been added to the XCodeProj.");

                CurrentProject.Save();

                return(NewFile.guid);
            }

            return("");
        }
예제 #22
0
        public virtual bool CopyToFromSync(bool bToSync)
        {
            string LocalFile = "";

            if (bToSync)
            {
                List <string> BuiltProducts = IgorCore.GetModuleProducts();

                IgorAssert.EnsureTrue(this, BuiltProducts.Count == 1, "This module requires exactly one built file, but we found " + BuiltProducts.Count + " instead.  Please make sure you've enabled a package step prior to this one.");

                if (BuiltProducts.Count > 0)
                {
                    LocalFile = BuiltProducts[0];
                }
            }
            else
            {
                LocalFile = GetParamOrConfigString(CopyToLocalDirFlag, "", Path.GetFullPath("."), false);
            }

            if (IgorAssert.EnsureTrue(this, !bToSync || File.Exists(LocalFile), "BitTorrent Sync copy was told to copy file " + LocalFile + ", but the file doesn't exist!"))
            {
                string SyncFile = "";

                if (IgorJobConfig.IsBoolParamSet(CopyToSyncExpEnabledFlag))
                {
                    SyncFile = GetParamOrConfigString(CopyToSyncExplicitFlag, "BitTorrent Sync copy to sync explicit is enabled, but the path isn't set.");
                }

                if (SyncFile == "" && IgorJobConfig.IsBoolParamSet(CopyToSyncEnvEnabledFlag))
                {
                    string EnvVariable = GetParamOrConfigString(CopyToSyncEnvFlag, "BitTorrent Sync copy to sync based on environment variable is enabled, but the env variable name isn't set.");

                    if (EnvVariable == "")
                    {
                        return(true);
                    }

                    SyncFile = IgorRuntimeUtils.GetEnvVariable(EnvVariable);

                    if (!IgorAssert.EnsureTrue(this, SyncFile != "", "The BitTorrent Sync root path environment variable " + EnvVariable + " isn't set."))
                    {
                        return(true);
                    }
                }

                string SyncFilename = GetParamOrConfigString(CopyToSyncFilenameFlag, (bToSync ?
                                                                                      "BitTorrent Sync copy to sync destination filename isn't set." : "BitTorrent Sync copy from sync source filename isn't set."));

                if (SyncFilename == "")
                {
                    return(true);
                }

                SyncFile = Path.Combine(SyncFile, SyncFilename);

                if (bToSync)
                {
                    if (File.Exists(SyncFile))
                    {
                        IgorRuntimeUtils.DeleteFile(SyncFile);
                    }

                    IgorRuntimeUtils.CopyFile(LocalFile, SyncFile);

                    Log("File " + LocalFile + " copied to requested location " + SyncFile + " for BitTorrent Sync uploading.");
                }
                else
                {
                    LocalFile = Path.Combine(LocalFile, Path.GetFileName(SyncFile));

                    if (File.Exists(LocalFile))
                    {
                        IgorRuntimeUtils.DeleteFile(LocalFile);
                    }

                    IgorRuntimeUtils.CopyFile(SyncFile, LocalFile);

                    Log("File " + SyncFile + " copied from the BitTorrent Sync share to requested location " + LocalFile + ".");

                    List <string> NewProducts = new List <string>();

                    NewProducts.Add(LocalFile);

                    IgorCore.SetNewModuleProducts(NewProducts);
                }
            }

            return(true);
        }
예제 #23
0
        public static void AddFramework(IIgorModule ModuleInst, string ProjectPath, string Filename, TreeEnum TreeBase, string Path = "", int FileEncoding = -1, string LastKnownFileType = "", string Name = "")
        {
            string FrameworkFileRefGUID = AddNewFileReference(ModuleInst, ProjectPath, Filename, TreeBase, Path, FileEncoding, LastKnownFileType, Name);

            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                if (IgorAssert.EnsureTrue(ModuleInst, CurrentProject != null, "XCodeProj couldn't be loaded."))
                {
                    bool bFoundFrameworksGroup = false;

                    foreach (KeyValuePair <string, PBXGroup> CurrentGroup in CurrentProject.groups)
                    {
                        if (CurrentGroup.Value.name == "Frameworks")
                        {
                            if (IgorAssert.EnsureTrue(ModuleInst, CurrentGroup.Value.ContainsKey("children"), "XCodeProj Frameworks PBXGroup doesn't have a children array."))
                            {
                                object FrameworkChildrenObj = CurrentGroup.Value.data["children"];

                                if (IgorAssert.EnsureTrue(ModuleInst, FrameworkChildrenObj != null, "XCodeProj Frameworks PBXGroup has a children key, but it can't be retrieved."))
                                {
                                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(PBXList).IsAssignableFrom(FrameworkChildrenObj.GetType()), "XCodeProj Frameworks PBXGroup has a children key, but it can't be cast to PBXList."))
                                    {
                                        PBXList FrameworkChildrenList = (PBXList)FrameworkChildrenObj;

                                        if (IgorAssert.EnsureTrue(ModuleInst, FrameworkChildrenList != null, "XCodeProj casted Framework Children List is null."))
                                        {
                                            if (FrameworkChildrenList.Contains(FrameworkFileRefGUID))
                                            {
                                                IgorDebug.Log(ModuleInst, "Framework " + Filename + " has already been added to the Framework Group " + CurrentGroup.Key + ".");
                                            }
                                            else
                                            {
                                                FrameworkChildrenList.Add(FrameworkFileRefGUID);

                                                CurrentGroup.Value.data["children"] = FrameworkChildrenList;

                                                IgorDebug.Log(ModuleInst, "Added the " + Filename + " framework to the Framework Group " + CurrentGroup.Key + ".");
                                            }
                                        }
                                    }
                                }

                                bFoundFrameworksGroup = true;

                                break;
                            }
                        }
                    }

                    IgorAssert.EnsureTrue(ModuleInst, bFoundFrameworksGroup, "Couldn't find a Frameworks PBXGroup in the XCodeProj.");

                    CurrentProject.Save();
                }
            }

            string FrameworkBuildFileGUID = AddNewBuildFile(ModuleInst, ProjectPath, FrameworkFileRefGUID);

            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                if (IgorAssert.EnsureTrue(ModuleInst, CurrentProject != null, "XCodeProj couldn't be loaded."))
                {
                    foreach (KeyValuePair <string, PBXFrameworksBuildPhase> CurrentTarget in CurrentProject.frameworkBuildPhases)
                    {
                        if (IgorAssert.EnsureTrue(ModuleInst, CurrentTarget.Value.ContainsKey("files"), "XCodeProj Framework Build Phase doesn't have a files array."))
                        {
                            object FrameworkFilesObj = CurrentTarget.Value.data["files"];

                            if (IgorAssert.EnsureTrue(ModuleInst, FrameworkFilesObj != null, "XCodeProj Framework Build Phase has a files key, but it can't be retrieved."))
                            {
                                if (IgorAssert.EnsureTrue(ModuleInst, typeof(PBXList).IsAssignableFrom(FrameworkFilesObj.GetType()), "XCodeProj Framework Build Phase has a files key, but it can't be cast to PBXList."))
                                {
                                    PBXList FrameworkFilesList = (PBXList)FrameworkFilesObj;

                                    if (IgorAssert.EnsureTrue(ModuleInst, FrameworkFilesList != null, "XCodeProj casted Framework File List is null."))
                                    {
                                        if (FrameworkFilesList.Contains(FrameworkBuildFileGUID))
                                        {
                                            IgorDebug.Log(ModuleInst, "Framework " + Filename + " has already been added to the Framework Build Phase " + CurrentTarget.Key + ".");
                                        }
                                        else
                                        {
                                            FrameworkFilesList.Add(FrameworkBuildFileGUID);

                                            CurrentTarget.Value.data["files"] = FrameworkFilesList;

                                            IgorDebug.Log(ModuleInst, "Added the " + Filename + " framework to the Framework Build Phase " + CurrentTarget.Key + ".");
                                        }
                                    }
                                }
                            }
                        }
                    }

                    CurrentProject.Save();
                }
            }
        }
예제 #24
0
        public virtual bool BuildAndroidProj()
        {
            List <string> BuildProducts = IgorCore.GetModuleProducts();

            if (IgorAssert.EnsureTrue(this, BuildProducts.Count > 0, "Building the Android project, but there were no previous built products."))
            {
                Log("Project should be saved to " + EditorUserBuildSettings.GetBuildLocation(BuildTarget.Android));
                string BuiltProjectDir = Path.Combine(BuildProducts[0], PlayerSettings.productName);
                if (!RunAndroidCommandLineUtility(this, BuiltProjectDir, "update project --path ." + AndroidProjectUpdateAdditionalArgs))
                {
                    return(true);
                }

                string BuildXML = Path.Combine(BuiltProjectDir, "build.xml");
                if (!IgorAssert.EnsureTrue(this, File.Exists(BuildXML), "Can't check " + BuildXML + " for APK name because it doesn't exist."))
                {
                    return(false);
                }

                string BuildXMLFileContents = File.ReadAllText(BuildXML);

                int ProjectNameParamStart = BuildXMLFileContents.IndexOf("<project name=\"") + "<project name=\"".Length;
                int ProjectNameParamEnd   = BuildXMLFileContents.IndexOf("\"", ProjectNameParamStart);

                string APKName = BuildXMLFileContents.Substring(ProjectNameParamStart, ProjectNameParamEnd - ProjectNameParamStart);

                if (!RunAnt(this, BuiltProjectDir, "clean debug"))
                {
                    return(true);
                }

                Log("Debug APK built!");

                string DebugSignedAPK         = Path.Combine(BuiltProjectDir, Path.Combine("bin", APKName + "-debug.apk"));
                string AppropriatelySignedAPK = DebugSignedAPK;

                if (IgorJobConfig.IsBoolParamSet(AndroidResignInReleaseFlag))
                {
                    Log("Re-signing the APK for release.");

                    string RepackageDir = Path.Combine(BuildProducts[0], "Repackage");

                    if (!ResignAPK(this, DebugSignedAPK, RepackageDir, ref AppropriatelySignedAPK,
                                   GetParamOrConfigString(AndroidKeystoreFilenameFlag, "Android Keystore filename isn't set, but you want to re-sign the APK!"),
                                   GetParamOrConfigString(AndroidKeystorePassFlag, "Android Keystore password isn't set, but you want to re-sign the APK!"),
                                   GetParamOrConfigString(AndroidKeyAliasFlag, "Android Key Alias isn't set, but you want to re-sign the APK!"),
                                   GetParamOrConfigString(AndroidKeyAliasPassFlag, "Android Key Alias password isn't set, but you want to re-sign the APK!")))
                    {
                        return(true);
                    }

                    Log("Re-signing the APK succeeded!");
                }

                string FinalBuildProductName = GetBuiltNameForTarget(BuildTarget.Android);

                if (File.Exists(FinalBuildProductName))
                {
                    IgorRuntimeUtils.DeleteFile(FinalBuildProductName);
                }

                IgorRuntimeUtils.CopyFile(AppropriatelySignedAPK, FinalBuildProductName);

                List <string> NewBuildProducts = new List <string>();

                if (IgorAssert.EnsureTrue(this, File.Exists(AppropriatelySignedAPK), "The built APK " + AppropriatelySignedAPK + " doesn't exist.  Something went wrong during the build step.  Please check the logs!"))
                {
                    NewBuildProducts.Add(AppropriatelySignedAPK);
                }

                IgorCore.SetNewModuleProducts(NewBuildProducts);

                Log("APK built and renamed to " + AppropriatelySignedAPK + ".");
            }

            return(true);
        }
예제 #25
0
        public static JobReturnStatus RunJob(bool bFromMenu = false)
        {
            bool bWasStartedManually = false;
            bool bThrewException     = false;
            bool bDone = false;

            try
            {
                if (!IgorJobConfig.GetIsRunning())
                {
                    IgorDebug.CoreLog("Job is starting!");

                    IgorAssert.StartJob();

                    CheckForNamedJobFlag();
                }

                if (IgorJobConfig.GetWasMenuTriggered())
                {
                    bWasStartedManually = true;
                }
                else
                {
                    bWasStartedManually = bFromMenu;

                    IgorJobConfig.SetWasMenuTriggered(bWasStartedManually);
                }

                if (!IgorJobConfig.GetIsRunning() || EnabledModules.Count == 0)
                {
                    RegisterAllModules();
                }

                if (!IgorJobConfig.GetIsRunning() || ActiveModulesForJob.Count == 0)
                {
                    ProcessArgs();
                }

                if (ExecuteSteps())
                {
                    IgorJobConfig.SetIsRunning(false);

                    bDone = true;
                }
            }
            catch (Exception e)
            {
                IgorDebug.CoreLogError("Caught exception while running the job.  Exception is " + (e == null ? "NULL exception!" : e.ToString() +
                                                                                                   (e.InnerException == null ? "\n\nNULL inner exception." : ("\n\nInner: " + e.InnerException.ToString()))));

                bThrewException = true;
            }
            finally
            {
                if (bThrewException || bDone)
                {
                    Cleanup();
                }
            }

            JobReturnStatus NewStatus = new JobReturnStatus();

            NewStatus.bDone               = bDone;
            NewStatus.bFailed             = bThrewException || IgorAssert.HasJobFailed();
            NewStatus.bWasStartedManually = bWasStartedManually;

            return(NewStatus);
        }
예제 #26
0
        public static string GetAndroidSDKPath(IIgorModule ModuleInst)
        {
            IgorAssert.EnsureTrue(ModuleInst, EditorPrefs.HasKey("AndroidSdkRoot"), "You haven't set your Android SDK root yet!  This build will fail!");

            return(EditorPrefs.GetString("AndroidSdkRoot"));
        }
예제 #27
0
        public static void SetDevTeamID(IIgorModule ModuleInst, string ProjectPath, string DevTeamID)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                string ProjectGUID = CurrentProject.project.guid;

                object ProjectSectionObj = CurrentProject.GetObject(ProjectGUID);

                if (IgorAssert.EnsureTrue(ModuleInst, ProjectSectionObj != null, "Can't find Project Section in XCodeProj."))
                {
                    PBXDictionary ProjectSection = (PBXDictionary)ProjectSectionObj;

                    object AttributesSectionObj = ProjectSection["attributes"];

                    if (IgorAssert.EnsureTrue(ModuleInst, AttributesSectionObj != null, "Can't find Attributes Section in Project Section."))
                    {
                        object TargetAttributesObj = ((PBXDictionary)AttributesSectionObj)["TargetAttributes"];

                        if (IgorAssert.EnsureTrue(ModuleInst, TargetAttributesObj != null, "Can't find TargetAttributes Section in Attributes Section."))
                        {
                            PBXDictionary TargetAttributes = (PBXDictionary)TargetAttributesObj;

                            object TargetsObj = ProjectSection["targets"];

                            if (IgorAssert.EnsureTrue(ModuleInst, TargetsObj != null, "Can't find Targets Section in Project Section."))
                            {
                                PBXList TargetsList = ((PBXList)TargetsObj);

                                if (IgorAssert.EnsureTrue(ModuleInst, TargetsList.Count > 0, "No build targets defined in XCodeProj."))
                                {
                                    string PrimaryBuildTargetGUID = (string)(TargetsList[0]);

                                    PBXDictionary PrimaryBuildTargetToDevTeam = new PBXDictionary();
                                    PBXDictionary DevTeamIDDictionary         = new PBXDictionary();

                                    DevTeamIDDictionary.Add("DevelopmentTeam", DevTeamID);

                                    PrimaryBuildTargetToDevTeam.Add(PrimaryBuildTargetGUID, DevTeamIDDictionary);

                                    if (TargetAttributes.ContainsKey(PrimaryBuildTargetGUID))
                                    {
                                        object ExistingPrimaryBuildTargetObj = TargetAttributes[PrimaryBuildTargetGUID];

                                        if (ExistingPrimaryBuildTargetObj != null)
                                        {
                                            PBXDictionary ExistingPrimaryBuildTarget = (PBXDictionary)ExistingPrimaryBuildTargetObj;

                                            if (!ExistingPrimaryBuildTarget.ContainsKey("DevelopmentTeam"))
                                            {
                                                ExistingPrimaryBuildTarget.Append(DevTeamIDDictionary);

                                                IgorDebug.Log(ModuleInst, "Added Development Team to XCodeProj.");
                                            }
                                            else
                                            {
                                                IgorDebug.Log(ModuleInst, "Development Team already set up in XCodeProj.");
                                            }
                                        }
                                        else
                                        {
                                            IgorDebug.LogError(ModuleInst, "Primary build target already has a key in TargetAttributes, but the value stored is invalid.");
                                        }
                                    }
                                    else
                                    {
                                        TargetAttributes.Append(PrimaryBuildTargetToDevTeam);

                                        IgorDebug.Log(ModuleInst, "Added Development Team to XCodeProj.");
                                    }

                                    CurrentProject.Save();
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #28
0
        public static void AddBundleURLType(IIgorModule ModuleInst, string PlistPath, string NewURLScheme)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(PlistPath), "Plist " + PlistPath + " doesn't exist!"))
            {
                FileInfo PlistFileInfo = new FileInfo(PlistPath);

                NSObject PlistRoot = PropertyListParser.Parse(PlistFileInfo);

                if (IgorAssert.EnsureTrue(ModuleInst, PlistRoot != null, "Plist " + PlistPath + " could not be parsed!"))
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(PlistRoot.GetType()), "Plist " + PlistPath + " root object is not a dictionary."))
                    {
                        NSDictionary RootDictionary = (NSDictionary)PlistRoot;

                        if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary != null, "Plist root is not a dictionary."))
                        {
                            NSSet BundleURLTypes = null;

                            if (RootDictionary.ContainsKey("CFBundleURLTypes"))
                            {
                                NSObject BundleURLTypesObj = RootDictionary.Get("CFBundleURLTypes");

                                if (IgorAssert.EnsureTrue(ModuleInst, BundleURLTypesObj != null, "CFBundleURLTypes wasn't found in the root dictionary even though the key exists."))
                                {
                                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSArray).IsAssignableFrom(BundleURLTypesObj.GetType()), "CFBundleURLTypes isn't an NSArray."))
                                    {
                                        BundleURLTypes = new NSSet(((NSArray)BundleURLTypesObj).GetArray());
                                    }
                                }
                            }

                            if (BundleURLTypes == null)
                            {
                                BundleURLTypes = new NSSet();
                            }

                            bool bAlreadyExists = false;

                            foreach (NSObject CurrentURLType in BundleURLTypes)
                            {
                                if (bAlreadyExists)
                                {
                                    break;
                                }

                                if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(CurrentURLType.GetType()), "One of the CFBundleURLTypes isn't an NSDictionary."))
                                {
                                    NSDictionary CurrentURLTypeDict = (NSDictionary)CurrentURLType;

                                    if (IgorAssert.EnsureTrue(ModuleInst, CurrentURLTypeDict != null, "One of the CFBundleURLTypes didn't cast to NSDictionary correctly."))
                                    {
                                        if (CurrentURLTypeDict.ContainsKey("CFBundleURLSchemes"))
                                        {
                                            NSObject CurrentURLSchemesArrayObj = CurrentURLTypeDict.Get("CFBundleURLSchemes");

                                            if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSArray).IsAssignableFrom(CurrentURLSchemesArrayObj.GetType()), "A CFBundleURLSchemes key exists for a given CFBundleURLType, but it's not an NSArray type."))
                                            {
                                                NSArray CurrentURLSchemesArray = (NSArray)CurrentURLSchemesArrayObj;

                                                if (IgorAssert.EnsureTrue(ModuleInst, CurrentURLSchemesArray != null, "The CFBundleURLSchemes object didn't cast to NSDictionary correctly."))
                                                {
                                                    NSSet CurrentURLSchemesSet = new NSSet(CurrentURLSchemesArray.GetArray());

                                                    foreach (NSObject CurrentURLSchemeObj in CurrentURLSchemesSet)
                                                    {
                                                        if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSString).IsAssignableFrom(CurrentURLSchemeObj.GetType()), "One of the CFBundleURLSchemes is not an NSString."))
                                                        {
                                                            NSString CurrentURLScheme = (NSString)CurrentURLSchemeObj;

                                                            if (IgorAssert.EnsureTrue(ModuleInst, CurrentURLScheme != null, "A CFBundleURLScheme entry didn't cast to NSString correctly."))
                                                            {
                                                                if (CurrentURLScheme.GetContent() == NewURLScheme)
                                                                {
                                                                    bAlreadyExists = true;

                                                                    IgorDebug.Log(ModuleInst, "URL scheme " + NewURLScheme + " is already in " + PlistPath);

                                                                    break;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            if (!bAlreadyExists)
                            {
                                NSString NewSchemeString = new NSString(NewURLScheme);

                                NSArray NewSchemeArray = new NSArray(1);

                                NewSchemeArray.SetValue(0, NewSchemeString);

                                NSDictionary NewTypeDictionary = new NSDictionary();

                                NewTypeDictionary.Add("CFBundleURLSchemes", NewSchemeArray);

                                BundleURLTypes.AddObject(NewTypeDictionary);

                                NSArray BundleURLTypesArray = new NSArray(BundleURLTypes.AllObjects());

                                if (RootDictionary.ContainsKey("CFBundleURLTypes"))
                                {
                                    RootDictionary["CFBundleURLTypes"] = BundleURLTypesArray;

                                    IgorDebug.Log(ModuleInst, "Updated CFBundleURLTypes to add " + NewURLScheme + ".");
                                }
                                else
                                {
                                    RootDictionary.Add("CFBundleURLTypes", BundleURLTypesArray);

                                    IgorDebug.Log(ModuleInst, "Added CFBundleURLTypes to add " + NewURLScheme + ".");
                                }

                                IgorRuntimeUtils.DeleteFile(PlistPath);

                                PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo);
                            }
                        }
                    }
                }
            }
        }
예제 #29
0
파일: iOSOTA.cs 프로젝트: fbizuneh/Igor
        public virtual bool CreateWebDeployFiles()
        {
            List <string> BuiltProducts = IgorCore.GetModuleProducts();

            string FileToCopy           = "";
            string RootProjectDirectory = "";
            string WebDeployTempDir     = Path.Combine(Path.GetFullPath("."), "iOSOTATemp");

            if (IgorAssert.EnsureTrue(this, BuiltProducts.Count > 1, "iOS OTA expected at least two built products, the IPA and the iOS XCode project directory."))
            {
                FileToCopy           = BuiltProducts[0];
                RootProjectDirectory = BuiltProducts[1];
            }

            if (IgorAssert.EnsureTrue(this, File.Exists(FileToCopy), "iOS OTA expected the IPA to be at " + FileToCopy + ", but it was not there.") &&
                IgorAssert.EnsureTrue(this, Directory.Exists(RootProjectDirectory), "iOS OTA expected the XCode Project folder to be at " + RootProjectDirectory + ", but it was not there."))
            {
                if (Directory.Exists(WebDeployTempDir))
                {
                    IgorRuntimeUtils.DeleteDirectory(WebDeployTempDir);
                }

                Directory.CreateDirectory(WebDeployTempDir);

                string PlistPath = Path.Combine(RootProjectDirectory, "Info.plist");

                string BundleIdentifier = PlayerSettings.bundleIdentifier;
                string BundleVersion    = IgorPlistUtils.GetStringValue(this, PlistPath, "CFBundleVersion");
                string DisplayName      = IgorPlistUtils.GetStringValue(this, PlistPath, "CFBundleDisplayName");

                string OTAManifestPath = GetParamOrConfigString(OTAPlistNameFlag, "", "Application", false);

                if (!OTAManifestPath.EndsWith(".plist"))
                {
                    OTAManifestPath += ".plist";
                }

                OTAManifestPath = Path.Combine(WebDeployTempDir, OTAManifestPath);

                string FullIconName = Path.Combine(RootProjectDirectory, Path.Combine("Unity-iPhone", Path.Combine("Images.xcassets", Path.Combine("AppIcon.appiconset", "Icon.png"))));

                string IPAName  = Path.GetFileName(FileToCopy);
                string IconName = Path.GetFileName(FullIconName);

                GenerateAndSavePlist(OTAManifestPath, IPAName, IconName, BundleIdentifier, BundleVersion, DisplayName);

                string IPADeployName  = Path.Combine(WebDeployTempDir, IPAName);
                string IconDeployName = Path.Combine(WebDeployTempDir, IconName);

                IgorRuntimeUtils.CopyFile(FileToCopy, IPADeployName);
                IgorRuntimeUtils.CopyFile(FullIconName, IconDeployName);

                List <string> NewBuiltProducts = new List <string>();

                NewBuiltProducts.Add(OTAManifestPath);
                NewBuiltProducts.Add(IPADeployName);
                NewBuiltProducts.Add(IconDeployName);

                IgorCore.SetNewModuleProducts(NewBuiltProducts);

                Log("iOS OTA files successfully generated.");
            }

            return(true);
        }
예제 #30
0
        public virtual bool Build(BuildOptions PlatformSpecificOptions)
        {
            if (!IgorAssert.EnsureTrue(this, GetAndroidSDKPath(this) != "", "Android SDK path is not set!"))
            {
                return(true);
            }

            PlayerSettings.Android.keystorePass = GetParamOrConfigString(AndroidKeystorePassFlag, "Your Android Keystore Password isn't set!  We won't be able to sign your application!");
            PlayerSettings.Android.keyaliasPass = GetParamOrConfigString(AndroidKeyAliasPassFlag, "Your Android Key Alias Password isn't set!  We won't be able to sign your application!");

            if (PlayerSettings.Android.keystorePass == "" || PlayerSettings.Android.keyaliasPass == "")
            {
                return(true);
            }

            FixReadOnlyFilesIn3rdPartyLibs();

            string AndroidProjDirectory = Path.Combine(Path.GetFullPath("."), "Android");

            if (AndroidProjDirectory.Contains(" "))
            {
                AndroidProjDirectory = Path.Combine(Path.GetTempPath() + PlayerSettings.productName, "Android");
            }

            if (Directory.Exists(AndroidProjDirectory))
            {
                IgorRuntimeUtils.DeleteDirectory(AndroidProjDirectory);
            }

            string FullBuiltPath = System.IO.Path.Combine(System.IO.Path.GetFullPath("."), GetBuiltNameForTarget(BuildTarget.Android));

            if (File.Exists(FullBuiltPath))
            {
                IgorRuntimeUtils.DeleteFile(FullBuiltPath);
            }

            // We need to force create the directory before we use it or it will prompt us for a path to build to
            Directory.CreateDirectory(AndroidProjDirectory);

            Log("Android project destination directory is: " + AndroidProjDirectory);

            EditorUserBuildSettings.symlinkLibraries             = true;
            EditorUserBuildSettings.exportAsGoogleAndroidProject = true;

            EditorUserBuildSettings.SetBuildLocation(BuildTarget.Android, AndroidProjDirectory);

            BuildOptions AllOptions = PlatformSpecificOptions | BuildOptions.AcceptExternalModificationsToPlayer;

            AllOptions |= GetExternalBuildOptions(JobBuildTarget);

            BuildPipeline.BuildPlayer(IgorUtils.GetLevels(), AndroidProjDirectory, BuildTarget.Android, AllOptions);

            CopyActivityOverrideSourceFiles(AndroidProjDirectory);

            List <string> BuiltFiles = new List <string>();

            BuiltFiles.Add(AndroidProjDirectory);

            IgorCore.SetNewModuleProducts(BuiltFiles);

            Log("Android Eclipse project has been created.");

            return(true);
        }