From cb82fdf31bfaebfa489df27020d31056fab3118a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 28 May 2016 16:06:53 -0400 Subject: [PATCH] iOS Core project to house common iOS code between app and extension --- bitwarden-mobile.sln | 51 +++++++++++++++ src/iOS.Core/Properties/AssemblyInfo.cs | 36 ++++++++++ src/{iOS => iOS.Core}/Services/SqlService.cs | 2 +- src/iOS.Core/iOS.Core.csproj | 69 ++++++++++++++++++++ src/iOS.Core/packages.config | 5 ++ src/iOS.Extension/ActionViewController.cs | 45 ++++++++++++- src/iOS.Extension/Entitlements.plist | 11 +++- src/iOS.Extension/iOS.Extension.csproj | 38 +++++++++++ src/iOS.Extension/packages.config | 8 +++ src/iOS/AppDelegate.cs | 1 + src/iOS/Entitlements.plist | 11 +++- src/iOS/iOS.csproj | 11 +++- 12 files changed, 281 insertions(+), 7 deletions(-) create mode 100644 src/iOS.Core/Properties/AssemblyInfo.cs rename src/{iOS => iOS.Core}/Services/SqlService.cs (95%) create mode 100644 src/iOS.Core/iOS.Core.csproj create mode 100644 src/iOS.Core/packages.config create mode 100644 src/iOS.Extension/packages.config diff --git a/bitwarden-mobile.sln b/bitwarden-mobile.sln index 00fc1b9bb..2834e5383 100644 --- a/bitwarden-mobile.sln +++ b/bitwarden-mobile.sln @@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Test", "test\App.Test\A EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iOS.Extension", "src\iOS.Extension\iOS.Extension.csproj", "{32F5A2D6-F54D-4DA1-AE26-0A980D48F422}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iOS.Core", "src\iOS.Core\iOS.Core.csproj", "{B2538ADA-B605-4D6F-ACD2-62A409680F84}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Ad-Hoc|Any CPU = Ad-Hoc|Any CPU @@ -277,6 +279,54 @@ Global {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Release|x64.ActiveCfg = Release|iPhone {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Release|x86.ActiveCfg = Release|iPhone + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Ad-Hoc|Any CPU.ActiveCfg = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Ad-Hoc|Any CPU.Build.0 = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Ad-Hoc|ARM.ActiveCfg = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Ad-Hoc|ARM.Build.0 = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Ad-Hoc|iPhone.ActiveCfg = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Ad-Hoc|iPhone.Build.0 = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Ad-Hoc|iPhoneSimulator.ActiveCfg = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Ad-Hoc|iPhoneSimulator.Build.0 = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Ad-Hoc|x64.ActiveCfg = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Ad-Hoc|x64.Build.0 = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Ad-Hoc|x86.ActiveCfg = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Ad-Hoc|x86.Build.0 = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.AppStore|Any CPU.ActiveCfg = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.AppStore|Any CPU.Build.0 = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.AppStore|ARM.ActiveCfg = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.AppStore|ARM.Build.0 = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.AppStore|iPhone.ActiveCfg = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.AppStore|iPhone.Build.0 = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.AppStore|iPhoneSimulator.ActiveCfg = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.AppStore|iPhoneSimulator.Build.0 = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.AppStore|x64.ActiveCfg = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.AppStore|x64.Build.0 = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.AppStore|x86.ActiveCfg = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.AppStore|x86.Build.0 = AppStore|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Debug|ARM.ActiveCfg = Debug|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Debug|ARM.Build.0 = Debug|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Debug|iPhone.Build.0 = Debug|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Debug|x64.ActiveCfg = Debug|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Debug|x64.Build.0 = Debug|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Debug|x86.ActiveCfg = Debug|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Debug|x86.Build.0 = Debug|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Release|Any CPU.Build.0 = Release|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Release|ARM.ActiveCfg = Release|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Release|ARM.Build.0 = Release|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Release|iPhone.ActiveCfg = Release|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Release|iPhone.Build.0 = Release|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Release|x64.ActiveCfg = Release|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Release|x64.Build.0 = Release|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Release|x86.ActiveCfg = Release|Any CPU + {B2538ADA-B605-4D6F-ACD2-62A409680F84}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -287,5 +337,6 @@ Global {B490C5DA-639E-4994-ABD2-54222B8A348E} = {EC730FD9-F623-4B6C-B503-95CDCFBCF277} {A300DCE1-8D10-4267-B96A-CB01AEB7C220} = {0D790714-ECF8-4A83-BE4A-E9C84DD1BB5D} {32F5A2D6-F54D-4DA1-AE26-0A980D48F422} = {EC730FD9-F623-4B6C-B503-95CDCFBCF277} + {B2538ADA-B605-4D6F-ACD2-62A409680F84} = {EC730FD9-F623-4B6C-B503-95CDCFBCF277} EndGlobalSection EndGlobal diff --git a/src/iOS.Core/Properties/AssemblyInfo.cs b/src/iOS.Core/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..358b1032a --- /dev/null +++ b/src/iOS.Core/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("iOS.Core")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("iOS.Core")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b2538ada-b605-4d6f-acd2-62a409680f84")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/iOS/Services/SqlService.cs b/src/iOS.Core/Services/SqlService.cs similarity index 95% rename from src/iOS/Services/SqlService.cs rename to src/iOS.Core/Services/SqlService.cs index 54d8b42f7..c3f2c4f1c 100644 --- a/src/iOS/Services/SqlService.cs +++ b/src/iOS.Core/Services/SqlService.cs @@ -2,7 +2,7 @@ using System.IO; using Bit.App.Abstractions; -namespace Bit.iOS.Services +namespace Bit.iOS.Core.Services { public class SqlService : ISqlService { diff --git a/src/iOS.Core/iOS.Core.csproj b/src/iOS.Core/iOS.Core.csproj new file mode 100644 index 000000000..df18dbea6 --- /dev/null +++ b/src/iOS.Core/iOS.Core.csproj @@ -0,0 +1,69 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {B2538ADA-B605-4D6F-ACD2-62A409680F84} + {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Bit.iOS.Core + Resources + Bit.iOS.Core + + + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + full + true + bin\Release + prompt + 4 + false + + + + ..\..\packages\sqlite-net-pcl.1.1.1\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLite-net.dll + True + + + + + + + + + + + + + + + + + + + {b490c5da-639e-4994-abd2-54222b8a348e} + App + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/src/iOS.Core/packages.config b/src/iOS.Core/packages.config new file mode 100644 index 000000000..bcdf89f57 --- /dev/null +++ b/src/iOS.Core/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/iOS.Extension/ActionViewController.cs b/src/iOS.Extension/ActionViewController.cs index 0c4a20e3b..cb79c549f 100644 --- a/src/iOS.Extension/ActionViewController.cs +++ b/src/iOS.Extension/ActionViewController.cs @@ -1,8 +1,17 @@ using System; +using System.Diagnostics; +using System.Linq; +using Bit.App.Abstractions; +using Bit.App.Repositories; +using Bit.App.Services; +using Bit.iOS.Core.Services; using CoreGraphics; using Foundation; +using Microsoft.Practices.Unity; using MobileCoreServices; using UIKit; +using XLabs.Ioc; +using XLabs.Ioc.Unity; namespace Bit.iOS.Extension { @@ -10,18 +19,52 @@ namespace Bit.iOS.Extension { public ActionViewController() : base("ActionViewController", null) { + if(!Resolver.IsSet) + { + SetIoc(); + } } public string HtmlContent { get; set; } public Uri BaseUri { get; set; } public Uri Url { get; set; } + private void SetIoc() + { + var container = new UnityContainer(); + + container + // Services + .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()) + //.RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()) + //.RegisterType(new ContainerControlledLifetimeManager()) + // Repositories + .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()); + // Other + //.RegisterInstance(CrossSettings.Current, new ContainerControlledLifetimeManager()) + //.RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager()) + //.RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager()) + //.RegisterInstance(CrossFingerprint.Current, new ContainerControlledLifetimeManager()); + + Resolver.SetResolver(new UnityResolver(container)); + } + public override void DidReceiveMemoryWarning() { base.DidReceiveMemoryWarning(); } - public override void LoadView() + public async override void LoadView() { View = new UIView(new CGRect(x: 0.0, y: 0, width: 320.0, height: 200.0)); var button = new UIButton(new CGRect(x: 10.0, y: 50.0, width: 200.0, height: 30.0)); diff --git a/src/iOS.Extension/Entitlements.plist b/src/iOS.Extension/Entitlements.plist index 0c67376eb..0933dd327 100644 --- a/src/iOS.Extension/Entitlements.plist +++ b/src/iOS.Extension/Entitlements.plist @@ -1,5 +1,14 @@ - + + com.apple.security.application-groups + + group.com.bitwarden.vault + + keychain-access-groups + + $(AppIdentifierPrefix)keychain.com.bitwarden.vault + + diff --git a/src/iOS.Extension/iOS.Extension.csproj b/src/iOS.Extension/iOS.Extension.csproj index 113a1917b..ab8738cee 100644 --- a/src/iOS.Extension/iOS.Extension.csproj +++ b/src/iOS.Extension/iOS.Extension.csproj @@ -10,6 +10,8 @@ BitiOSExtension Resources Properties + + true @@ -97,17 +99,53 @@ + + + ..\..\packages\Unity.3.5.1405-prerelease\lib\portable-net45+wp80+win8+wpa81+MonoAndroid10+MonoTouch10\Microsoft.Practices.Unity.dll + True + + + ..\..\packages\sqlite-net-pcl.1.1.1\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLite-net.dll + True + + + ..\..\packages\XLabs.IoC.2.0.5782\lib\portable-net45+netcore45+wp8+MonoAndroid1+MonoTouch1\XLabs.Ioc.dll + True + + + ..\..\packages\XLabs.IoC.Unity.2.0.5782\lib\portable-net45+netcore45+wp8+MonoAndroid1+MonoTouch1\XLabs.Ioc.Unity.dll + True + Always + + + {b490c5da-639e-4994-abd2-54222b8a348e} + App + + + {b2538ada-b605-4d6f-acd2-62a409680f84} + iOS.Core + false + false + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + \ No newline at end of file diff --git a/src/iOS.Extension/packages.config b/src/iOS.Extension/packages.config new file mode 100644 index 000000000..b77ae5c77 --- /dev/null +++ b/src/iOS.Extension/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index 9c242af4d..51e4333be 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -20,6 +20,7 @@ using Plugin.Settings.Abstractions; using System.Diagnostics; using Xamarin.Forms; using Bit.App; +using Bit.iOS.Core.Services; namespace Bit.iOS { diff --git a/src/iOS/Entitlements.plist b/src/iOS/Entitlements.plist index 0c67376eb..0933dd327 100644 --- a/src/iOS/Entitlements.plist +++ b/src/iOS/Entitlements.plist @@ -1,5 +1,14 @@ - + + com.apple.security.application-groups + + group.com.bitwarden.vault + + keychain-access-groups + + $(AppIdentifierPrefix)keychain.com.bitwarden.vault + + diff --git a/src/iOS/iOS.csproj b/src/iOS/iOS.csproj index 38abfe039..03a843e0d 100644 --- a/src/iOS/iOS.csproj +++ b/src/iOS/iOS.csproj @@ -119,7 +119,6 @@ - @@ -238,6 +237,12 @@ {b490c5da-639e-4994-abd2-54222b8a348e} App + + {b2538ada-b605-4d6f-acd2-62a409680f84} + iOS.Core + false + false + {32f5a2d6-f54d-4da1-ae26-0a980d48f422} iOS.Extension @@ -361,9 +366,9 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - + \ No newline at end of file