Exemplo n.º 1
0
        public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
        {
            var guids    = AssetDatabase.FindAssets("t:Morpeh.Apple.iOSPostBuildProcessor");
            var settings = new PostBuildProcessingSettings();

            foreach (var guid in guids)
            {
                if (string.IsNullOrEmpty(guid))
                {
                    continue;
                }
                var config = AssetDatabase.LoadAssetAtPath <iOSPostBuildProcessor>(AssetDatabase.GUIDToAssetPath(guid));
                if (config == null)
                {
                    continue;
                }
                settings.AddSettings(config);
            }

            Tools.Process(settings, path);
        }
Exemplo n.º 2
0
        public static void Process(PostBuildProcessingSettings settings, string path)
        {
            var projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
            var project     = new PBXProject();

            project.ReadFromString(File.ReadAllText(projectPath));
            var target_name = project.GetUnityFrameworkTargetGuid();
            var target      = project.TargetGuidByName(target_name);

            var plistPath = Path.Combine(path, "Info.plist");
            var plist     = new PlistDocument();

            plist.ReadFromFile(plistPath);


            AddFrameworks(project, target, settings.frameworks);
            AddProperty(project, target, settings.flags);
            AddProperties(plist, settings.plistKeys);
            foreach (var copyFilesDirectory in settings.copyFilesDirectories)
            {
                CopyAllFilesFromDirectory(copyFilesDirectory, path, project, target);
            }

            foreach (var newDelegateFile in settings.entitlementsFiles)
            {
                AddEntitlements(newDelegateFile, project, path, target, target_name);
            }

            foreach (var newDelegateFile in settings.newDelegateFiles)
            {
                ReplaceDelegate(newDelegateFile, path);
            }

            project.WriteToFile(projectPath);
            File.WriteAllText(projectPath, project.WriteToString());
            File.WriteAllText(plistPath, plist.WriteToString());
        }