xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.48k stars 515 forks source link

Xamarin binding project on iOS fails to integrate in the projects of the same solution #16299

Closed mdima closed 1 year ago

mdima commented 2 years ago

Steps to Reproduce

  1. Open the project at https://github.com/mdima/Test.ZoomBinding;
  2. Start compiling the project ZoomSDKSampleApp.iOS and it will fail, because VS doesn't find the objects inside the binding library (MobileRTC_iOS);
  3. Also if you browse the "Class view" of the project ZoomSDKSampleApp.iOS, the referenced library Zoomios is empty.
  4. Anyway, the MobileRTC_iOS project compile successfully. If you remove the project reference to MobileRTC_iOS inside the project ZoomSDKSampleApp.iOS and you add the DLL generated from the binding project (Zoomios.dll), the project ZoomSDKSampleApp.iOS will compile successfully and the Class view will regularly show the classes exposed by the binding project.

Expected Behavior

The expected behavior is that the functions exposed by the project MobileRTC_iOS are usable by the project ZoomSDKSampleApp.iOS using a project reference.

Actual Behavior

Now it is necessary to reference the DLL generated by the project, not the project itself.

Environment

Version information Microsoft Visual Studio Professional 2022 Version 17.3.5 VisualStudio.17.Release/17.3.5+32922.545 Microsoft .NET Framework Version 4.8.04084 Installed Version: Professional Visual C++ 2022 00476-80000-00000-AA020 Microsoft Visual C++ 2022 ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools ASA Service Provider 1.0 ASP.NET and Web Tools 17.3.376.3011 ASP.NET and Web Tools ASP.NET Web Frameworks and Tools 2012 17.3.376.3011 For additional information, visit https://www.asp.net/ Azure App Service Tools v3.0.0 17.3.376.3011 Azure App Service Tools v3.0.0 Azure Data Lake Tools for Visual Studio 2.6.5000.0 Microsoft Azure Data Lake Tools for Visual Studio Azure Functions and Web Jobs Tools 17.3.376.3011 Azure Functions and Web Jobs Tools Azure Stream Analytics Tools for Visual Studio 2.6.5000.0 Microsoft Azure Stream Analytics Tools for Visual Studio Bridge to Kubernetes 0.1 Bridge to Kubernetes for Visual Studio 2019 Bundler & Minifier 2.9.3 Adds support for bundling and minifying JavaScript, CSS and HTML files in any project. C# Tools 4.3.0-3.22470.13+80a8ce8d5fdb9ceda4101e2acb8e8eb7be4ebcea C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Cookiecutter 17.0.22179.3 Provides tools for finding, instantiating and customizing templates in cookiecutter format. Dotfuscator Community Edition 6.5.0+76d4669002 PreEmptive Protection - Dotfuscator CE Extensibility Message Bus 1.2.6 (master@34d6af2) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. Linux Core Dump Debugging 1.0.9.32708 Enables debugging of Linux core dumps. Microsoft Azure Hive Query Language Service 2.6.5000.0 Language service for Hive query Microsoft Azure Stream Analytics Language Service 2.6.5000.0 Language service for Azure Stream Analytics Microsoft Azure Tools for Visual Studio 2.9 Support for Azure Cloud Services projects Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Mono Debugging for Visual Studio 17.3.20 (3f4cb00) Support for debugging Mono processes with Visual Studio. Node.js Tools 1.5.40629.1 Commit Hash:3f5cc0329815af3ffb948f08857446d206a9af36 Adds support for developing and debugging Node.js apps in Visual Studio NuGet Package Manager 6.3.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ Office Developer Tools for Visual Studio 17.0.32616.00 Microsoft Office Developer Tools for Visual Studio Python - Django support 17.0.22179.3 Provides templates and integration for the Django web framework. Python - Profiling support 17.0.22179.3 Profiling support for Python projects. Python with Pylance 17.0.22179.3 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers. Razor (ASP.NET Core) 17.0.0.2232702+e1d654e792aa2fe6646a6935bcca80ff0aff4387 Provides languages services for ASP.NET Core Razor. SQL Server Data Tools 17.0.62207.04100 Microsoft SQL Server Data Tools SQLite & SQL Server Compact Toolbox 4.8 SQLite & SQL Server Compact Toolbox adds scripting, import, export, rename, query execution and much more to SQL Server Compact & SQLite Data Connections. Syntax Visualizer 1.0 An extension for visualizing Roslyn SyntaxTrees. Test Adapter for Boost.Test 1.0 Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory. Test Adapter for Google Test 1.0 Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory. ToolWindowHostedEditor 1.0 Hosting json editor into a tool window TypeScript Tools 17.0.10701.2001 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 4.3.0-3.22470.13+80a8ce8d5fdb9ceda4101e2acb8e8eb7be4ebcea Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual C++ for Cross Platform Mobile Development (Android) 17.0.32708.82 Visual C++ for Cross Platform Mobile Development (Android) Visual C++ for Cross Platform Mobile Development (iOS) 17.0.32819.101 Visual C++ for Cross Platform Mobile Development (iOS) Visual C++ for Linux Development 1.0.9.32708 Visual C++ for Linux Development Visual F# Tools 17.1.0-beta.22363.4+1b94f89d4d1f41f20f9be73c76f4b229d4e49078 Microsoft Visual F# Tools Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio. Visual Studio Tools for Unity 17.3.0.0 Visual Studio Tools for Unity VisualStudio.DeviceLog 1.0 Information about my package VisualStudio.Mac 1.0 Mac Extension for Visual Studio Workflow Manager Tools 1.0 1.0 This package contains the necessary Visual Studio integration components for Workflow Manager. Xamarin 17.3.0.308 (d17-3@56b9f7e) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 17.3.0.217 (remotes/origin/d17-3@b81db1dcc0) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 17.2.28 (9b3d244) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 13.0.0.0 (d17-3/030cd63) Xamarin.Android Reference Assemblies and MSBuild support. Mono: dffa5ab Java.Interop: xamarin/java.interop/d17-3@7716ae53 SQLite: xamarin/sqlite/3.38.5@df4deab Xamarin.Android Tools: xamarin/xamarin-android-tools/main@14076a6 Xamarin.iOS and Xamarin.Mac SDK 16.0.0.75 (e4f48bed7) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Build Logs

1>C:\Users\Michele DM\Documents\GitHub\Test.ZoomBinding\ZoomSDKSampleApp.iOS\iOSZoomSDKService.cs(112,28,112,49): error CS0246: The type or namespace name 'MobileRTCAuthDelegate' could not be found (are you missing a using directive or an assembly reference?) 1>C:\Users\Michele DM\Documents\GitHub\Test.ZoomBinding\ZoomSDKSampleApp.iOS\iOSZoomSDKService.cs(9,38,9,70): error CS0246: The type or namespace name 'IMobileRTCMeetingServiceDelegate' could not be found (are you missing a using directive or an assembly reference?) 1>C:\Users\Michele DM\Documents\GitHub\Test.ZoomBinding\ZoomSDKSampleApp.iOS\iOSZoomSDKService.cs(12,17,12,37): error CS0246: The type or namespace name 'MobileRTCAuthService' could not be found (are you missing a using directive or an assembly reference?)

Example Project (If Possible)

I created a sample project here: https://github.com/mdima/Test.ZoomBinding

chamons commented 2 years ago

This is because your combining a .NET 6 iOS Project:

% cat ZoomSDKSampleApp/ZoomSDKSampleApp.csproj | head -n1

<Project Sdk="Microsoft.NET.Sdk">

with an legacy binding project:

% cat MobileRTC_iOS/MobileRTC_iOS.csproj | head -n5

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

Try converting your binding project to NET6 and see if the behavior improves.

ghost commented 2 years ago

Hi @mdima. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

mdima commented 2 years ago

Hi, well... I was searching the documentation and trying this a lot, but still in a NET6 binding project I am not able to reference a native iOS framework... Does anyone knows any guide about that?

Also: I understand that most of the effort is on NET6 and Maui, but the issue is on Xamarin Forms, at least XF became not supported I should make it run on that environment.

Thanks, Michele

rolfbjarne commented 1 year ago

Hi, well... I was searching the documentation and trying this a lot, but still in a NET6 binding project I am not able to reference a native iOS framework...

This should work just fine in a .NET binding project:

https://github.com/mdima/Test.ZoomBinding/blob/2b0067bf4286b784caa72e85f7fe4b226c630472/MobileRTC_iOS/MobileRTC_iOS.csproj#L255-L258

Please let us know if this works.

Also: I understand that most of the effort is on NET6 and Maui, but the issue is on Xamarin Forms, at least XF became not supported I should make it run on that environment.

Xamarin.Forms isn't supported in .NET, you'll have to upgrade to MAUI.

ghost commented 1 year ago

Hi @mdima. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost commented 1 year ago

Hi @mdima. Due to inactivity, we will be closing this issue. Please feel free to re-open this issue if the issue persists. For enhanced visibility, if over 7 days have passed, please open a new issue and link this issue there. Thank you.