WebSocket4Net cannot Nuget dependency to iOS proje

2019-08-21 16:59发布

问题:

I am trying to install WebSocket4Net to my iOS/Android project in Xamarin.

When I add it to the Android project everything works great. When I try to add it to the iOS project I see this...

Install-Package : Could not install package 'WebSocket4Net 0.12'. You are trying to install this package into a project that targets 'Xamarin.iOS,Version=v1.0', 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:1 char:1
+ Install-Package WebSocket4Net
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

Am I on too old/too new of a project to add this perhaps?

回答1:

You are currently working on a Unified iOS project, while the NuGet package does not contain such an assembly. Quite similarly an issue was documented,

http://blog.alectucker.com/post/2015/01/19/sqlite-error-with-xamarinios-unified-api.aspx

Kerry has the Unified iOS support done already in code base,

https://github.com/kerryjiang/WebSocket4Net

So you either wait for an updated NuGet package, or simply use the source code directly.