xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

custom iOS Renderers won't compile when using MSBuild.Sdk.Extras since 4.5.0.396 #9995

Closed MariovanZeist closed 4 years ago

MariovanZeist commented 4 years ago

Description

In my Xamarin projects, I use the great MSBuild.Sdk.Extras package to be able to easily create multitargeted libraries. But since the latest Xamarin version, there seems to be a problem. I am not sure if the problem is related to MSBuild.Sdk.Extras or Xamarin, although the previous version of Xamarin did work, so something must have changed.

The problem is related to transitive dependencies. I have 1 library where I reference Xamarin.Forms, my other libraries will reference that library, so they get the Xamarin.Forms library as a transitive dependency. (That way I only update 1 package, and all my related libraries will reference the correct Xamarin.Forms version)

in 4.5.0.396, for iOS it won't find the Xamarin.Forms.Platform.iOS namespace. So my custom renderers won't compile. It does work for Android. (Haven't tested UWP)

Steps to Reproduce

  1. Clone https://github.com/MariovanZeist/XamRepro
  2. Compile

Expected Behavior

Both libraries compile.

Actual Behavior

The iOS version doesn't compile

Basic Information

Reproduction Link

https://github.com/MariovanZeist/XamRepro

Workaround

When referencing "Xamarin.Forms" Version="4.5.0.396" directly in the Xam.Controls library the library will compile.

PureWeen commented 4 years ago

@MariovanZeist to maintain backwards compatibility with VS 2017 we had to add some trickery into our forms.targets file

I'll need to look into seeing if we can make this work transitively with ios

MariovanZeist commented 4 years ago

@PureWeen Not sure if it's related, but in the .nuspec/Xamarin.Forms.targets file at line 211 and 216, I think the hintpath will result in a path with a double \

$(MSBuildThisFileDirectory)**\XCODE10**\$(FrameworkDll)

I think $(MSBuildThisFileDirectory) already has a trailing \

I saw this when I was rummaging through a MSBuild log when investigating this issue.

Jacko1394 commented 4 years ago

4.5.0.396 is useless for me also... Xamarin.Forms.Platform.iOS namespace don't exist.

MariovanZeist commented 4 years ago

@Jacko1394 If you reference Xamarin.Forms directly in the library that needs the Xamarin.Forms.Platform.iOS namespace it will work.

MariovanZeist commented 4 years ago

I will close this issue for now, as it seems to be fixed in the next release. Will reopen when the problem persists.

Thanks @PureWeen

MariovanZeist commented 4 years ago

Verified fixed in version 4.5.0.530