Пример #1
0
        void CreateTodayExtensionProject()
        {
            var csproj = inputProject;
            var suffix = Suffix + "-extension";

            csproj.SetProjectTypeGuids("{EE2C853D-36AF-4FDB-B1AD-8E90477E2198};" + LanguageGuid);
            csproj.SetOutputPath("bin\\$(Platform)\\$(Configuration)" + suffix);
            csproj.SetIntermediateOutputPath("obj\\$(Platform)\\$(Configuration)" + suffix);
            csproj.SetImport(IsFSharp ? "$(MSBuildExtensionsPath)\\Xamarin\\iOS\\Xamarin.iOS.AppExtension.FSharp.targets" : "$(MSBuildExtensionsPath)\\Xamarin\\iOS\\Xamarin.iOS.AppExtension.CSharp.targets");
            csproj.FixInfoPListInclude(suffix);
            csproj.SetOutputType("Library");
            csproj.AddAdditionalDefines("XAMCORE_2_0;XAMCORE_3_0;TODAY_EXTENSION");
            var ext = IsFSharp ? "fs" : "cs";

            csproj.AddCompileInclude("TodayExtensionMain." + ext, Path.Combine(Harness.TodayExtensionTemplate, "TodayExtensionMain." + ext), true);
            csproj.AddInterfaceDefinition(Path.Combine(Harness.TodayExtensionTemplate, "TodayView.storyboard").Replace('/', '\\'));
            csproj.SetExtraLinkerDefs("extra-linker-defs" + ExtraLinkerDefsSuffix + ".xml");
            csproj.FixProjectReferences("-today");
            if (MonoNativeInfo != null)
            {
                MonoNativeInfo.AddProjectDefines(csproj);
                csproj.AddAdditionalDefines("MONO_NATIVE_TODAY");
            }

            Harness.Save(csproj, TodayExtensionProjectPath);

            TodayExtensionGuid = csproj.GetProjectGuid();

            XmlDocument info_plist        = new XmlDocument();
            var         target_info_plist = Path.Combine(TargetDirectory, $"Info{suffix}.plist");

            info_plist.LoadWithoutNetworkAccess(Path.Combine(TargetDirectory, "Info.plist"));
            BundleIdentifier = info_plist.GetCFBundleIdentifier() + "-today";
            info_plist.SetCFBundleIdentifier(BundleIdentifier + ".todayextension");
            info_plist.SetMinimumOSVersion(GetMinimumOSVersion("8.0"));
            info_plist.AddPListStringValue("CFBundlePackageType", "XPC!");
            info_plist.SetCFBundleDisplayName(Name);
            info_plist.AddPListKeyValuePair("NSExtension", "dict",
                                            @"
        <key>NSExtensionMainStoryboard</key>
        <string>TodayView</string>
        <key>NSExtensionPointIdentifier</key>
        <string>com.apple.widget-extension</string>
    ");
            Harness.Save(info_plist, target_info_plist);
        }
Пример #2
0
        void CreateTodayExtensionProject()
        {
            var csproj = inputProject;
            var suffix = Suffix + "-extension";

            csproj.SetProjectTypeGuids("{EE2C853D-36AF-4FDB-B1AD-8E90477E2198};" + LanguageGuid);
            csproj.SetOutputPath("bin\\$(Platform)\\$(Configuration)" + suffix);
            csproj.SetIntermediateOutputPath("obj\\$(Platform)\\$(Configuration)" + suffix);
            csproj.SetImport(IsFSharp ? "$(MSBuildExtensionsPath)\\Xamarin\\iOS\\Xamarin.iOS.AppExtension.FSharp.targets" : "$(MSBuildExtensionsPath)\\Xamarin\\iOS\\Xamarin.iOS.AppExtension.CSharp.targets");
            csproj.FixInfoPListInclude(suffix, Path.GetDirectoryName(TemplateProjectPath));
            csproj.SetOutputType("Library");
            csproj.AddAdditionalDefines("XAMCORE_3_0;TODAY_EXTENSION");
            var ext = IsFSharp ? "fs" : "cs";

            // we have diff templates for the bcl tests because they use xunit/nunit and not monotouch nunit.
            csproj.AddCompileInclude("TodayExtensionMain." + ext, Path.Combine(Harness.TodayExtensionTemplate, "TodayExtensionMain." + ext), true);
            csproj.AddInterfaceDefinition(Path.Combine(Harness.TodayExtensionTemplate, "TodayView.storyboard").Replace('/', '\\'));
            csproj.SetExtraLinkerDefs("extra-linker-defs" + ExtraLinkerDefsSuffix + ".xml");
            csproj.FixProjectReferences(Path.Combine(ProjectsDir, GetTargetSpecificDir()), "-today", FixProjectReference);
            csproj.ResolveAllPaths(TemplateProjectPath);
            csproj.Save(TodayExtensionProjectPath, (l, m) => Harness.Log(l, m));

            TodayExtensionGuid = csproj.GetProjectGuid();

            XmlDocument info_plist        = new XmlDocument();
            var         target_info_plist = Path.Combine(TargetDirectory, $"Info{suffix}.plist");

            info_plist.LoadWithoutNetworkAccess(Path.Combine(TargetDirectory, OriginalInfoPListInclude));
            BundleIdentifier = info_plist.GetCFBundleIdentifier() + "-today";
            info_plist.SetCFBundleIdentifier(BundleIdentifier + ".todayextension");
            info_plist.SetMinimumOSVersion(GetMinimumOSVersion("8.0"));
            info_plist.AddPListStringValue("CFBundlePackageType", "XPC!");
            info_plist.SetCFBundleDisplayName(Name);
            info_plist.AddPListKeyValuePair("NSExtension", "dict",
                                            @"
        <key>NSExtensionMainStoryboard</key>
        <string>TodayView</string>
        <key>NSExtensionPointIdentifier</key>
        <string>com.apple.widget-extension</string>
    ");
            info_plist.Save(target_info_plist, (l, m) => Harness.Log(l, m));
        }
Пример #3
0
        void CreateWatchOSExtensionProject()
        {
            var csproj = inputProject;
            var suffix = Suffix + "-extension";

            // Remove unused configurations
            csproj.DeleteConfiguration("iPhone", "Release-bitcode");
            csproj.DeleteConfiguration("iPhone", "Release64");
            csproj.DeleteConfiguration("iPhone", "Debug64");

            csproj.FixArchitectures("i386", "ARMv7k", "iPhone", "Release32");
            csproj.FixArchitectures("i386", "ARMv7k", "iPhone", "Debug32");

            // add Release64_32 and set the correct architecture
            csproj.CloneConfiguration("iPhone", "Release", "Release64_32");
            csproj.FixArchitectures("i386", "ARM64_32", "iPhone", "Release64_32");

            // add Debug64_32 and set the correct architecture
            csproj.CloneConfiguration("iPhone", "Debug", "Debug64_32");
            csproj.FixArchitectures("i386", "ARM64_32", "iPhone", "Debug64_32");

            csproj.FixArchitectures(SimulatorArchitectures, DeviceArchitectures, "iPhoneSimulator", "Debug");
            csproj.FixArchitectures(SimulatorArchitectures, DeviceArchitectures, "iPhoneSimulator", "Release");
            csproj.FixArchitectures(SimulatorArchitectures, DeviceArchitectures, "iPhone", "Debug");
            csproj.FixArchitectures(SimulatorArchitectures, DeviceArchitectures, "iPhone", "Release");

            csproj.SetProjectTypeGuids("{1E2E965C-F6D2-49ED-B86E-418A60C69EEF};" + LanguageGuid);
            csproj.SetOutputPath("bin\\$(Platform)\\$(Configuration)" + suffix);
            csproj.SetIntermediateOutputPath("obj\\$(Platform)\\$(Configuration)" + suffix);
            csproj.RemoveTargetFrameworkIdentifier();
            csproj.SetPlatformAssembly("Xamarin.WatchOS");
            csproj.SetImport(IsFSharp ? "$(MSBuildExtensionsPath)\\Xamarin\\WatchOS\\Xamarin.WatchOS.AppExtension.FSharp.targets" : "$(MSBuildExtensionsPath)\\Xamarin\\WatchOS\\Xamarin.WatchOS.AppExtension.CSharp.targets");
            csproj.FixProjectReferences("-watchos");

            csproj.FixInfoPListInclude(suffix);
            csproj.SetOutputType("Library");
            csproj.AddAdditionalDefines("BITCODE", "iPhone", "Release");
            csproj.AddAdditionalDefines("XAMCORE_2_0;XAMCORE_3_0;FEATURE_NO_BSD_SOCKETS;MONOTOUCH_WATCH;");
            csproj.RemoveReferences("OpenTK-1.0");
            var ext = IsFSharp ? "fs" : "cs";

            csproj.AddCompileInclude("InterfaceController." + ext, Path.Combine(Harness.WatchOSExtensionTemplate, "InterfaceController." + ext));
            csproj.SetExtraLinkerDefs("extra-linker-defs" + ExtraLinkerDefsSuffix + ".xml");
            csproj.SetMtouchUseBitcode(true, "iPhone", "Release");
            csproj.SetMtouchUseLlvm(true, "iPhone", "Release");

            if (MonoNativeInfo != null)
            {
                csproj.AddAdditionalDefines("MONO_NATIVE_WATCH");
                MonoNativeHelper.AddProjectDefines(csproj, MonoNativeInfo.Flavor);
                MonoNativeHelper.RemoveSymlinkMode(csproj);
            }

            // Not linking a watch extensions requires passing -Os to the native compiler.
            // https://github.com/mono/mono/issues/9867
            var configurations = new string [] { "Debug", "Debug32", "Debug64_32", "Release", "Release32", "Release64_32" };

            foreach (var c in configurations)
            {
                var flags = "-fembed-bitcode-marker";
                if (csproj.GetMtouchLink("iPhone", c) == "None")
                {
                    flags += " -Os";
                }

                csproj.AddExtraMtouchArgs($"--gcc_flags='{flags}'", "iPhone", c);
            }

            Harness.Save(csproj, WatchOSExtensionProjectPath);

            WatchOSExtensionGuid = csproj.GetProjectGuid();

            XmlDocument info_plist        = new XmlDocument();
            var         target_info_plist = Path.Combine(TargetDirectory, $"Info{Suffix}-extension.plist");

            info_plist.LoadWithoutNetworkAccess(Path.Combine(TargetDirectory, "Info.plist"));
            BundleIdentifier = info_plist.GetCFBundleIdentifier() + "_watch";
            if (BundleIdentifier.Length >= 58)
            {
                BundleIdentifier = BundleIdentifier.Substring(0, 57);                  // If the main app's bundle id is 58 characters (or sometimes more), then the watch extension crashes at launch. radar #29847128.
            }
            info_plist.SetCFBundleIdentifier(BundleIdentifier + ".watchkitapp.watchkitextension");
            info_plist.SetMinimumOSVersion(GetMinimumOSVersion("2.0"));
            info_plist.SetUIDeviceFamily(4);
            info_plist.AddPListStringValue("RemoteInterfacePrincipleClass", "InterfaceController");
            info_plist.AddPListKeyValuePair("NSExtension", "dict", string.Format(
                                                @"
    <key>NSExtensionAttributes</key>
    <dict>
    <key>WKAppBundleIdentifier</key>
    <string>{0}.watchkitapp</string>
    </dict>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.watchkit</string>
", BundleIdentifier));
            if (!info_plist.ContainsKey("NSAppTransportSecurity"))
            {
                info_plist.AddPListKeyValuePair("NSAppTransportSecurity", "dict",
                                                @"
		  <key>NSAllowsArbitraryLoads</key>
		  <true/>
		"        );
            }
            Harness.Save(info_plist, target_info_plist);
        }
Пример #4
0
        void CreateWatchOSExtensionProject()
        {
            var csproj = inputProject;
            var suffix = "-watchos-extension";

            csproj.SetProjectTypeGuids("{1E2E965C-F6D2-49ED-B86E-418A60C69EEF};" + LanguageGuid);
            csproj.SetOutputPath("bin\\$(Platform)\\$(Configuration)" + suffix);
            csproj.SetIntermediateOutputPath("obj\\$(Platform)\\$(Configuration)" + suffix);
            csproj.RemoveTargetFrameworkIdentifier();
            csproj.SetPlatformAssembly("Xamarin.WatchOS");
            csproj.SetImport(IsFSharp ? "$(MSBuildExtensionsPath)\\Xamarin\\WatchOS\\Xamarin.WatchOS.AppExtension.FSharp.targets" : "$(MSBuildExtensionsPath)\\Xamarin\\WatchOS\\Xamarin.WatchOS.AppExtension.CSharp.targets");
            csproj.FixProjectReferences("-watchos");
            csproj.FixArchitectures("i386", "ARMv7k");
            csproj.FixInfoPListInclude(suffix);
            csproj.SetOutputType("Library");
            csproj.AddAdditionalDefines("BITCODE", "iPhone", "Release");
            csproj.AddAdditionalDefines("XAMCORE_2_0;XAMCORE_3_0;FEATURE_NO_BSD_SOCKETS");
            csproj.RemoveReferences("OpenTK-1.0");
            var ext = IsFSharp ? "fs" : "cs";

            csproj.AddCompileInclude("InterfaceController." + ext, Path.Combine(Harness.WatchOSExtensionTemplate, "InterfaceController." + ext));
            csproj.SetExtraLinkerDefs("extra-linker-defs" + Suffix + ".xml");
            csproj.SetMtouchUseBitcode(true, "iPhone", "Release");
            csproj.SetMtouchUseLlvm(true, "iPhone", "Release");

            Harness.Save(csproj, WatchOSExtensionProjectPath);

            WatchOSExtensionGuid = csproj.GetProjectGuid();

            XmlDocument info_plist        = new XmlDocument();
            var         target_info_plist = Path.Combine(TargetDirectory, "Info-watchos-extension.plist");

            info_plist.LoadWithoutNetworkAccess(Path.Combine(TargetDirectory, "Info.plist"));
            BundleIdentifier = info_plist.GetCFBundleIdentifier() + "-watch";
            if (BundleIdentifier.Length >= 58)
            {
                BundleIdentifier = BundleIdentifier.Substring(0, 57);                  // If the main app's bundle id is 58 characters (or sometimes more), then the watch extension crashes at launch. radar #29847128.
            }
            info_plist.SetCFBundleIdentifier(BundleIdentifier + ".watchkitapp.watchkitextension");
            info_plist.SetMinimumOSVersion("2.0");
            info_plist.SetUIDeviceFamily(4);
            info_plist.AddPListStringValue("RemoteInterfacePrincipleClass", "InterfaceController");
            info_plist.AddPListKeyValuePair("NSExtension", "dict", string.Format(
                                                @"
    <key>NSExtensionAttributes</key>
    <dict>
    <key>WKAppBundleIdentifier</key>
    <string>{0}.watchkitapp</string>
    </dict>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.watchkit</string>
", BundleIdentifier));
            if (!info_plist.ContainsKey("NSAppTransportSecurity"))
            {
                info_plist.AddPListKeyValuePair("NSAppTransportSecurity", "dict",
                                                @"
		  <key>NSAllowsArbitraryLoads</key>
		  <true/>
		"        );
            }
            Harness.Save(info_plist, target_info_plist);
        }