Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Confused about default Xamarin.Forms iOS project

Using VS 16.3, I created a XF iOS Single Page project. After fiddling with it for an hour or two, I finally noticed that it is a ".NET Standard" project (I for some reason expected a shared project). That's OK -- it's on me.

Is this the "standard" now (no pun...)?

The reason I created this was to get familiar with how an iOS app can start and/or give info to another iOS app through the iOS "OpenURL" call. But I was pretty frustrated when I could not easily get access to the NewApp.iOS namespace, nor include "using Foundation; using UIKit" in my "NewApp" namespace.

I think I'm understanding now why this is a a problem with the .Net Standard -- the bulk of the code is made into a "library" (a little counter-intuitive, no?). And this library gets "called" from the platform-specific code to start the App. Clever...

I'm just a little confused on how I WOULD do this -- I've seen "dependency service", but is that right? This is, after all, a solution with ONLY iOS as the target.

Best Answer


  • BobWhittenBobWhitten USMember ✭✭

    Thanks @AdamMeaney -- I may be speaking (and thinking) too loosely about "projects".

    Sure, that makes sense, that the XF project itself doesn't reference iOS classes. I was only using XF because I'm familiar with it -- I really wanted to make an app to test some iOS code. So, Shared Project is the way for this need.

    BUT, VS2019 no longer seems to offer that as an XF project, or at least I couldn't figure it out. So, copied and hacked an old shared projects solution.

    Of course, now that you point out OpenUri, maye that will address my need. Thanks for that!

  • AdamMeaneyAdamMeaney USMember ✭✭✭✭✭

    As an fyi, I recently learned that they were intending to deprecate that one in favor of Xamarin Essentials version of that call.

    Just for better future proofing.

    I am pretty sure they are leaning us towards NetStandard projects for all future development, but it could be they are just continuing their streak of losing templates they need when updating versions.

    Most likely, you can import that template and continue to use Shared Projects if that is what you are looking for.

    I just find my shared projects confusing with all the #if iOS and such.

  • BobWhittenBobWhitten USMember ✭✭

    Hmmmm.... looks like OpenUri has moved over into Xamarin.Essentials. Timely update here.

    The Device.OpenURI() method seems it will be dropped from XF 4.3

Sign In or Register to comment.