/// <summary>
        /// Tries to create an instance for modifying the project at the given build path.
        /// Returns "null" if something went wrong.
        /// </summary>
        public static SkillzXCProjEdit LoadXCProj(string projPath)
        {
            TextReader reader = null;
            try
            {
                const string projFilePath = "Unity-iPhone.xcodeproj/project.pbxproj";

                SkillzXCProjEdit edit = new SkillzXCProjEdit();
                edit.ProjectPath = projPath;
                edit.FilePath = Path.Combine(projPath, projFilePath);

                reader = new StreamReader(edit.FilePath);

                string line = reader.ReadLine();
                while (line != null)
                {
                    edit.LinesOfFile.Add(line);
                    line = reader.ReadLine();
                }

                return edit;
            }
            catch (Exception e)
            {
                AlertError("Error opening pbxproj file at '" + projPath + "' for Skillz: " + e.GetType().ToString() + ": " + e.Message);
                return null;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Exemplo n.º 2
0
        public static void OnPostProcessBuild(BuildTarget build, string path)
        {
            //Make sure this build is for iOS.
            //Unity 4 uses 'iPhone' for the enum value; Unity 5 changes it to 'iOS'.
            if (build.ToString() != "iPhone" && build.ToString() != "iOS")
            {
                UnityEngine.Debug.LogWarning("Skillz cannot be set up for a platform other than iOS.");
                return;
            }
            if (Application.platform != RuntimePlatform.OSXEditor)
            {
                UnityEngine.Debug.LogError("Skillz cannot be set up for XCode automatically on a platform other than OSX.");
                return;
            }

            //Get whether this is an append build by checking whether a custom file has already been created.
            //If it is, then nothing needs to be modified.
            string   checkAppendFilePath = Path.Combine(path, checkAppendFileName);
            FileInfo checkAppend         = new FileInfo(checkAppendFilePath);

            if (checkAppend.Exists)
            {
                return;
            }

            checkAppend.Create().Close();

            bool trySetUp = SetUpOrientation(path) && SetUpSDKFiles(path);

            if (!trySetUp)
            {
                //These failures aren't fatal; the developer can do them manually.
                UnityEngine.Debug.LogWarning("Skillz automated steps failed!");
            }

            //Set up XCode project settings.
            SkillzXCProjEdit editProj = SkillzXCProjEdit.LoadXCProj(path);

            if (editProj == null ||
                !editProj.AddLinkerFlags() || !editProj.AddSkillzFiles() || !editProj.AddRunScript() ||
                !editProj.SaveChanges())
            {
                UnityEngine.Debug.LogError("Skillz automated XCode editing failed!");
                return;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Tries to create an instance for modifying the project at the given build path.
        /// Returns "null" if something went wrong.
        /// </summary>
        public static SkillzXCProjEdit LoadXCProj(string projPath)
        {
            TextReader reader = null;

            try
            {
                const string projFilePath = "Unity-iPhone.xcodeproj/project.pbxproj";

                //Modify for Skillz. (Legacy, could be refactored to use PBXProject.
                SkillzXCProjEdit edit = new SkillzXCProjEdit();
                edit.ProjectPath = projPath;
                edit.FilePath    = Path.Combine(projPath, projFilePath);

                //Disable bitcode on export.
//				PBXProject pbxProject = new PBXProject();
//				pbxProject.ReadFromFile(edit.FilePath);
//				string target = pbxProject.TargetGuidByName("Unity-iPhone");
//				pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
//				pbxProject.WriteToFile (edit.FilePath);

                reader = new StreamReader(edit.FilePath);

                string line = reader.ReadLine();
                while (line != null)
                {
                    edit.LinesOfFile.Add(line);
                    line = reader.ReadLine();
                }

                return(edit);
            }
            catch (Exception e)
            {
                AlertError("Error opening pbxproj file at '" + projPath + "' for Skillz: " + e.GetType().ToString() + ": " + e.Message);
                return(null);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Tries to create an instance for modifying the project at the given build path.
        /// Returns "null" if something went wrong.
        /// </summary>
        public static SkillzXCProjEdit LoadXCProj(string projPath)
        {
            TextReader reader = null;

            try
            {
                const string projFilePath = "Unity-iPhone.xcodeproj/project.pbxproj";

                SkillzXCProjEdit edit = new SkillzXCProjEdit();
                edit.ProjectPath = projPath;
                edit.FilePath    = Path.Combine(projPath, projFilePath);

                reader = new StreamReader(edit.FilePath);

                string line = reader.ReadLine();
                while (line != null)
                {
                    edit.LinesOfFile.Add(line);
                    line = reader.ReadLine();
                }

                return(edit);
            }
            catch (Exception e)
            {
                AlertError("Error opening pbxproj file at '" + projPath + "' for Skillz: " + e.GetType().ToString() + ": " + e.Message);
                return(null);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
        public static void OnPostProcessBuild(BuildTarget build, string path)
        {
            //Make sure this build is for iOS.
            //Unity 4 uses 'iPhone' for the enum value; Unity 5 changes it to 'iOS'.
            if (build.ToString() != "iPhone" && build.ToString() != "iOS")
            {
                UnityEngine.Debug.LogWarning("Skillz cannot be set up for a platform other than iOS.");
                return;
            }
            if (Application.platform != RuntimePlatform.OSXEditor)
            {
                UnityEngine.Debug.LogError("Skillz cannot be set up for XCode automatically on a platform other than OSX.");
                return;
            }

            //Get whether this is an append build by checking whether a custom file has already been created.
            //If it is, then nothing needs to be modified.
            string   checkAppendFilePath = Path.Combine(path, checkAppendFileName);
            FileInfo checkAppend         = new FileInfo(checkAppendFilePath);

            if (checkAppend.Exists)
            {
                return;
            }

            checkAppend.Create().Close();

            bool trySetUp = SetUpSDKFiles(path);

            if (!trySetUp)
            {
                //These failures aren't fatal; the developer can do them manually.
                UnityEngine.Debug.LogWarning("Skillz XCode export is missing Skillz Framework.");
            }

            //Set up XCode project settings.
            SkillzXCProjEdit editProj = SkillzXCProjEdit.LoadXCProj(path);

            if (editProj == null ||
                !editProj.AddRunScript() ||
                !editProj.SaveChanges())
            {
                UnityEngine.Debug.LogError("Skillz automated XCode editing failed!");
                return;
            }

            XCProject project = new XCProject(path);

            if (project != null)
            {
                project.AddFile(path + "/Skillz.framework",
                                project.GetGroup("Embed Frameworks"),
                                "SOURCE_ROOT",
                                true,
                                false,
                                true);

                //AddFile should also add FrameworkSearchPaths if required but doesn't
                project.AddFrameworkSearchPaths("$(PROJECT_DIR)");
                project.AddOtherLDFlags("-ObjC -lc++ -lz -lsqlite3 -lxml2 -weak_framework PassKit -framework Skillz");

                //Unity_4 doesn't exist so we check for Unity 5 defines.  Unity 6 is used for futureproofing.
#if !UNITY_5 && !UNITY_6
                project.AddFile(Application.dataPath + "/Skillz/Build/IncludeInXcode/Skillz+Unity.mm");
#endif
                project.Save();
            }
            else
            {
                UnityEngine.Debug.LogError("Skillz automated XCode export failed!");
                return;
            }
        }