Ejemplo n.º 1
0
        public string CreateTemporarySatelliteAssembly(string culture = "en-AU")
        {
            var asm_dir = Path.Combine(Path.GetDirectoryName(RootAssembly), culture);

            Directory.CreateDirectory(asm_dir);

            var asm_name = Path.GetFileNameWithoutExtension(RootAssembly) + ".resources.dll";

            // Cheat a bit, by compiling a normal assembly with code instead of creating a resource assembly
            return(MTouch.CompileTestAppLibrary(asm_dir, "class X {}", appName: Path.GetFileNameWithoutExtension(asm_name)));
        }
Ejemplo n.º 2
0
        public void CreateTemporararyServiceExtension(string code = null)
        {
            var testDir = CreateTemporaryDirectory();
            var app     = Path.Combine(testDir, "testApp.appex");

            Directory.CreateDirectory(app);

            if (code == null)
            {
                code = @"using UserNotifications;
[Foundation.Register (""NotificationService"")]
public partial class NotificationService : UNNotificationServiceExtension
{
	protected NotificationService (System.IntPtr handle) : base (handle) {}
}";
            }

            AppPath    = app;
            Executable = MTouch.CompileTestAppLibrary(testDir, code: code, profile: Profile);

            File.WriteAllText(Path.Combine(app, "Info.plist"),
                              @"<?xml version=""1.0"" encoding=""UTF-8""?>
<!DOCTYPE plist PUBLIC ""-//Apple//DTD PLIST 1.0//EN"" ""http://www.apple.com/DTDs/PropertyList-1.0.dtd"">
<plist version=""1.0"">
<dict>
	<key>CFBundleDisplayName</key>
	<string>serviceextension</string>
	<key>CFBundleName</key>
	<string>serviceextension</string>
	<key>CFBundleIdentifier</key>
	<string>com.xamarin.testapp.serviceextension</string>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundlePackageType</key>
	<string>XPC!</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
	<key>CFBundleVersion</key>
	<string>1.0</string>
	<key>MinimumOSVersion</key>
	<string>10.0</string>
	<key>NSExtension</key>
	<dict>
		<key>NSExtensionPointIdentifier</key>
		<string>com.apple.usernotifications.service</string>
		<key>NSExtensionPrincipalClass</key>
		<string>NotificationService</string>
	</dict>
</dict>
</plist>
");
        }
Ejemplo n.º 3
0
        public void CreateTemporaryWatchKitExtension(string code = null)
        {
            var testDir = CreateTemporaryDirectory();
            var app     = Path.Combine(testDir, "testApp.appex");

            Directory.CreateDirectory(app);

            if (code == null)
            {
                code = @"using WatchKit;
public partial class NotificationController : WKUserNotificationInterfaceController
{
	protected NotificationController (System.IntPtr handle) : base (handle) {}
}";
            }

            AppPath    = app;
            Executable = MTouch.CompileTestAppLibrary(testDir, code: code, profile: Profile);

            File.WriteAllText(Path.Combine(app, "Info.plist"), @"<?xml version=""1.0"" encoding=""UTF-8""?>
<!DOCTYPE plist PUBLIC ""-//Apple//DTD PLIST 1.0//EN"" ""http://www.apple.com/DTDs/PropertyList-1.0.dtd"">
<plist version=""1.0"">
<dict>
	<key>CFBundleDisplayName</key>
	<string>testapp</string>
	<key>CFBundleName</key>
	<string>testapp</string>
	<key>CFBundleIdentifier</key>
	<string>com.xamarin.testapp</string>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleVersion</key>
	<string>1.0</string>
	<key>MinimumOSVersion</key>
	<string>2.0</string>
	<key>NSExtension</key>
	<dict>
		<key>NSExtensionAttributes</key>
		<dict>
			<key>WKAppBundleIdentifier</key>
			<string>com.xamarin.testapp.watchkitapp</string>
		</dict>
		<key>NSExtensionPointIdentifier</key>
		<string>com.apple.watchkit</string>
	</dict>
	<key>RemoteInterfacePrincipleClass</key>
	<string>InterfaceController</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
</dict>
</plist>
");
        }
Ejemplo n.º 4
0
        public void CreateTemporaryWatchOSIntentsExtension(string code = null, string appName = "intentsExtension")
        {
            string testDir;

            if (RootAssembly == null)
            {
                testDir = CreateTemporaryDirectory();
            }
            else
            {
                // We're rebuilding an existing executable, so just reuse that directory
                testDir = Path.GetDirectoryName(RootAssembly);
            }
            var app = AppPath ?? Path.Combine(testDir, $"{appName}.appex");

            Directory.CreateDirectory(app);

            if (code == null)
            {
                code = @"
using System;
using Foundation;
using Intents;
using WatchKit;
[Register (""IntentHandler"")]
public class IntentHandler : INExtension, IINRidesharingDomainHandling {
	protected IntentHandler (System.IntPtr handle) : base (handle) {}
	public void HandleRequestRide (INRequestRideIntent intent, Action<INRequestRideIntentResponse> completion)  { }
	public void HandleListRideOptions (INListRideOptionsIntent intent, Action<INListRideOptionsIntentResponse> completion) { }
	public void HandleRideStatus (INGetRideStatusIntent intent, Action<INGetRideStatusIntentResponse> completion) { }
	public void StartSendingUpdates (INGetRideStatusIntent intent, IINGetRideStatusIntentResponseObserver observer) { }
	public void StopSendingUpdates (INGetRideStatusIntent intent) { }
}";
            }

            AppPath      = app;
            Extension    = true;
            RootAssembly = MTouch.CompileTestAppLibrary(testDir, code: code, profile: Profile.watchOS, appName: appName);

            File.WriteAllText(Path.Combine(app, "Info.plist"), $@"<?xml version=""1.0"" encoding=""UTF-8""?>
<!DOCTYPE plist PUBLIC ""-//Apple//DTD PLIST 1.0//EN"" ""http://www.apple.com/DTDs/PropertyList-1.0.dtd"">
<plist version=""1.0"">
<dict>
	<key>BuildMachineOSBuild</key>
	<string>17E199</string>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleDisplayName</key>
	<string>{appName}</string>
	<key>CFBundleExecutable</key>
	<string>{appName}</string>
	<key>CFBundleIdentifier</key>
	<string>com.xamarin.testapp.watchkitapp.watchkitextension.intentswatch</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>{appName}</string>
	<key>CFBundlePackageType</key>
	<string>XPC!</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>1.0</string>
	<key>MinimumOSVersion</key>
	<string>3.2</string>
	<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSAllowsArbitraryLoads</key>
		<true/>
	</dict>
	<key>NSExtension</key>
	<dict>
		<key>NSExtensionAttributes</key>
		<dict>
			<key>IntentsRestrictedWhileLocked</key>
			<array/>
			<key>IntentsSupported</key>
			<array>
				<string>INRequestRideIntent</string>
				<string>INListRideOptionsIntent</string>
				<string>INGetRideStatusIntent</string>
			</array>
		</dict>
		<key>NSExtensionPointIdentifier</key>
		<string>com.apple.intents-service</string>
		<key>NSExtensionPrincipalClass</key>
		<string>IntentHandler</string>
	</dict>
	<key>UIDeviceFamily</key>
	<array>
		<integer>4</integer>
	</array>
</dict>
</plist>
");
        }
Ejemplo n.º 5
0
        public void CreateTemporaryTodayExtension(string code = null, string extraCode = null, IList <string> extraArgs = null, string appName = "testTodayExtension")
        {
            string testDir;

            if (RootAssembly == null)
            {
                testDir = CreateTemporaryDirectory();
            }
            else
            {
                // We're rebuilding an existing executable, so just reuse that
                testDir = Path.GetDirectoryName(RootAssembly);
            }
            var app = AppPath ?? Path.Combine(testDir, $"{appName}.appex");

            Directory.CreateDirectory(app);

            if (code == null)
            {
                code = @"using System;
using Foundation;
using NotificationCenter;
using UIKit;

public partial class TodayViewController : UIViewController, INCWidgetProviding
{
	public TodayViewController (IntPtr handle) : base (handle)
	{
	}

	[Export (""widgetPerformUpdateWithCompletionHandler:"")]
	public void WidgetPerformUpdate (Action<NCUpdateResult> completionHandler)
	{
		completionHandler (NCUpdateResult.NewData);
	}
}
";
            }
            if (extraCode != null)
            {
                code += extraCode;
            }

            AppPath      = app;
            Extension    = true;
            RootAssembly = MTouch.CompileTestAppLibrary(testDir, code: code, profile: Profile, extraArgs: extraArgs, appName: appName);

            var info_plist =             // FIXME: this includes a NSExtensionMainStoryboard key which points to a non-existent storyboard. This won't matter as long as we're only building, and not running the extension.
                             @"<?xml version=""1.0"" encoding=""UTF-8""?>
<!DOCTYPE plist PUBLIC ""-//Apple//DTD PLIST 1.0//EN"" ""http://www.apple.com/DTDs/PropertyList-1.0.dtd"">
<plist version=""1.0"">
<dict>
	<key>CFBundleDisplayName</key>
	<string>todayextension</string>
	<key>CFBundleName</key>
	<string>todayextension</string>
	<key>CFBundleIdentifier</key>
	<string>com.xamarin.testapp.todayextension</string>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundlePackageType</key>
	<string>XPC!</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
	<key>CFBundleVersion</key>
	<string>1.0</string>
	<key>MinimumOSVersion</key>
	<string>10.0</string>
	<key>NSExtension</key>
	<dict>
		<key>NSExtensionPointIdentifier</key>
		<string>widget-extension</string>
		<key>NSExtensionMainStoryboard</key>
		<string>MainInterface</string>
	</dict>
</dict>
</plist>
";
            var plist_path = Path.Combine(app, "Info.plist");

            if (!File.Exists(plist_path) || File.ReadAllText(plist_path) != info_plist)
            {
                File.WriteAllText(plist_path, info_plist);
            }
        }
Ejemplo n.º 6
0
        public void CreateTemporaryServiceExtension(string code = null, string extraCode = null, IList <string> extraArgs = null, string appName = "testServiceExtension")
        {
            string testDir;

            if (RootAssembly == null)
            {
                testDir = CreateTemporaryDirectory();
            }
            else
            {
                // We're rebuilding an existing executable, so just reuse that
                testDir = Path.GetDirectoryName(RootAssembly);
            }
            var app = AppPath ?? Path.Combine(testDir, $"{appName}.appex");

            Directory.CreateDirectory(app);

            if (code == null)
            {
                code = @"using UserNotifications;
[Foundation.Register (""NotificationService"")]
public partial class NotificationService : UNNotificationServiceExtension
{
	protected NotificationService (System.IntPtr handle) : base (handle) {}
}";
            }
            if (extraCode != null)
            {
                code += extraCode;
            }

            AppPath      = app;
            Extension    = true;
            RootAssembly = MTouch.CompileTestAppLibrary(testDir, code: code, profile: Profile, extraArgs: extraArgs, appName: appName);

            var info_plist =
                @"<?xml version=""1.0"" encoding=""UTF-8""?>
<!DOCTYPE plist PUBLIC ""-//Apple//DTD PLIST 1.0//EN"" ""http://www.apple.com/DTDs/PropertyList-1.0.dtd"">
<plist version=""1.0"">
<dict>
	<key>CFBundleDisplayName</key>
	<string>serviceextension</string>
	<key>CFBundleName</key>
	<string>serviceextension</string>
	<key>CFBundleIdentifier</key>
	<string>com.xamarin.testapp.serviceextension</string>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>7.0</string>
	<key>CFBundlePackageType</key>
	<string>XPC!</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
	<key>CFBundleVersion</key>
	<string>1.0</string>
	<key>MinimumOSVersion</key>
	<string>10.0</string>
	<key>NSExtension</key>
	<dict>
		<key>NSExtensionPointIdentifier</key>
		<string>com.apple.usernotifications.service</string>
		<key>NSExtensionPrincipalClass</key>
		<string>NotificationService</string>
	</dict>
</dict>
</plist>
";
            var plist_path = Path.Combine(app, "Info.plist");

            if (!File.Exists(plist_path) || File.ReadAllText(plist_path) != info_plist)
            {
                File.WriteAllText(plist_path, info_plist);
            }
        }