Beispiel #1
0
        /// <summary>
        /// Creates an app extension.
        /// </summary>
        /// <returns>The GUID of the new target.</returns>
        /// <param name="proj">A project passed as this argument.</param>
        /// <param name="mainTargetGuid">The GUID of the main target to link the app to.</param>
        /// <param name="name">The name of the app extension.</param>
        /// <param name="bundleId">The bundle ID of the app extension. The bundle ID must be
        /// prefixed with the parent app bundle ID.</param>
        /// <param name="infoPlistPath">Path to the app extension Info.plist document.</param>
        public static string AddAppExtension(this PBXProject proj, string mainTargetGuid,
                                             string name, string bundleId, string infoPlistPath)
        {
            string ext           = ".appex";
            var    newTargetGuid = proj.AddTarget(name, ext, "com.apple.product-type.app-extension");

            foreach (var configName in proj.BuildConfigNames())
            {
                var configGuid = proj.BuildConfigByName(newTargetGuid, configName);
                if (configName.Contains("Debug"))
                {
                    SetDefaultAppExtensionDebugBuildFlags(proj, configGuid);
                }
                else
                {
                    SetDefaultAppExtensionReleaseBuildFlags(proj, configGuid);
                }
                proj.SetBuildPropertyForConfig(configGuid, "INFOPLIST_FILE", infoPlistPath);
                proj.SetBuildPropertyForConfig(configGuid, "PRODUCT_BUNDLE_IDENTIFIER", bundleId);
            }

            proj.AddSourcesBuildPhase(newTargetGuid);
            proj.AddResourcesBuildPhase(newTargetGuid);
            proj.AddFrameworksBuildPhase(newTargetGuid);
            string copyFilesPhaseGuid = proj.AddCopyFilesBuildPhase(mainTargetGuid, "Embed App Extensions", "", "13");

            proj.AddFileToBuildSection(mainTargetGuid, copyFilesPhaseGuid, proj.GetTargetProductFileRef(newTargetGuid));

            proj.AddTargetDependency(mainTargetGuid, newTargetGuid);

            return(newTargetGuid);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a watch application.
        /// </summary>
        /// <returns>The GUID of the new target.</returns>
        /// <param name="proj">A project passed as this argument.</param>
        /// <param name="mainTargetGuid">The GUID of the main target to link the watch app to.</param>
        /// <param name="watchExtensionTargetGuid">The GUID of watch extension as returned by [[AddWatchExtension()]].</param>
        /// <param name="name">The name of the watch app. It must the same as the name of the watch extension.</param>
        /// <param name="bundleId">The bundle ID of the watch app.</param>
        /// <param name="infoPlistPath">Path to the watch app Info.plist document.</param>
        public static string AddWatchApp(this PBXProject proj, string mainTargetGuid, string watchExtensionTargetGuid,
                                         string name, string bundleId, string infoPlistPath)
        {
            var newTargetGuid = proj.AddTarget(name, ".app", "com.apple.product-type.application.watchapp2");

            var isbcModuleName = proj.nativeTargets[watchExtensionTargetGuid].name.Replace(" ", "_");

            foreach (var configName in proj.BuildConfigNames())
            {
                var configGuid = proj.BuildConfigByName(newTargetGuid, configName);
                if (configName.Contains("Debug"))
                {
                    SetDefaultWatchAppDebugBuildFlags(proj, configGuid);
                }
                else
                {
                    SetDefaultWatchAppReleaseBuildFlags(proj, configGuid);
                }
                proj.SetBuildPropertyForConfig(configGuid, "PRODUCT_BUNDLE_IDENTIFIER", bundleId);
                proj.SetBuildPropertyForConfig(configGuid, "INFOPLIST_FILE", infoPlistPath);
                proj.SetBuildPropertyForConfig(configGuid, "IBSC_MODULE", isbcModuleName);
            }

            proj.AddResourcesBuildPhase(newTargetGuid);
            string copyFilesGuid = proj.AddCopyFilesBuildPhase(newTargetGuid, "Embed App Extensions", "", "13");

            proj.AddFileToBuildSection(newTargetGuid, copyFilesGuid,
                                       proj.GetTargetProductFileRef(watchExtensionTargetGuid));

            string copyWatchFilesGuid = proj.AddCopyFilesBuildPhase(mainTargetGuid, "Embed Watch Content",
                                                                    "$(CONTENTS_FOLDER_PATH)/Watch", "16");

            proj.AddFileToBuildSection(mainTargetGuid, copyWatchFilesGuid, proj.GetTargetProductFileRef(newTargetGuid));

            proj.AddTargetDependency(newTargetGuid, watchExtensionTargetGuid);
            proj.AddTargetDependency(mainTargetGuid, newTargetGuid);

            return(newTargetGuid);
        }
Beispiel #3
0
        /// <summary>
        /// Configures file for embed framework section for the given native target.
        ///
        /// This function also internally calls <code>proj.AddFileToBuild(targetGuid, fileGuid)</code>
        /// to ensure that the framework is added to the list of linked frameworks.
        ///
        /// If the target has already configured the given file as embedded framework, this function has
        /// no effect.
        ///
        /// A projects containing multiple native targets, a single file or folder reference can be
        /// configured to be built in all, some or none of the targets. The file or folder reference is
        /// added to appropriate build section depending on the file extension.
        /// </summary>
        /// <param name="proj">A project passed as this argument.</param>
        /// <param name="targetGuid">The GUID of the target as returned by [[TargetGuidByName()]].</param>
        /// <param name="fileGuid">The file GUID returned by [[AddFile]] or [[AddFolderReference]].</param>
        public static void AddFileToEmbedFrameworks(this PBXProject proj, string targetGuid, string fileGuid)
        {
            PBXNativeTargetData target = proj.nativeTargets[targetGuid];

            var phaseGuid = proj.AddCopyFilesBuildPhase(targetGuid, "Embed Frameworks", "", "10");
            var phase     = proj.copyFiles[phaseGuid];
            var frameworkEmbedFileData = proj.FindFrameworkByFileGuid(phase, fileGuid);

            if (frameworkEmbedFileData == null)
            {
                frameworkEmbedFileData = PBXBuildFileData.CreateFromFile(fileGuid, false, null);
                proj.BuildFilesAdd(targetGuid, frameworkEmbedFileData);

                phase.files.AddGUID(frameworkEmbedFileData.guid);
            }

            frameworkEmbedFileData.codeSignOnCopy      = true;
            frameworkEmbedFileData.removeHeadersOnCopy = true;
        }