jsmarcus / Iconize

Use icon fonts in your Xamarin.Forms application!
Other
204 stars 71 forks source link

compatibility with Xamarin Forms 3.0 #68

Open wanderson-ra opened 6 years ago

wanderson-ra commented 6 years ago

There is forecast to update the plugin to be compatible with Xamarin Forms 3.0?

DawidBester commented 6 years ago

Same question, when updating my project to the latest release of Xamarin Forms, the update fails with the following message; Unable to resolve dependencies. 'Xamarin.Forms 3.0.0.446417' is not compatible with 'Xam.Plugin.Iconize 2.0.0.37-beta constraint: Xamarin.Forms (>= 2.3.5 && < 3.0.0)'.

wanderson-ra commented 6 years ago

Same problem! Please update the nuget package.

acastr7 commented 6 years ago

If you add his CI NuGet Feed: https://ci.appveyor.com/nuget/iconize to visual studio, you can get version 3.0.0.62 which does work with Xamarin Forms 3.

Im-PJ commented 6 years ago

@acastr7 @DawidBester I'm not seeing version 3.0.0.66 even after adding CI feed to visual studio :confused:

DawidBester commented 6 years ago

Thanks, that worked!

However the upgrade process is not trivial, as it is undocumented.

From memory I made the following changes after installing Xam.Plugin.Iconize and Xam.Plugin.Iconize.FontAwesome v3.0.0.66 from https://ci.appveyor.com/nuget/iconize:

  1. Changed Plugin.Iconize.Iconize.With(new Plugin.Iconize.Fonts.FontAwesomeModule()); in App.xaml.cs to
    
    Plugin.Iconize.Iconize
                .With(new Plugin.Iconize.Fonts.FontAwesomeRegularModule())
                .With(new Plugin.Iconize.Fonts.FontAwesomeSolidModule());
2. Changed all icon names in the project to the new FontAwesome 5 naming, see https://fontawesome.com/icons, this mainly icon name change from fa- to fas- or fas-

3. Downloaded the new fonts files from https://fontawesome.com/get-started/web-fonts-with-css, and after extracting the archive; renamed two of the font files found in the use-on-desktop folder to the iconize naming convention: 
Font Awesome 5 Free-Regular-400.otf renamed to iconize-fontawesome-regular.otf and 
Font Awesome 5 Free-Solid-900.otf renamed to iconize-fontawesome-solid.otf

4. (a) For the Android project; added the two new font files to the Asssets folder and removed the old iconize-fontawesome.ttf file.

4. (b) For the Android project; in MainActivity.cs left the following statement unchanged; `Plugin.Iconize.Iconize.Init(Resource.Id.toolbar, Resource.Id.sliding_tabs);`

5. (a) For the iOS project copied the two new font files to the Resources folder and removed the old iconize-fontawesome.ttf file.

5. (b) For the iOS project, in  Info.plist removed the old font reference; <string>iconize-fontawesome.ttf</string>  and updated Info.plist as follows
UIAppFonts
<array>
    <string>iconize-fontawesome-regular.otf</string>
    <string>iconize-fontawesome-solid.otf</string>
</array>

6. Additionally; for AppCenter builds I had to configure a NuGet.Config file in project root folder to enable AppCenter to find the new plugin location. 
References; 
https://blog.nuget.org/20170316/NuGet-now-fully-integrated-into-MSBuild.html 
https://docs.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior

NuGet.Config file contents;

<?xml version="1.0" encoding="utf-8"?>



7. Finally installed Xamarin Forms 3.0!
DawidBester commented 6 years ago

In VS 2017 I've configured package sources per screenshot.

image

Additionally when you Browse Nuget packages in VS you might need to select the new Package source from the dropdown on the right top of the screen to see the content on the new source;

image

Im-PJ commented 6 years ago

Thanks. Changing package source worked. Is the new version working fine with XF 3?

wanderson-ra commented 6 years ago

It's working, thank you!

aquisio commented 6 years ago

@DawidBester Thanks for your excellent write-up of the migration procedure. It mostly works as you described, but unfortunately I am not seeing icons rendered on Android.

On investigation, I see that the platform-specific Iconize classes (e.g. the custom renderers) are accessible from within iOS and UWP projects but they are absent in Android projects, which seems to explain the failure to render icons. Actually, I proved this assumption by copying the source code for one of the Android custom renderers into my Android codebase, after which rendering works correctly.

I also noticed that the bin\Debug folders of the iOS and UWP projects contain Plugin.Iconize.dll and Plugin.Iconize.FontAwesome.dll, but they are missing from the Android project.

Since others don't seem to be experiencing this problem, I am wondering whether my Android project has a targeting incompatibility with this release of Plugin.Iconize. It is an unmodified Android project within a Xamarin.Forms v3.0.0.482510 template solution, created using VS2017 v15.7.1.

I wonder if anyone could suggest what I might try next? Many thanks.

Welchen commented 6 years ago

Curious, how come this in a CI Nuget feed and the normal Nuget feed is not being updated?

Welchen commented 6 years ago

@DawidBester how come the switch from TTF to OTF?

jsmarcus commented 6 years ago

Mostly because the nuget process of bringing the font files into the projects is busted. I don’t think it’s ready until we have proper documentation for how to workaround the nuget bug.

From: Ryan Watson notifications@github.com Sent: Friday, May 25, 2018 4:47 PM To: jsmarcus/Iconize Iconize@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: Re: [jsmarcus/Iconize] compatibility with Xamarin Forms 3.0 (#68)

Curious, how come this in a CI Nuget feed and the normal Nuget feed is not being updated?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjsmarcus%2FIconize%2Fissues%2F68%23issuecomment-392181739&data=02%7C01%7C%7Cb8897884e80d4cec7f6608d5c280b90c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636628780463311797&sdata=6ItElb2aj8h72o1dl76WvZm0V1ucnwpMnm2k16XDWFg%3D&reserved=0, or mute the threadhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAB1LIPzxTdiQWlscWkCEttCjPCcKzcnHks5t2G3cgaJpZM4T27Ca&data=02%7C01%7C%7Cb8897884e80d4cec7f6608d5c280b90c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636628780463311797&sdata=k3Y4nR6a%2FZBQStAS2U4g0EwpnuFOyQFu7W3l9%2FQGUM0%3D&reserved=0.

aquisio commented 6 years ago

@jsmarcus The deployment procedure outlined by @DawidBester assumes that the font files will be installed manually into each of the platform projects (and I find that an acceptable compromise), but the Android version doesn't work at all, apparently because none of the Plugin.Iconize platform implementation is deployed to Android.

Is there something we can do to get Android working, even if it means manually adding font files until the Nuget packaging issue is resolved?

jsmarcus commented 6 years ago

Have you tried adding the nuget to the Android project directly (as well as the netstandard one). I am not having any problems with the plugin in Android (although I haven’t had to add it directly).

From: Tim Coulter notifications@github.com Sent: Saturday, May 26, 2018 11:52 AM To: jsmarcus/Iconize Iconize@noreply.github.com Cc: Jeremy Marcus jeremymarcus@msn.com; Mention mention@noreply.github.com Subject: Re: [jsmarcus/Iconize] compatibility with Xamarin Forms 3.0 (#68)

@jsmarcushttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjsmarcus&data=02%7C01%7C%7Ca4d6bedbb8ba475c03f908d5c320a5e7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636629467338839872&sdata=LzDmnSkm1smMxxB5AxmqA2V3nPSF9wc3zNDBxtjNi%2BQ%3D&reserved=0 The deployment procedure outlined by @DawidBesterhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FDawidBester&data=02%7C01%7C%7Ca4d6bedbb8ba475c03f908d5c320a5e7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636629467338839872&sdata=vkLzOYiyotw%2BI8jIM7IZQhh%2BvJSAWySbD0sjdRhaJw8%3D&reserved=0 assumes that the font files will be installed manually into each of the platform projects (and I find that an acceptable compromise), but the Android version doesn't work at all, apparently because none of the Plugin.Iconize platform implementation is deployed to Android.

Is there something we can do to get Android working, even if it means manually adding font files until the Nuget packaging issue is resolved?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjsmarcus%2FIconize%2Fissues%2F68%23issuecomment-392269944&data=02%7C01%7C%7Ca4d6bedbb8ba475c03f908d5c320a5e7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636629467338839872&sdata=unZ3koNDfoleI8170etZTj0BCnLXtiA5SHZjwbeXakc%3D&reserved=0, or mute the threadhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAB1LIMElMDD2AIGG9pPOPKKwXPbQp4__ks5t2XosgaJpZM4T27Ca&data=02%7C01%7C%7Ca4d6bedbb8ba475c03f908d5c320a5e7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636629467338839872&sdata=lGH1nijGjPWBBTcbsGv7809iTNpv1jECe3qK7iGjnOk%3D&reserved=0.

thudugala commented 6 years ago

@jsmarcus Can you publish the new 3.0.0.66 on nuget and add the instruction on "how to add the fonts to the projects".

Welchen commented 6 years ago

@jsmarcus Is there a reason you switched to use the OTF instead of the TTF? The file size of the TTF is smaller and seems like it would be better to use for mobile.

armaganX commented 6 years ago

how to add brands otf file to project.

armaganX commented 6 years ago

install Xam.Plugin.Iconize and Xam.Plugin.Iconize.FontAwesome v3.0.0.66 only into PCL project. file name: "iconize-fontawesome-brands.otf" App.xaml.cs: Plugin.Iconize.Iconize .With(new Plugin.Iconize.Fonts.FontAwesomeRegularModule()) .With(new Plugin.Iconize.Fonts.FontAwesomeBrandsModule()) .With(new Plugin.Iconize.Fonts.FontAwesomeSolidModule());

jsmarcus commented 6 years ago

@Welchen I hadn't looked at it specifically. The change came as part of a PR and it looked good. As you say the TTF is smaller and would be better so I will be changing it before a release to nuget.

kolchy commented 6 years ago

@aquisio did you get Android working with this new build? I'm in your situation where none of the icons render in Android :/

aquisio commented 6 years ago

@kolchy : Unfortunately, no. I am waiting for the Nuget release and hoping it will include a fix for this (as well as a reversion to TTF fonts, as others have requested).

kolchy commented 6 years ago

@aquisio I just started rolling my own pkg based on the source here, and realised my mistake. If you look at the icon codes here they have changed. I was still using fa-plus-circle for example. I ended up having to change that to far-plus-circle and it works :)

aquisio commented 6 years ago

@kolchy Thanks, but that doesn't seem to be my problem. I have used the new icon codes (as per procedure by @DawidBester above) but it stills works only on iOS and UWP. I'll stay patient and hope that it starts working when the Nuget update is released.

ChaseFlorell commented 6 years ago

Upon upgrading to the myget feed version, Android didn't even compile. I discovered it was pointing to the wrong folder, so I manually pointed it to the droid folder in the packages directory. Once I did that, it was able to resolve the renderer, and I was able to simply fix the Constructor issue and move forward.

UNFORTUNATELY, as soon as I ran the app, I ran into this.

06-08 11:11:23.709 E/Crash Report( 1876):   at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00017] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
06-08 11:11:23.709 E/Crash Report( 1876):   at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
06-08 11:11:23.709 E/Crash Report( 1876):   at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
06-08 11:11:23.709 E/Crash Report( 1876):   at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00213] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
06-08 11:11:23.709 E/Crash Report( 1876):   at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x000a1] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
06-08 11:11:23.709 E/Crash Report( 1876):   at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
06-08 11:11:23.709 E/Crash Report( 1876):   at Xamarin.Forms.Internals.Registrar`1[TRegistrable].GetHandler (System.Type type, System.Object[] args) [0x00051] in D:\agent_work\1\s\Xamarin.Forms.Core\Registrar.cs:56 
06-08 11:11:23.709 E/Crash Report( 1876):   at Xamarin.Forms.Internals.Registrar`1[TRegistrable].GetHandlerForObject[TOut] (System.Object obj, System.Object[] args) [0x0002c] in D:\agent_work\1\s\Xamarin.Forms.Core\Registrar.cs:92 
06-08 11:11:23.709 E/Crash Report( 1876):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Support.V4.App.FragmentManager fragmentManager, Android.Content.Context context) [0x00000] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\Platform.cs:356 
06-08 11:11:23.709 E/Crash Report( 1876):   at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) [0x00008] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:50 
06-08 11:11:23.709 E/Crash Report( 1876):   at Android.Support.V4.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_inflater, System.IntPtr native_container, System.IntPtr native_savedInstanceState) [0x00020] in <1e89c43d3c7d48b5ba69bfc0b1bdf114>:0 
06-08 11:11:23.709 E/Crash Report( 1876):   at (wrapper dynamic-method) System.Object.0e29e54e-857b-427e-9714-87fd202f0d3d(intptr,intptr,intptr,intptr,intptr)
06-08 11:11:23.709 E/Crash Report( 1876):    --- End of inner exception stack trace ---
06-08 11:11:23.718 E/AppCenterCrashes( 1876): Unhandled Exception:
06-08 11:11:23.718 E/AppCenterCrashes( 1876): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MissingMethodException: void Plugin.Iconize.IconTabbedPageRenderer..ctor(Android.Content.Context)
06-08 11:11:23.718 E/AppCenterCrashes( 1876):   at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)
06-08 11:11:23.718 E/AppCenterCrashes( 1876):   at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
06-08 11:11:23.718 E/AppCenterCrashes( 1876):    --- End of inner exception stack trace ---
06-08 11:11:23.718 E/AppCenterCrashes( 1876):   at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00017] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
06-08 11:11:23.718 E/AppCenterCrashes( 1876):   at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
06-08 11:11:23.718 E/AppCenterCrashes( 1876):   at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
06-08 11:11:23.718 E/AppCenterCrashes( 1876):   at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00213] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
06-08 11:11:23.718 E/AppCenterCrashes( 1876):   at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x000a1] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
06-08 11:11:23.718 E/AppCenterCrashes( 1876):   at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
06-08 11:11:23.718 E/AppCenterCrashes( 1876):   at Xamarin.Forms.Internals.Registrar`1[TRegistrable].GetHandler (System.Type type, System.Object[] args) [0x00051] in D:\agent_work\1\s\Xamarin.Forms.Core\Registrar.cs:56 
06-08 11:11:23.718 E/AppCenterCrashes( 1876):   at Xamarin.Forms.Internals.Registrar`1[TRegistrable].GetHandlerForObject[TOut] (System.Object obj, System.Object[] args) [0x0002c] in D:\agent_work\1\s\Xamarin.Forms.Core\Registrar.cs:92 
06-08 11:11:23.718 E/AppCenterCrashes( 1876):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Support.V4.App.FragmentManager fragmentManager, Android.Content.Context context) [0x00000] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\Platform.cs:356 
06-08 11:11:23.718 E/AppCenterCrashes( 1876):   at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) [0x00008] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:50 
06-08 11:11:23.718 E/AppCenterCrashes( 1876):   at Android.Support.V4.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_inflater, System.IntPtr native_container, System.IntPtr native_savedInstanceState) [0x00020] in <1e89c43d3c7d48b5ba69bfc0b1bdf114>:0 
06-08 11:11:23.718 E/AppCenterCrashes( 1876):   at (wrapper dynamic-method) System.Object.0e29e54e-857b-427e-9714-87fd202f0d3d(intptr,intptr,intptr,intptr,intptr)
06-08 11:11:23.800 I/eClient.Androi( 1876): Explicit concurrent copying GC freed 228(152KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 2MB/4MB, paused 51us total 27.055ms
06-08 11:11:23.965 W/eClient.Androi( 1876): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
ChaseFlorell commented 6 years ago

so setting something like this fixes the missing method exception

var x = new IconTabBarRenderer(Android.App.Application.Context);
dfarrNTST commented 6 years ago

@jsmarcus Is there an estimated time frame for a Xamarin Forms 3.0 compatible Release version of this in NuGet? (not the CI version)

czuck commented 6 years ago

Can we get an updated pre-release of the current version that will allow updating to Forms 3.1 without the changes for Font Awesome 5??

ClausElmann commented 6 years ago

Xam.Plugin.Iconize 3.2.0.74 was pushed to NuGet today