locked
AppleDevice is missing in Xamarin.Forms.Labs 1.2.1-pre2 RRS feed

  • Question

  • User83890 posted

    I have an iOS + PCL solution and I need to get XForms.Labs Geolocator working in my PCL but right now all calls to Resolver.Resolve() return NULL. So I'm guessing that XLabs isn't getting initialized properly. The XLabs Wiki says that a container must be setup before using XLabs services.

    To test this I created new solution (unified API) with Xamarin Studio and used NuGet to install XForms 1.3.1.6296 and XForms.Labs 1.2.1-pre2. Next I copied the container setup code from XLabs Wiki into my AppDelegate class however this will not compile because AppleDevice cannot be resolved.

    How can I fix this?

    Here is my AppDelegate.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    
    using Foundation;
    using UIKit;
    using Xamarin.Forms.Labs.Services;
    using Xamarin.Forms.Labs;
    
    namespace UnifiedTest.iOS
    {
        [Register ("AppDelegate")]
        public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
        {
            public override bool FinishedLaunching (UIApplication app, NSDictionary options)
            {
                global::Xamarin.Forms.Forms.Init ();
    
                SetIoc ();
    
                LoadApplication (new App ());
    
                return base.FinishedLaunching (app, options);
            }
    
            private void SetIoc()
            {
                var container = new SimpleContainer ();
                container.Register<IDevice> (t => AppleDevice.CurrentDevice);
                container.Register<IDisplay> (t => t.Resolve<IDevice> ().Display);
                container.Register<INetwork>(t=> t.Resolve<IDevice>().Network);
    
                Resolver.SetResolver (container.GetResolver ());
            }
        }
    }
    
    Wednesday, January 14, 2015 2:56 AM

All replies

  • User12403 posted

    Labs NuGet packages do not currently support 1.3.1 (unified API). You would need to get the latest master from GitHub: https://github.com/XLabs/Xamarin-Forms-Labs

    Wednesday, January 14, 2015 4:11 AM
  • User83890 posted

    Oh, that's makes sense. Thanks for the help.

    Wednesday, January 14, 2015 4:21 AM
  • User85984 posted

    Hmmm .. not for me :-(

    How do I include this master into my own project. How much do I need to include? Currently I'm only using the camera integration.

    Thanks in advance Per

    Wednesday, January 14, 2015 7:45 AM
  • User12403 posted

    @PerReitzel?, the camera feature is in Platform so you would need to include XLabs.Core + XLabs.Platform and then XLabs.Platform.[iOS][Droid][WP8].

    Wednesday, January 14, 2015 1:25 PM
  • User85984 posted

    Ok .. but just to get this right. So I just download your Whole master source and build the Xlabs.Core and Xlabs.Platform (+Ios, Droid and WP8) bits .. and then I include the dll's from the build folder as references in my project?

    At least this is what I've been trying but when I try to run my project/app and try to get the MediaPicker through the IMediaPicker interface (mediaPicker = DependencyService.Get();) I get a null back from that call .. both on WP and Droid

    Wednesday, January 14, 2015 1:40 PM
  • User85984 posted

    mediaPicker = DependencyService.Get(); .. of course

    Wednesday, January 14, 2015 1:42 PM
  • User85984 posted

    sorry .. when I post this reply the IMediaPicker between the two < and > is deleted ..

    Wednesday, January 14, 2015 1:43 PM
  • User12403 posted

    Add XLabs.IoC as well and set the media picker there. Platform now doesn't have Xamarin.Forms reference so it is not registered with DependencyService. Alternatively you can register it yourself with DepedencyService in the platform project(s).

    Wednesday, January 14, 2015 6:44 PM
  • User57783 posted

    Hi! For any one who needs help. Below how I solved the problem.

    1- Below code In the AppDelegate side:

    private void SetIoc () { var resolverContainer = new XLabs.Ioc.SimpleContainer (); resolverContainer.Register< XLabs.Platform.Device.IDevice> (t => AppleDevice.CurrentDevice) .Register<XLabs.Platform.Device.IDisplay> (t => t.Resolve<XLabs.Platform.Device.IDevice> ().Display) .Register<XLabs.Ioc.IDependencyContainer> (t => resolverContainer); XLabs.Ioc.Resolver.SetResolver (resolverContainer.GetResolver ()); }

    2- Below Code in the implementation side (The shared library)

    var device = XLabs.Ioc.Resolver.Resolve<XLabs.Platform.Device.IDevice>(); mediaPicker = DependencyService.Get<XLabs.Platform.Services.Media.IMediaPicker> () ?? device.MediaPicker;

    PS! This solution is only for the MediaPicker

    Thursday, January 15, 2015 11:47 AM
  • User85984 posted

    Thanks a lot Sami & Ahmad .. and now it works Again :-)

    Sami .. when do you expect that we can download the first XLab pre .. and even better the final v. 2?

    Tuesday, January 20, 2015 6:55 AM
  • User85984 posted

    .. and then still a problem with Android :-(

    Everything seems to be intialized well .. but when I access the camera I get the following runtime error:

    Calling startActivity() from outside of an Activity context requires the FLAGACTIVITYNEW_TASK flag. Is this really what you want?

    I've been trying to set this flag different Places in my code but without luck. Where and how do I solve this?

    Thanks in advance Per

    Tuesday, January 20, 2015 9:37 AM
  • User2496 posted

    In the new packages the user should call DependecyService.Register if he wants to register a Service from XLabs to be used with Xamarin Forms.

    Tuesday, January 20, 2015 11:42 AM
  • User85984 posted

    I'm a bit newbie to this .. sorry. Can you tell me where a set this? To get my 'mediaPicker' I have this code:

            var device = Resolver.Resolve<IDevice>();
            mediaPicker = DependencyService.Get<IMediaPicker>() ?? device.MediaPicker;
    

    Thanks in advance Per

    Tuesday, January 20, 2015 12:14 PM
  • User12403 posted

    @PerReitzel?, XLabs2.0-pre6 is in Nuget now.

    Here is the Wiki on getting IOC setup: https://github.com/XLabs/Xamarin-Forms-Labs/wiki/IOC

    Tuesday, January 20, 2015 3:11 PM
  • User85984 posted

    Thanks Sami.

    I'm still having problem with my Android project. It works perfectly fine with WP and Ios but when running on Android I get this runtime error:

    Calling startActivity() from outside of an Activity context requires the FLAGACTIVITYNEW_TASK flag

    What I did was to first remove the references to the XLab dll's I build from the shared source. Then I install the Xlabs2.0-pre7

    From OnCreate I call the following:

        private void SetIoc()
        {
            var resolverContainer = new XLabs.Ioc.SimpleContainer();
    
            var app = new XFormsAppDroid();
    
            app.Init(this);
    
            resolverContainer.Register<IDevice>(t => AndroidDevice.CurrentDevice)
                .Register<IDisplay>(t => t.Resolve<IDevice>().Display)
                .Register<IDependencyContainer>(resolverContainer)
                .Register<XLabs.Platform.Mvvm.IXFormsApp>(app);
    
            Resolver.SetResolver(resolverContainer.GetResolver());
        }
    

    From where I have the implementation to the camera I setup the interface like this:

            var device = Resolver.Resolve<IDevice>();
            mediaPicker = DependencyService.Get<IMediaPicker>() ?? device.MediaPicker;
    

    I can see when debugging that the mediaPicker is created after the above .. but I still get the Runtime error. Any idea what it can be?

    /per

    Tuesday, January 20, 2015 6:46 PM
  • User2496 posted

    You will need to register the service now using DependecyService.Register() on your platform project.

    Tuesday, January 20, 2015 6:54 PM
  • User12403 posted

    It's a bug on the media picker due to the refactoring. I will push in a fix.

    Tuesday, January 20, 2015 7:09 PM
  • User85984 posted

    Hi Sami,

    Thanks for helping on this!

    I just installed the Pre8 version of XLabs packages (I guess that this version include your bug fix?) .. but now I have a problem getting the Mvvm from XLabs.Platform .. it is not included as I see it?

    /per

    Wednesday, January 21, 2015 8:16 AM
  • User85984 posted

    @SKall? .. when I try to download your lates XLabs source and build the references, and include the same dll's as come with the Nuget packages I installed - then everything works perfectly .. and now also with camera on my Android :smile:

    Thanks

    Wednesday, January 21, 2015 10:02 AM
  • User59013 posted

    When will Unified API support be available via Nuget?

    Wednesday, January 21, 2015 1:22 PM
  • User12403 posted

    @XamarinSnob? the pre-release is available now. The name of the packages has changed and you should search for XLabs instead of Xamarin.Forms.Labs. To get the XF add-ons install XLabs.Forms package (on iOS you probably want to add XLabs.Ioc as well since it isn't an automatic dependency like on Droid & WP).

    Wednesday, January 21, 2015 2:35 PM
  • User46691 posted

    @SKall, just a FYI, I've been able to use the pre-release nuget with one exception. There isn't a nuget that includes the XLabs.Platform.DLL. I've had to manually reference. When I do, it all seems to be working. I'll report back if I find other issues.

    Wednesday, January 21, 2015 3:20 PM
  • User59013 posted

    What am I missing? I downloaded the latest XLab packages but now getting:

    "The name AppleDevice does not exist in current context".

    It's supposed to be part of the XLabs.Platforms.Device namespace but doesn't seem to be there.

    Does anybody have any ideas?

    Thursday, January 22, 2015 2:02 PM
  • User12403 posted

    Nuget package configuration issues... Update to the latest and everything should be fixed now.

    Thursday, January 22, 2015 4:13 PM
  • User59013 posted

    Still having the same problem.

    Steps taken: 1) removed all references to Xamarin.Forms.Labs 2) removed all references to Xamarin.Forms 3) Installed "XLabs - Platform 2.0.0-pre91" which very conveniently includes all dependancies ;) 4) updated namespacing all over the show and some minor refactoring

    But still I'm getting a build error (The name AppleDevice does not exist in current context) on AppleDevide.CurrentDevice on the resolver initialization here:

    var resolverContainer = new SimpleContainer();
    
    resolverContainer.Register<IDevice>(t => AppleDevice.CurrentDevice)
                                .Register<IDisplay>(t => t.Resolve<IDevice>().Display)
                                .Register<IDependencyContainer>(resolverContainer);
    

    Thanks for the help so far @SKall

    Friday, January 23, 2015 7:46 AM
  • User51906 posted

    @XamarinSnob? I had the same problem that IDevice was missing. You can fix that when you add the XLabs.Platform.dll to the Android and iOS project. To make things clear and XLabs working you need these dll's in your platform projects.

    XLabs.Core.dll
    XLabs.Forms.dll
    XLabs.Forms.Droid.dll or XLabs.Forms.iOS.dll
    XLabs.IoC.dll
    XLabs.Platform.dll <-- this one was missing
    XLabs.Platform.Droid.dll or XLabs.Platform.iOS.dll
    XLabs.Serialization.dll
    

    //Edit: Ok, I tried the pre91 and it installs all dependencies correctly. Does your AppDelegate inherit from XFormsApplicationDelegate?

    Friday, January 23, 2015 8:04 AM
  • User59013 posted

    Ahh ha! Thanks. That seems to have got me over the hurdle. I have a different issue now:

    I'm getting a strange "Could not load type 'Android.OS.BaseBundle' from assembly 'XLabs.Platform.Droid'" when I try to invoke the SelectPhotoAsync method on the mediaPicker. I'm creating the media picker as suggested above:

    var device = XLabs.Ioc.Resolver.Resolve<XLabs.Platform.Device.IDevice>();
    IMediaPicker mediaPicker = DependencyService.Get<XLabs.Platform.Services.Media.IMediaPicker>() ?? device.MediaPicker;
    

    Am I missing an assembly somewhere again?

    Friday, January 23, 2015 11:49 AM
  • User59013 posted

    @RaphaelSchindler? your solution worked, but now having issues with the media picker on android

    Friday, January 23, 2015 12:29 PM
  • User59013 posted

    I can't shake this bug:

    System.TypeLoadException: Could not load type 'Android.OS.BaseBundle' from assembly 'XLabs.Platform.Droid'

    Any help will be hugely appreciated ;)

    Friday, January 23, 2015 1:35 PM
  • User51906 posted

    @XamarinSnob? Take a look at this. https://github.com/XLabs/Xamarin-Forms-Labs/issues/584 And try this in your MainActivity.cs / AppDelegate

    .Register<IMediaPicker>(t => t.Resolve<MediaPicker>())
    

    and in the shared code you use

    var mediaPicker = Resolver.Resolve<IMediaPicker>();

    this should solve your problem.

    Monday, January 26, 2015 6:13 AM
  • User77850 posted

    Just tested with XLabs - Forms (v2.0.0-pre91) from NuGet which works fine with: container.Register<IDevice>(t => AppleDevice.CurrentDevice);

    Tuesday, January 27, 2015 10:58 AM
  • User65389 posted

    @SKall:

    I have a few dumb questions to XLabs…
    I want to have a look to xLabs.
    Therefore I have downloaded the whole Xamarin-forms-master.zip and extract it in a folder.
    From: https://github.com/XLabs/Xamarin-Forms-Labs

    I then should be able to deploy the sample-projects (XLabs.Sample.Droid / .iOS and .WP) to the devices?
    - Correct?

    I am not able to create the app.
    Various error-messages, like:
    Unexpected error - Please file a bug report at http://bugzilla.xamarin.com. Reason: System.IO.FileNotFoundException: Could not load assembly 'XLabs.Platform.Droid
    Unexpected error - Please file a bug report at http://bugzilla.xamarin.com. Reason: System.IO.FileNotFoundException: Could not load assembly 'XLabs.Forms.Droid,
    This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ....\packages\sqlite-net-wp8.3.8.5\build\windowsphone8\sqlite-net-wp8.props. M:\SW\VS_2013\Xamarin\Xlabs\Xamarin-Forms-Labs-

    => While sqlite-net-wp8.3.8.4 is installed and I’m not able to install sqlite-net-wp8.3.8.5 from nugget.-prompt (conflict with “portable-net45+win8+wp80+Monodroid10+Xamarinios10+Monotouch10”)

    And further some errors like:
    The Metafile 'M:\SW\VS_2013\Xamarin\Xlabs\Xamarin-Forms-Labs-master\build\XLabs.Platform.dll' was not found Further for: 'Xlabs\Xamarin-Forms-Labs-master\build\XLabs.Ioc.dll', 'Xlabs\Xamarin-Forms-Labs-master\build\XLabs.Forms.dll', 'Xlabs\Xamarin-Forms-Labs-master\build\XLabs.Forms.Charting.dll', 'Xlabs\Xamarin-Forms-Labs-master\build\XLabs.Caching.dll' and 'Xlabs\Xamarin-Forms-Labs-master\build\debug\XLabs.Core.dll'

    How to resolve these errors - do I missing something?

    I have an existing app with various existing pages.
    If I want to include XLabs in my project, e.g. for using the Popup, query the device-properties:
    Do I have to change all my existing pages or will I be able to “mix the code” (leave some pages as they are and add new pages based on XLabs)?

    Thanks for an answer and … sorry for the dumb questions…

    Tuesday, January 27, 2015 12:37 PM
  • User51906 posted

    For the errors I can't help you, but with your questions.

    Currently there are only 2 pages from XLabs. The ExtendedMasterDetailPage and the ModelPage. Most of the time you add controls from XLabs to your pages. Like Checkbox or CarouselView and you can add them to your pages as you want. Thats for the controls.

    For the Services you have to change theMainApplication.cs and AppDelegate.cs as described in this thread.

    Tuesday, January 27, 2015 1:49 PM
  • User65389 posted

    @RaphaelSchindler?:
    Thanks for your Feedback.
    So.. if I understand you correct, I don't have to change the app-logic and the existing pages and can easily add some controls to the existing pages. So I don't have to fear side effects...

    I hope, somebody can help me further with the errors..

    Tuesday, January 27, 2015 4:20 PM
  • User51906 posted

    @FredyWenger? No you don't have to change the logic of anything. If you just want controls, add as you want. However the services you must register them.

    Wednesday, January 28, 2015 6:06 AM
  • User65389 posted

    @Skall:
    Can you help me with the problems to the installation (see my posing above)?

    Thursday, January 29, 2015 9:41 AM
  • User38273 posted

    Hi Guys, after following everything that was said on this thread and others I'm still unable to make Xlabs or his older brother Xamarin.Forms.Labs 1.2.1-pre2 work on my Xamarin Forms 1.3.1.6296 PCL Project. Reading the wiki on Xlabs it all seemed very easy before the new Xamarin Forms 1.3.1 but now things seem to have changed a bit... If anyone could walk me through getting Xlabs working with the latest stable release of Xamarin Forms which I believe is this version I'm using then that would be great... I am trying to get the Camera to work cross platform to take a picture and then store that picture on Azure Blob Storage (that will be another hurdle I will have to get working for the 3 platforms)

    If I have my AppDelegate inherit from XFormsApplicationDelegate like: public partial class AppDelegate : XFormsApplicationDelegate

    then visual studio complains and says that XFormsApplicationDelegate could not be found.

    If I have it follow the new Xamarin Forms 1.3.1 standard like: public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate

    then I suspect XLabs won't work but couldn't validate that because following the new standard above, another error occurs. I have copied and pasted the code above in my AppDelegate class:

    private void SetIoc ()
                    {
                        var resolverContainer = new XLabs.Ioc.SimpleContainer ();
                        resolverContainer.Register< XLabs.Platform.Device.IDevice> (t => AppleDevice.CurrentDevice)
                            .Register<XLabs.Platform.Device.IDisplay> (t => t.Resolve<XLabs.Platform.Device.IDevice> ().Display)
                            .Register<XLabs.Ioc.IDependencyContainer> (t => resolverContainer);
                        XLabs.Ioc.Resolver.SetResolver (resolverContainer.GetResolver ());
                    }
    

    And Visual Studio then complains about this line: resolverContainer.Register<XLabs.Platform.Device.IDevice>(t => AppleDevice.CurrentDevice)

    red underlining this bit "t => AppleDevice.CurrentDevice" stating this error message: "Cannot convert lambda expression to type 'System Type' because it is not a delegate type"

    These are all of my usings: using System; using System.Collections.Generic; using System.Linq; using Microsoft.WindowsAzure; using MonoTouch.Foundation; using MonoTouch.UIKit; using Xamarin.Forms; using XLabs.Forms; using XLabs.Serialization; using XLabs.Platform; using XLabs.Ioc; using XLabs.Platform.Device; using XLabs.Platform.Services; using XLabs;

    These are my Nuget prerelease Xlabs Packages: Xlabs - Core, Forms, IoC Unity, loC, Platform, Serialization

    By the way - When I tried to make the same code work with Xamarin.Forms.Labs 1.2.1-pre2 it would also not work because when I tried this line (or its equivalent for Xamarin.Forms.Labs - can't remember which): public partial class AppDelegate : XFormsApplicationDelegate

    Then VS complained about LoadApplication(new App()); stating that LoadApplication didn't exist...

    I spent several hours yesterday with both Xamarin.Forms.Labs and XLabs and I'm either doing something very silly or its not a peace of cake getting XLabs to work with the latest Xamarin Forms 1.3.1...

    Please Help :-)

    Monday, February 2, 2015 7:29 AM
  • User102962 posted

    I get the same errors as LuisMarques... How we can solve them?

    I think that the problem is that nuget packages are older than master packages and wiki. But I don't understand how to use master version downloaded by github.

    Thanks in advance, Fabio

    Tuesday, February 3, 2015 11:26 AM
  • User38273 posted

    Fabio, hopefully one of the knowledgeable people in this thread will notice our pleads for help in the next day or so :smile: Let me know if you fix it. I haven't had the time yet to go back to it since the weekend...

    Wednesday, February 4, 2015 6:20 AM
  • User51906 posted

    @LuisMarques @FabioMarcone Ok. Let us tear this down. Which Nuget do you use? Is it correctly installed in the PCL and the Platform Project?

    Wednesday, February 4, 2015 6:24 AM
  • User102962 posted

    @RaphaelSchindler I use Official Nuget repository (www.nuget.org/api/v2) and I've in ios project: - ExifLib.PCL 1.0.0 - Newtonsoft.Json 6.0.8 - Xamarin.Forms 1.3.1.6296 - Xamarin.Forms.Labs 1.2.0 - Xamarin.Forms.Maps 1.3.1.6296

    Do need other info? I'm trying to use geolocator and I use Xamarin Studio.

    I get a not found error (XFormsApplicationDelegate could not be found) in AppDelegate declaration so I use:

    public override bool FinishedLaunching (UIApplication app, NSDictionary options) { this.SetIoc ();

            global::Xamarin.Forms.Forms.Init ();
            global::Xamarin.FormsMaps.Init ();
    
            LoadApplication (new App ());
    
            return base.FinishedLaunching (app, options);
        }
    
        /// <summary>
        /// Sets the IoC.
        /// </summary>
        private void SetIoc ()
        {
            var resolverContainer = new SimpleContainer ();
    
            //resolverContainer.Register<IDevice> (t => AppleDevice.CurrentDevice) 
            resolverContainer.Register<IDisplay> (t => t.Resolve<IDevice> ().Display)
                .Register<IDependencyContainer> (t => resolverContainer);
    
            Resolver.SetResolver (resolverContainer.GetResolver ());
        }
    

    AppleDevice is not found so I comment that line.

    Thanks.

    Wednesday, February 4, 2015 8:26 AM
  • User51906 posted

    Xamarin.Forms.Labs 1.2.0 does NOT support Xamarin.Forms 1.3.x use this Nuget http://www.nuget.org/packages/XLabs.Forms/2.0.0-pre91

    Wednesday, February 4, 2015 8:28 AM
  • User83890 posted

    Like a few others in this thread, I'm sort of stuck with getting AppleDevice to resolve. I used the package console extension in Xamarin Studio to execute the following NuGet commands:

    Install-Package XLabs.Core -Pre Install-Package XLabs.Serialization -Pre Install-Package XLabs.IoC -Pre Install-Package XLabs.Platform -Pre Install-Package XLabs.Forms -Pre

    The package console reported all 5 of these packages where version 2.0.0-pre91 and now everything resolves except AppleDevice. What have I overlooked?

    Wednesday, February 4, 2015 8:30 AM
  • User83890 posted

    We'll it turns out that I just right-clicked on all XLabs packages and removed them. Then I reinstalled them all in this order and AppleDevice can now be resolved (not that the order should matter). Also note that Core was not explicitly installed, it was automatically pulled in as a dependency:

    Install-Package XLabs.Platform -Pre Install-Package XLabs.Ioc -Pre Install-Package XLabs.Serialization -Pre Install-Package XLabs.Forms -Pre

    Wednesday, February 4, 2015 8:33 AM
  • User51906 posted

    As I don't use the console for managing nuget I can't say what is going wrong there :) Normally, if you're installing XLabs.Forms all others are getting installed as dependencys. At least that is how it worked here.

    Wednesday, February 4, 2015 8:50 AM
  • User38273 posted

    Hi guys thanks for the helpful comments. I will try later tonight removing and re-installing all nugets (for the 3rd time). I have as stated on my post XLabs nugets and in theory it should work but visual studio kept complaining. I'll report back later. Maybe xamarin could consider putting some course work on xamarin university about XLabs - it's a great community project it seems...

    Wednesday, February 4, 2015 9:32 AM
  • User102962 posted

    Thanks to @RaphaelSchindler I solved. Maybe XLabs could have more howto guides (for stable and developing version)...

    Wednesday, February 4, 2015 9:43 AM
  • User51906 posted

    @FabioMarcone You're welcome

    Wednesday, February 4, 2015 9:45 AM
  • User38273 posted

    Hi @FabioMarcone how did you solve it exactly? Was it by removing all packages relates to XLabs and re-installing them in the order that @PaulHazlett recommended? I didn't realise the order mattered! I'm asking because I want to be 100% clear on the order etc. can you also tell me how your app delegate class definition looks like? What class does it inherit from and what specific usings have you included. Thanks in advance.

    Wednesday, February 4, 2015 11:18 AM
  • User2496 posted

    Hey guys, you should try XLabs 2.0 pre, make sure you try to check all dependencies are in the same version XLabs - Core 2.0.0-pre91 .

    Wednesday, February 4, 2015 1:07 PM
  • User38273 posted

    Hi All, so I removed all my XLabs nugets, re-installed them again (note that I looked for the pre91 pre release version but it didn't appear on the search list anymore. I believe it was released finally yesterday because the stable version has 2.0 with 04/02 date). So anyway, I re-installed every nuget and followed the same order as Paul described:

    All version 2.0 XLabs.Platform XLabs.Ioc XLabs.Serialization XLabs.Forms

    The only difference is that I used the normal way of installing in visual studio (didn't do console commands).

    Following the wiki on https://github.com/XLabs/Xamarin-Forms-Labs/wiki it says: On iOS you can just change in your AppDelegate.cs to this: public partial class AppDelegate : XFormsApplicationDelegate

    When I do this, Visual studio says that he can't find XFormsApplicationDelegate.

    So finding the same error as before Can't figure out what is wrong...

    If instead I define it as: public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate

    (which goes against what the wiki says)

    and then in the same AppDelegate class I define the method: private void SetIoc() { var resolverContainer = new XLabs.Ioc.SimpleContainer(); resolverContainer.Register(t => AppleDevice.CurrentDevice) .Register(t => t.Resolve().Display) .Register(t => resolverContainer); XLabs.Ioc.Resolver.SetResolver(resolverContainer.GetResolver()); }

    Visual studio again complains about resolverContainer.Register(t => AppleDevice.CurrentDevice)

    stating that t => AppleDevice.CurrentDevice"Cannot convert lambda expression to type 'System Type' because it is not a delegate type"

    These are all XLabs usings: using XLabs.Forms; using XLabs.Serialization; using XLabs.Platform; using XLabs.Ioc; using XLabs.Platform.Device; using XLabs.Platform.Services; using XLabs;

    Guys, @FabioMarcone, @PaulHazlett, @rmarinho, @SKall, @RaphaelSchindler can one of you maybe paste your AppleDelegate definition, your usings, and package references? Just make sure the sample code you are posting is using the latest Xamarin Forms version and the latest XLabs version (otherwise it may work for you because you are using older libraries). This is so I can determine what I'm missing. I tried everything I can think of and followed every advice on wiki & this thread but can't make it work :disappointed:

    Thursday, February 5, 2015 7:38 AM
  • User102962 posted

    I use Xamarin Studio, I had install Package Management Console add in and then I had deinstall old Lab version 1.2.0 from ide and then install XLabs 2.0.0-pre91 using console. The 2.x version solve your problems (you hav to use public partial class AppDelegate : XFormsApplicationDelegate like showed by samples).

    Thursday, February 5, 2015 8:03 AM
  • User51906 posted

    This is my AppDelegate and I hope this helps you.

    using Foundation;
    using mCRM.Views;
    using Toasts.Forms.Plugin.iOS;
    using UIKit;
    using Xamarin.Forms;
    using XLabs.Forms;
    using XLabs.Platform.Device;
    using XLabs.Platform.Services.Media;
    using XLabs.Ioc;
    using XLabs.Platform.Services;
    
    namespace mCRM.iOS
    {
        [Register("AppDelegate")]
        public partial class AppDelegate : XFormsApplicationDelegate
        {
    
            public override bool FinishedLaunching(UIApplication app, NSDictionary options)
            {
                Forms.Init();
                ToastNotificatorImplementation.Init();
                SetIoC();
    
                LoadApplication(new App());
    
                return base.FinishedLaunching(app, options);
            }
    
            private void SetIoC()
            {
                var resolverContainer = new SimpleContainer();
    
                resolverContainer.Register<IDevice>(t => AppleDevice.CurrentDevice)
                    .Register<IPhoneService>(t => t.Resolve<IDevice>().PhoneService)
                    .Register<IAudioStream>(t => t.Resolve<IDevice>().Microphone)
                    .Register<INetwork>(t => t.Resolve<IDevice>().Network)
                    .Register<IDependencyContainer>(resolverContainer);
    
                Resolver.SetResolver(resolverContainer.GetResolver());
            }
        }
    }
    
    Thursday, February 5, 2015 8:20 AM
  • User12403 posted

    This is our iOS sample applications app delegate:

    https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/Samples/XLabs.Sample.iOS/AppDelegate.cs

    I have tested the latest 2.0 release package multiple times by just installing XLabs.Forms package. It has pulled in all dependencies automatically every single time.

    If you are having issues with resolving namespaces and where things are located then I suggest installing the trial version of Resharper. Chances are you will find it will save you a LOT of time and is well worth the price. Personal license (which you can use anywhere including business) is only $149.

    Thursday, February 5, 2015 12:30 PM
  • User69837 posted

    @LuisMarques, what is your namespace? This seems like a namespace problem because you have Xamarin.Forms in your namespace.

    Thursday, February 5, 2015 4:12 PM
  • User38273 posted

    Thank you all for your assistance. Unfortunately I haven't been able to fix this issue. I will probably have to spend another day's worth banging my head against the wall until I find what is wrong!! During the weekend I will have a look at the sample @SKall provided to compare the differences in the 2 projects' nugets. One thing is certain, I am now 99.999% certain its nothing in the code. It must be the project configuration, some conflict on the nuget packages, or something like that. I have removed all Xlabs and reinstalled them all again, did what SKall suggested and installed only XLAbs.Forms which in turn downloaded all other dependencies but Visual Studio still says it doesnt recognise the name XFormsApplicationDelegate....

    Here is my full App Delegate:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using Microsoft.WindowsAzure;
    using MonoTouch.Foundation;
    using MonoTouch.UIKit;
    using Xamarin.Forms;
    using XLabs.Forms;
    using XLabs.Platform.Device;
    using XLabs.Platform.Services.Media;
    using XLabs.Ioc;
    using XLabs.Platform.Services;
    
    namespace NoteTakerPCL.iOS
    {
        // The UIApplicationDelegate for the application. This class is responsible for launching the 
        // User Interface of the application, as well as listening (and optionally responding) to 
        // application events from iOS.
        [Register("AppDelegate")]
    //    public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
        public partial class AppDelegate : XFormsApplicationDelegate
        {
            // class-level declarations
            //
            // This method is invoked when the application has loaded and is ready to run. In this 
            // method you should instantiate the window, load the UI into it and then make the window
            // visible.
            //
            // You have 17 seconds to return from this method, or iOS will terminate your application.
            //
            public override bool FinishedLaunching(UIApplication app, NSDictionary options)
            {
                global::Xamarin.Forms.Forms.Init();
                Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
                LoadApplication(new App());
    
                return base.FinishedLaunching(app, options);
            }
    
            private void SetIoc()
            {
                var resolverContainer = new XLabs.Ioc.SimpleContainer();
                resolverContainer.Register<XLabs.Platform.Device.IDevice>(t => AppleDevice.CurrentDevice)
                    .Register<XLabs.Platform.Device.IDisplay>(t => t.Resolve<XLabs.Platform.Device.IDevice>().Display)
                    .Register<XLabs.Ioc.IDependencyContainer>(t => resolverContainer);
                XLabs.Ioc.Resolver.SetResolver(resolverContainer.GetResolver());
            }
        }
    }
    
    Friday, February 6, 2015 7:30 AM
  • User51906 posted

    Try to replace your using Directives with mine.

    using Foundation;
    using UIKit;
    using Microsoft.WindowsAzure;
    using Xamarin.Forms;
    using XLabs.Forms;
    using XLabs.Platform.Device;
    using XLabs.Platform.Services.Media;
    using XLabs.Ioc;
    using XLabs.Platform.Services;
    
    Friday, February 6, 2015 8:01 AM
  • User38273 posted

    @RaphaelSchindler i will do as you suggest tomorrow morning and report back. Can you do me a quick favour - where exactly is this class defined? Which nuget? Which using directive enables the name to be recognised when referred to? Is it XLabs.Forms; or XLabs.Platform? Just wondering where this magical class is defined ;-)

    Friday, February 6, 2015 9:09 AM
  • User51906 posted

    @LuisMarques The XFormsApplicationDelegate is part of the XLabs.Forms Nuget is XLabs 2.0.0 -pre91

    Friday, February 6, 2015 9:19 AM
  • User38273 posted

    @RaphaelSchindler Ok - thanks, good to know where exactly the class is defined - quite weird though that I have the XLabs.Forms using directive but somehow it's still invisible. You said XLabs 2.0.0 -pre91 - to be clear - I didn't find any pre-release versions of XLabs the last 2 days I checked. They were appearing in the visual studio search list about 3 days ago, but not now. I think that there is only a single stable release available at the moment and that is the one visual studio downloads from nuget. Wondering if you use some console command to install them or if you just download them normally via visual studio drop down menu - add packages

    Friday, February 6, 2015 11:42 AM
  • User51906 posted

    @LuisMarques It seems that 2.0.0 has hit the stable release so you will only find that right now but it is the same as 2.0.0 pre91 with some bug fixes as I can see. The package has last release on 4th February 2015. Could you try the newest Xamarin.Forms pre Version that is at the moment 1.3.3.6231 pre2

    Friday, February 6, 2015 11:47 AM
  • User38273 posted

    @RaphaelSchindler Ok thanks for confirming - I wonder if this latest stable XLabs also works with your app delegate.

    Anyway, I'll try tomorrow morning with the using directives you suggested and remove all the other ones. In fact I'll add them one by one and re-build each time to see if the class at some point becomes visible...

    Friday, February 6, 2015 12:00 PM
  • User51906 posted

    @LuisMarques Just changed from 2.0.0 pre91 to stable 2.0.0 and it works.

    Friday, February 6, 2015 12:07 PM
  • User38273 posted

    Ok good to know it's not anything wrong with the new stable package. What a mystery !! :-) I'll report back tomorrow morning.

    Friday, February 6, 2015 12:20 PM
  • User38273 posted

    Hi Guys, I finally found what was wrong! The way I found it was by starting a new Xamarin.Forms project and then adding XLabs.Forms to that brand new forms project. I noticed that it immediately recognized that mysterious XFormsApplicationDelegate class. I then suspected that it could be because of the fact that the brand new template for Xamarin.Forms was already migrated to Xamarin.iOS Unified - I compared the references of that new project with mine and saw differences - mine said iOS.classic, and the new one had no such reference. From there I just had to find the migration "how to" page and post migration, the class became "visible" to Visual Studio and the issues vanished. So now you all know, XLabs is only compatible with Xamarin.iOS unified, not classic... My fault, I should have upgraded weeks ago but never crossed my mind this was the reason for all the head ache!

    Thank you all for your feedback - and special thanks to @RaphaelSchindler for your huge patience and constant helpful examples and answers. Knowing the class was in XLabs.Forms and that the new package worked fine with your project was key to direct troubleshooting to other areas.

    Sunday, February 8, 2015 8:54 PM
  • User51906 posted

    @LuisMarques Great that it works now. I should have asked earlier if you upgraded to unified :neutral:

    Monday, February 9, 2015 7:12 AM
  • User44936 posted

    I installed XLabs - Forms 2.0.5522 (latest stable) 161 Saturday, February 14 2015
    However when I am trying to takepicture (camera feature) in Android it fails with a runtime error as below The class Android.OS.BaseBundle could not be loaded, used in XLabs.Platform.Droid

    How to resolve this.

    My code is as below public class MainActivity : XFormsApplicationDroid { private static bool initialized; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); if (!initialized) { this.SetIoc(); }

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
    
        }
    
        /// <summary>
        /// Sets the IoC.
        /// </summary>
        private void SetIoc()
        {
            var resolverContainer = new SimpleContainer();
    
            var app = new XFormsAppDroid();
    
    
            app.Init(this);
    
            resolverContainer
                .Register<IDevice>(t => AndroidDevice.CurrentDevice)
    
                .Register<IDisplay>(t => t.Resolve<IDevice>().Display)
                .Register<IDependencyContainer>(resolverContainer)
                .Register<IXFormsApp>(app);
    
    
            Resolver.SetResolver(resolverContainer.GetResolver());
    
            _initialized = true;
        }
    

    }

    Wednesday, February 18, 2015 10:45 PM
  • User44936 posted

    I installed XLabs - Forms 2.0.5522 (latest stable) 161 Saturday, February 14 2015
    However when I am trying to takepicture (camera feature) in Android it fails with a runtime error as below The class Android.OS.BaseBundle could not be loaded, used in XLabs.Platform.Droid

    How to resolve this.

    My code is as below public class MainActivity : XFormsApplicationDroid { private static bool initialized; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); if (!initialized) { this.SetIoc(); }

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
    
        }
    
        /// <summary>
        /// Sets the IoC.
        /// </summary>
        private void SetIoc()
        {
            var resolverContainer = new SimpleContainer();
    
            var app = new XFormsAppDroid();
    
    
            app.Init(this);
    
            resolverContainer
                .Register<IDevice>(t => AndroidDevice.CurrentDevice)
    
                .Register<IDisplay>(t => t.Resolve<IDevice>().Display)
                .Register<IDependencyContainer>(resolverContainer)
                .Register<IXFormsApp>(app);
    
    
            Resolver.SetResolver(resolverContainer.GetResolver());
    
            _initialized = true;
        }
    

    }

    Wednesday, February 18, 2015 10:45 PM
  • User65389 posted

    @LuisMarques and @RaphaelSchindler:

    First, thanks for your postings here.... I have installed XLabs a longer time ago, but only have used the PopUp-Control (Xlabs.forms). Now, I want to use some services from XLabs (including device) and have exactly the same problems as Luis:

    red underlining this bit "t => AppleDevice.CurrentDevice" stating this error message: "Cannot convert lambda expression to type 'System Type' because it is not a delegate type"

    I have searched for hours and finally also had a look to my references (thanks your posting, Luis). In difference to Luis, I have done the migration to unified (according to the description) and thought, that I am on unified (also as I have not other problems)... Now, I have seen, that it seems, as the migration with the tool was not or only partially done :disappointed:
    My references targets still montotouch10 (ios.classic), in my csproj-file still the old key is in included, and I have still usings with monotouch-namespace (but I have found only 2 in the AppDelegate.cs-file).

    I also have tried, to run the migration-tool once again - nothing happens :bawling:

    Questions: - Does somebody knows, what the migration-tool exactly does?

    According to the Xamarin-documentation (to manually migrate an iOS-project), the following steps are to do:
    - change a key and project-setting in the csproj-file
    - remove the references to the monotouch.10 and replace it with references to Xamarin.iOS10
    - remove the monotouch-namespace
    - done...?

    In don't like that, as I fear to "destroy" my project (I also don't understand, that I have no other problems, as I also have done already the manual changes in all projects).

    Any suggestions...?

    Thanks for every reply!

    P.S.
    I also create a description, how to install and use XLabs and will post it then here in the forum.

    Friday, March 13, 2015 6:20 PM
  • User51906 posted

    @FredyWenger Hi and sorry for the late response, I was on vacation. Do you get compile Errors if you're compiling your app and AppleDevice is red underlined? I had the same behaviour and sometimes it is underlined and sometimes not. I don't know the exact reason why but as long as no problems occur I don't really care^^

    I just looked in my .csproj of the iOS project and I too have a reference to monotouch10 after using the migration tool. Seems to be ok.

    Monday, March 16, 2015 8:01 AM
  • User65389 posted

    @RaphaelSchindler:
    Thanks for your "late? response" . I hope you had a nice holiday... :sunglasses: :sunglasses: :sunglasses:

    If you really have your references (e.g. to Xamarin.Forms.Core) already to monotouch, I suggest you to update to unified (as I think, you will have problems else....).
    As I have loosed now full two day's with the problems (first the unified-problem, then a further problem wit Xamarin.Mobile), I have posted my findings in a new thread (in the hope, that may help some other developers like us - maybe also you :innocent:)

    Link: forums.xamarin.com/discussion/35928/information-problems-update-xf-to-unified-appledevice-xamarin-mobile-xlabs?new=1

    Once again, thanks for your help...

    Monday, March 16, 2015 5:26 PM
  • User65389 posted

    @All readers of this thread:

    I have implemented XLabs and thereby created a documentation (.pdf). You will find it here: forums.xamarin.com/discussion/35991/how-to-install-setup-and-use-xlabs?new=1

    Tuesday, March 17, 2015 1:02 PM