asudbury / NinjaCoderForMvvmCross

A Visual Studio AddIn for MvvmCross framework and Xamarin Forms
44 stars 18 forks source link

Windows Phone Xamarin Forms App not launching first page #158

Closed kreuzhofer closed 9 years ago

kreuzhofer commented 9 years ago

Hi,

when generating a project for Xamarin Forms with the Ninja Coder, the Windows Phone Application is stuck at the loading screen. Nothing happens and the first page ist not loading. I guess this has to do something with the RootFrame.Navigating event, that cancels the navigation. I am not sure how to fix this. Anyone else discovering the same issue?

Regards Daniel

kreuzhofer commented 9 years ago

I think the current installation package for Visual Studio is broken. It does not contain the latest project templates. This might be the main reason for the problems.

asudbury commented 9 years ago

Hi,

if you send me the readme it generates it will give me some idea of what templates it is using and i take it from there.

MobiliTips commented 9 years ago

Same here. It's just that after creating a project from scratch with MVVMCross + Xamarin Forms option on Ninja Coder 3.4 and then just start the application, it stucks on the clock screen. Everything's fine with Android and iOS. Maybe the Windows Phone presenter is missing some code lines like ones here: https://github.com/MarcosCobena/Xam.Forms.Mvx/blob/master/Movies/Movies.WinPhone/MvxFormsPhoneViewPresenter.cs Specialy a RootFrame.Navigate if NavigationPage is null ?

asudbury commented 9 years ago

will look into it - hopefully just an update to one of the nuget packages.

asudbury commented 9 years ago

if you add the following line below this.navigationPage = new NavigationPage(page); does it now work?

this.RootFrame.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));

MobiliTips commented 9 years ago

I get this error: No XAML was found at the location '/MainPage.xaml' Same error with a clean MVVMCross blank project plus the cheesebaron FormsPresenters mvx plugin https://github.com/Cheesebaron/Cheesebaron.MvxPlugins/tree/master/FormsPresenters So I think it should be my implementation of it. No problem by your side? Keep searching...

MobiliTips commented 9 years ago

Ok it's the MainPage.xaml build action property set to None after Ninja project creation. So 2 things to do: . add this.RootFrame.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); after this.navigationPage = new NavigationPage(page); . ensure that MainPage.xaml build action property is set to Page Now the MainView is displayed but as an empty black screen and it's because of MainPage.xaml.cs initialization. Creating a standard MVVMCross project from scratch and installing the Cheesebaron FormsPresenters plugin worked like a charm, so I decided to merge good ideas form his plugin into your Ninja implementation. I'll share the result if interested.

--- EDIT--- As I said I created a MVVMCross + Xamarin Forms project with NinjaCoder. Then I modified some parts of the generated code thanks to Cheesebaron FormsPresenters plugin sources, to merge "best of both worlds". Now, as everything's working like a charm on each Platform, please find here the result project: https://github.com/MobiliTips/NinjaMvxForms Maybe it could help...

asudbury commented 9 years ago

thanks for the info - looking into it now.

MobiliTips commented 9 years ago

Well I with this implementation I was stuck by a dependency injection error: .No possibility to inject service interfaces into viewmodel constructors at all .Mvx.Resolve() works only on Android and Windows Phone viewmodels This was due to service resolution between the Forms project to the Core project as if I put views into the Core project, injection works great. Anyway, you'll find this working project (MVVMCross with DI + Xamarin Forms) here: https://github.com/MobiliTips/MvxForms Don't know if it helps.

asudbury commented 9 years ago

Sounds like it could be a linker error.

Sent from my iPhone

On 9 Mar 2015, at 16:08, Jeremy BRUN-PICARD notifications@github.com wrote:

Well I with this implementation I was stuck by a dependency injection error: .No possibility to inject service interfaces into viewmodel constructors at all .Mvx.Resolve() works only on Android and Windows Phone viewmodels This was due to service resolution between the Forms project to the Core project as if I put views into the Core project, injection works great. Anyway, you'll find this working project (MVVMCross with DI + Xamarin Forms) here: https://github.com/MobiliTips/MvxForms Don't know if it helps.

— Reply to this email directly or view it on GitHub.

MobiliTips commented 9 years ago

Ok get it! It was binding context into xaml view witch make it throw a constructor error. I removed xaml binding and let the presenter do it after Page creation. Also I made some code refactoring like generic presenter abstract class, now all is working and code is updated at: https://github.com/MobiliTips/NinjaMvxForms I'll probably fork your project soon to apply my updates and pull if you want.

asudbury commented 9 years ago

Sounds great - thanks

Sent from my iPhone

On 13 Mar 2015, at 18:15, Jeremy BRUN-PICARD notifications@github.com wrote:

Ok get it! It was binding context into xaml view witch make it throw a constructor error. I removed xaml binding and let the presenter do it after Page creation. Also I made some code refactoring like generic presenter abstract class, now all is working and code is updated at: https://github.com/MobiliTips/NinjaMvxForms I'll probably fork your project soon to apply my updates and pull if you want.

— Reply to this email directly or view it on GitHub.

asudbury commented 9 years ago

ready to start looking at this. @MobiliTips any chance you can resummarise when the problems are with the current Ninja. I want to try and stay close to my original design if possible,

If that still doesn't work ill like to understand what it means to change the design. My aim was to try and keep Xamarin.Forms and MvvmCross in seperate projects at the PCL/core level.

As i understand Android and iOS were working ok?? But windows phone wasnt? what was going wrong.

Sorry if im making you go over old ground - my head has been else where for the last few weeks - trying to context switch back over to the ninja :-)

MobiliTips commented 9 years ago

Oups, I followed the discussion on pull thread https://github.com/asudbury/NinjaCoderForMvvmCross/pull/163

asudbury commented 9 years ago

Hi @MobiliTips - did you change 2 nuget packages - these:-

Scorchio.NinjaCoder.MvvmCross.Xamarin.Forms.Core

Scorchio.NinjaCoder.MvvmCross.Xamarin.Forms

MobiliTips commented 9 years ago

Yes I did change both .nuspec files to deal with new .cs.pp files and I upgraded both version number (forgeting the pre-release flag -beta1 by the way). Normaly, it should be ready to go.

asudbury commented 9 years ago

Should get this all sorted tomorrow - have updated ninja to support pre release ninja nuget packages just need to upload new packages and see if it works :-)

Sent from my iPhone

On 23 Mar 2015, at 08:43, Jeremy BRUN-PICARD notifications@github.com wrote:

Yes I did change both of .nuspec files to deal with new .cs.pp files and I upgraded both version number (forgeting the pre-release flag -beta1 by the way). Normaly, it should be ready to go.

— Reply to this email directly or view it on GitHub.

asudbury commented 9 years ago

@MobiliTips

Im trying to understand the XamarinFormsApp class in the nuget package Scorchio.NinjaCoder.MvvmCross.Xamarin.Forms.

This seems to be a new version of App class in the nuget package Scorchio.NinjaCoder.Xamarin.Forms.

can we use your new XamarinFormsApp class in Scorchio.NinjaCoder.Xamarin.Forms.and remove App class. (and also remove XamarinFormsApp from Scorchio.NinjaCoder.MvvmCross.Xamarin.Forms..

MobiliTips commented 9 years ago

Yes definitly! I called it XamarinFormsApp in case user wan't to merge Forms and Core project as Core project already host an App class but inherited from MvxApplication. Preventing from potential conflict. Like so, I found it easyer to know witch App we are talking about (MvxApplication vs Xamarin.Forms.App). So yes we can use the new XamarinFormsApp class. Nice job for your pre-release Ninja version!

asudbury commented 9 years ago

im taking DebugTrace out of the solution for now we can put it back in a future release (DebugTrace doesn't appear to part of nuget or the solution at present)

MobiliTips commented 9 years ago

Ok no pb. Don't forget to remove references from setup.cs

Envoyé depuis un mobile Samsung.

-------- Message d'origine --------
De : asudbury notifications@github.com
Date :26/03/2015 20:33 (GMT+01:00)
A : asudbury/NinjaCoderForMvvmCross NinjaCoderForMvvmCross@noreply.github.com
Cc : Jeremy BRUN-PICARD mobilitips@hotmail.com
Objet : Re: [NinjaCoderForMvvmCross] Windows Phone Xamarin Forms App not launching first page (#158)
im taking DebugTrace out of the solution for now we can put it back in a future release (DebugTrace doesn't appear to part of nuget or the solution at present) — Reply to this email directly or view it on GitHub.
asudbury commented 9 years ago

still got some problems! - can check out the pre release version?

MobiliTips commented 9 years ago

Will take a look tomorrow.

Envoyé depuis un mobile Samsung.

-------- Message d'origine --------
De : asudbury
Date :26/03/2015 23:06 (GMT+01:00)
A : asudbury/NinjaCoderForMvvmCross
Cc : Jeremy BRUN-PICARD
Objet : Re: [NinjaCoderForMvvmCross] Windows Phone Xamarin Forms App not launching first page (#158)

still got some problems! - can check out the pre release version?


Reply to this email directly or view it on GitHub: https://github.com/asudbury/NinjaCoderForMvvmCross/issues/158#issuecomment-86734953

asudbury commented 9 years ago

Getting this error - which i think is because we are trying to install this nuget package to a project that doesnt have any related content any more - will have a look later.

Install-Package : Could not install package 'Scorchio.NinjaCoder.Xamarin.Forms 1.0.12-beta1'. You are trying to install this package into a project that targets 'portable-net45+win+wp80+MonoAndroid10+xamarinios10+MonoTouch10', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. At line:7 char:1

MobiliTips commented 9 years ago

Yes you're right.

  1. We're trying to add Scorchio.NinjaCoder.Xamarin.Forms 1.0.12-beta1 reference to the Forms project but it doesn't contains any related files. As XamarinFormsApp.cs class file is needed by MvxForms projects but could also be usefull for Forms only projects, we can move XamarinFormsApp.cs.pp referencing line from Scorchio.NinjaCoder.MvvmCross.Xamarin.Forms.nuspec to Scorchio.NinjaCoder.Xamarin.Forms. I can see that the XamarinFormsApp.cs.pp file itself is already on the good place into NuSpec/XamarinForms/FormsContent. Just have to move referencing from nuspec file. Like this, no more nuget install pb.
  2. Also, I can see into the Windows phone MainPage.xaml.cs file I forgot to change presenter.MvxFormsApp into presenter.XamarinFormsApp.
  3. Also, MainPage.xaml build action still at None but it should be at Page. We could change this option into the nuget installation command process. Anyway, it could be set manually after project creation by user itself.
  4. Finaly, the resulting MainView.xaml ContentView is empty (so the black screen). Maybe it's me who did not pay attention selecting options on Ninja but at least if MainViewModel contains the SampleText property, I think the MainView should be binded to it, so the user could directly build the project and see it works.

I'll correct and commit 1 and 2. Then, I'll look for the option 3 nuget script line (seen somewhere already). Don't know about 4. I'll give a try again paying attention :)

EDIT: 1 & 2 fix just commited

asudbury commented 9 years ago

Sounds like we may need a build to fix this - don't think we will get it resolved with just nuget changes.

Sent from my iPhone

On 27 Mar 2015, at 09:27, Jeremy BRUN-PICARD notifications@github.com wrote:

Yes you're right.

We're trying to add Scorchio.NinjaCoder.Xamarin.Forms 1.0.12-beta1 reference to the Forms project but it doesn't contains any related files. As XamarinFormsApp.cs class file is needed by MvxForms projects but could also be usefull for Forms only projects, we can move XamarinFormsApp.cs.pp referencing line from Scorchio.NinjaCoder.MvvmCross.Xamarin.Forms.nuspec to Scorchio.NinjaCoder.Xamarin.Forms. I can see that the XamarinFormsApp.cs.pp file itself is already on the good place into NuSpec/XamarinForms/FormsContent. Just have to move referencing from nuspec file. Like this, no more nuget install pb.

Also, I can see into the Windows phone MainPage.xaml.cs file I forgot to change presenter.MvxFormsApp into presenter.XamarinFormsApp.

Also, MainPage.xaml build action still at None but it should be at Page. We could change this option into the nuget installation command process. Anyway, it could be set manually after project creation by user itself.

Finaly, the resulting MainView.xaml ContentView is empty (so the black screen). Maybe it's me who did not pay attention selecting options on Ninja but at least if MainViewModel contains the SampleText property, I think the MainView should be binded to it, so the user could directly build the project and see it works.

I'll correct and commit 1 and 2. Then, I'll look for the option 3 nuget script line (seen somewhere already). Don't know about 4. I'll give a try again paying attention :)

— Reply to this email directly or view it on GitHub.

asudbury commented 9 years ago

How about i put in a dummy file into the Forms project - something like a ninjacoder,txt with a new build i can not add it but anyone using the current build are just going to get an extra text file.

MobiliTips commented 9 years ago

Ok let's resume about MvxForms.

What do you think? I could commit the iOS part for you, just tell me.

asudbury commented 9 years ago

If you commit your changes I'll pick up after

Sent from my iPhone

On 28 Mar 2015, at 08:46, Jeremy BRUN-PICARD notifications@github.com wrote:

Ok let's resume about MvxForms.

Forms nuget install shouldn't be a problem anymore with last commit (just moved XamarinFormsApp.cs.pp). We have to refresh the nuget package for it. Android works ok Windows Phone works ok. Well, normaly the MainPage.xaml build action should be set automaticaly to Page without need to do anything about it (as it is when I install my plugin MvxForms, nothings special done). If it's not the case, user can do it manually or we can do it by template or following this article: http://www.expertsys.hu/2014/11/20/setting-project-items-buildaction-from-nuget-package/. But anyway, it's not really a problem. iOS still has some bugs: First of all, there's an inversion as AppDelegate.cs file contains Application class and Main.cs file contains AppDelegate class. We have to change it from the cs.pp files MvxForms require iOS Setup class constructor to be of type Setup(MvxApplicationDelegate applicationDelegate, UIWindow window) and AppDelegate should call it like Setup setup = new Setup(this, this.windows); Well, I think we could modify AppDelegate and Setup directly from NuSpec/MvvmCross/iOSContent as both Mvx only and MvxForms project will work perfectly with these modifications. What do you think? I could commit the iOS part for you, just tell me.

— Reply to this email directly or view it on GitHub.

MobiliTips commented 9 years ago

Ok done! As we said, on NuSpec/MvvmCross/iOSContent/

I did not change/upgrade the Scorchio.NinjaCoder.MvvmCross nuspec version, may be we should push it as pre-release to. The same for Scorchio.NinjaCoder.MvvmCross.Xamarin.Forms.

asudbury commented 9 years ago

ok pulled your changes can you just list for me below the nuget packages i need to reissue please.

Ive done Scorchio.NinjaCoder.Xamarin.Forms what others do i need to do?

MobiliTips commented 9 years ago

Ok, here's the list:

Then we should be close to our goal (hope so :) )

By the way, when we'll be done with MvxForms, we probably should create a new Git Branch called "beta" or whatever so that we could work on a beta version, preserving the stable one, and merging branches when beta goes public.

asudbury commented 9 years ago

I like your idea of a beta branch.

Give me 10 minutes and I will have the nuget packages released.

Sent from my iPhone

On 28 Mar 2015, at 11:58, Jeremy BRUN-PICARD notifications@github.com wrote:

Ok, here's the list:

Scorchio.NinjaCoder.Xamarin.Forms because of the XamarinFormsApp.cs.pp reference add (you've done this one) Scorchio.NinjaCoder.MvvmCross.Xamarin.Forms because of the XamarinFormsApp.cs.pp reference removal Scorchio.NinjaCoder.MvvmCross because of Setup.cs.pp, AppDelegate.cs.pp and Main.cs.pp files content change Then we should be close to our goal (hope so :) )

By the way, when we'll be done with MvxForms, we probably should create a new Git Branch called "beta" or whatever so that we could work on a beta version, preserving the stable one, and merging branches when beta goes public.

— Reply to this email directly or view it on GitHub.

asudbury commented 9 years ago

nuget updated.

now thinking about MainPage.xaml build action should be set automaticaly to Page.

I think will update the studio template and create new installer.

MobiliTips commented 9 years ago

Just tried MvxForms creation with Ninja pre-release.

Well, we're close to but not yet done! :)

MobiliTips commented 9 years ago

AppDelegate problem fixed and commited. You'll need to reissue (again) Scorchio.NinjaCoder.MvvmCross.Xamarin.Forms.

asudbury commented 9 years ago

Why whats wrong with it - i did reissue it?

MobiliTips commented 9 years ago

We need to upgrade this nuget package because it now includes AppDelegate.cs.pp. This is due to get the mvvmcross version of AppDelegate and not the forms one. During the install process, first the mvvmcross pkg add the good appdelegate version, secondly the xamarinforms pkg override it with its own version but incompatible with mvxforms. So now with the thirdly install of mvvmcrossandxamarinforms pkg, it override it back to the mvvmcross version. And we're good to go.

Envoyé depuis un mobile Samsung.

-------- Message d'origine --------
De : asudbury
Date :28/03/2015 15:05 (GMT+01:00)
A : asudbury/NinjaCoderForMvvmCross
Cc : Jeremy BRUN-PICARD
Objet : Re: [NinjaCoderForMvvmCross] Windows Phone Xamarin Forms App not launching first page (#158)

Why whats wrong with it - i did reissue it?


Reply to this email directly or view it on GitHub: https://github.com/asudbury/NinjaCoderForMvvmCross/issues/158#issuecomment-87232858

asudbury commented 9 years ago

another version uploaded to nuget.

MobiliTips commented 9 years ago

Tried again with last nuget and it's a pleasure to confirm that iOS works great!! :D

I noticed something (I wonder why I didn't before) about Droid. Splash screen resources files are missing from MvvmCross nuspec resulting in a missing file error message on build. I added both splashstyle.xml and splash.png and now it works great! :D

Also,on WinPhone, MainPage.xaml.cs was referencing the old presenter from Forms project (wrong using). I updated it.

Changes commited already, so again, we have to upload to nuget.org: •Scorchio.NinjaCoder.MvvmCross for Droid splash screen files add •Scorchio.NinjaCoder.MvvmCross.Xamarin.Forms for WinPhone MainPage.xaml using update

Sorry, I didn't notice these bugs before.

asudbury commented 9 years ago

so if i do a pull and reissue the nuget packages we are looking good :-)

asudbury commented 9 years ago

some how i need to give you access to the nuget packages - can i do that?

MobiliTips commented 9 years ago

Well, yes you can but I think it's important that you keep ownership on publishing as it's your project and only one person with publish rights help managing package versions. But if you want to, you can.

Just tell me if you want to reissue last 2 pkgs by your self or if you want me to do it. If so, I'll need the publishing nuget key (use mail or private messaging on twitter)

By the way, as MainPage.xaml build action should be set to Page, MainPage.xaml.cs should also be set to Compile. Both are set to None after Ninja creation.

asudbury commented 9 years ago

Will take a look later - had a busy weekend doing other things.

Sent from my iPhone

On 30 Mar 2015, at 10:59, Jeremy BRUN-PICARD notifications@github.com wrote:

Well, yes you can but I think it's important that you keep ownership on publishing as it's your project and only one person with publish rights help managing package versions. But if you want to, you can.

Just tell me if you want to reissue last 2 pkgs by your self or if you want me to do it. If so, I'll need the publishing nuget key (use mail or private messaging on twitter)

By the way, as MainPage.xaml build action should be set to Page, MainPage.xaml.cs should also be set to Compile. Both are set to None after Ninja creation.

— Reply to this email directly or view it on GitHub.

asudbury commented 9 years ago

i cant see Droid splash screen files add to to the nuspec file •Scorchio.NinjaCoder.MvvmCross.

MobiliTips commented 9 years ago

Done!

asudbury commented 9 years ago

hopefully ive updated both nuget packages correctly - if you would like try and let me know - thanks again.

MobiliTips commented 9 years ago

Hum... don't know what happened but packages contain strange files. Seems to be old packages but well named beta-x. Should have a look on it cause nuspec files look good.

Envoyé depuis un mobile Samsung.

-------- Message d'origine --------
De : asudbury
Date :30/03/2015 20:28 (GMT+01:00)
A : asudbury/NinjaCoderForMvvmCross
Cc : Jeremy BRUN-PICARD
Objet : Re: [NinjaCoderForMvvmCross] Windows Phone Xamarin Forms App not launching first page (#158)

hopefully ive updated both nuget packages correctly - if you would like try and let me know - thanks again.


Reply to this email directly or view it on GitHub: https://github.com/asudbury/NinjaCoderForMvvmCross/issues/158#issuecomment-87781339

asudbury commented 9 years ago

Oh!!

I seem to be making really hard work of generating these nuget packages :-(

Sent from my iPhone

On 31 Mar 2015, at 07:14, Jeremy BRUN-PICARD notifications@github.com wrote:

Hum... don't know what happened but packages contain strange files. Seems to be old packages but well named beta-x. Should have a look on it cause nuspec files look good.

Envoyé depuis un mobile Samsung.

-------- Message d'origine --------
De : asudbury
Date :30/03/2015 20:28 (GMT+01:00)
A : asudbury/NinjaCoderForMvvmCross
Cc : Jeremy BRUN-PICARD
Objet : Re: [NinjaCoderForMvvmCross] Windows Phone Xamarin Forms App not launching first page (#158)

hopefully ive updated both nuget packages correctly - if you would like try and let me know - thanks again.


Reply to this email directly or view it on GitHub: https://github.com/asudbury/NinjaCoderForMvvmCross/issues/158#issuecomment-87781339 — Reply to this email directly or view it on GitHub.

MobiliTips commented 9 years ago

This issue is now resolved. Closed.