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

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

            proj.AddSourcesBuildPhase(newTargetGuid);
            proj.AddResourcesBuildPhase(newTargetGuid);
            proj.AddFrameworksBuildPhase(newTargetGuid);

            return(newTargetGuid);
        }
示例#2
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);
        }