You should be able to create a bindings library for either "modern" or "full" frameworks, and compile them.
It only works for the "modern" framework.
=== Visual Studio Professional 2017 for Mac ===
Version 7.3.3 (build 23)
Installation UUID: d9050f0b-87f7-4e38-9d83-c01eaf2f82fc
Runtime:
Mono 5.4.1.7 (2017-06/e66d9abbb27) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 504010007
=== NuGet ===
Version: 4.3.1.4445
=== .NET Core ===
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.0.5
2.0.0
2.0.0-preview1-002111-00
2.0.0-beta-001791-00
1.1.1
1.1.0
1.0.4
SDK: /usr/local/share/dotnet/sdk/2.1.4/Sdks
SDK Versions:
2.1.4
2.0.0
2.0.0-preview1-005977
2.0.0-preview1-005645
1.0.1
1.0.0-preview2-1-003177
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin/Sdks
=== Xamarin.Profiler ===
Version: 1.6.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Apple Developer Tools ===
Xcode 9.2 (13772)
Build 9C40b
=== Xamarin.iOS ===
Version: 11.6.1.4 (Visual Studio Professional)
Hash: db807ec9
Branch: xcode9.2
Build date: 2018-01-10 16:45:48-0500
=== Xamarin.Android ===
Not Installed
=== Xamarin.Mac ===
Version: 4.0.0.216 (Visual Studio Professional)
=== Xamarin Inspector ===
Version: 1.4.0
Hash: b3f92f9
Branch: master
Build date: Fri, 19 Jan 2018 22:00:34 GMT
Client compatibility: 1
=== Build Information ===
Release ID: 703030023
Git revision: e02ab111d8181ffe766c2258141282c88188ebb6
Build date: 2018-02-20 08:06:38-05
Xamarin addins: 5ce2b6790676a4542aa0d69d07f6a716e17d4e65
Build lane: monodevelop-lion-d15-5
=== Operating System ===
Mac OS X 10.13.3
Darwin 17.4.0 Darwin Kernel Version 17.4.0
Sun Dec 17 09:19:54 PST 2017
root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64
=== Enabled user installed addins ===
AddinMaker 1.4.2
RhinoCommon Plugin Support 7.3.3.0
Internet of Things (IoT) development (Preview) 7.1
Building Solution: MyBindingProject (Debug)
__________________________________________________
Project "/Users/curtis/Projects/MyBindingProject/MyBindingProject/MyBindingProject.csproj" (Build target(s)):
/Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(2003,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Xamarin.Mac". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/bin/bgen -nostdlib /v /baselib:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/Xamarin.Mac.dll /unsafe /d:"__UNIFIED__;__MACOS__;DEBUG" /Users/curtis/Projects/MyBindingProject/MyBindingProject/ApiDefinition.cs /s:/Users/curtis/Projects/MyBindingProject/MyBindingProject/StructsAndEnums.cs -r /mscorlib.dll -r /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/4.5-api/System.Core.dll -r /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/4.5-api/System.dll -r /mscorlib.dll /tmpdir:/Users/curtis/Projects/MyBindingProject/MyBindingProject/obj/Debug/mac/ /sourceonly:/Users/curtis/Projects/MyBindingProject/MyBindingProject/obj/Debug/mac/sources.list /target-framework=Xamarin.Mac,Version=v4.5,Profile=Full
BTOUCH : error CS0006: Metadata file `/mscorlib.dll' could not be found
BTOUCH : error CS0006: Metadata file `/mscorlib.dll' could not be found
BTOUCH : error CS1703: An assembly `System' with the same identity has already been imported. Consider removing one of the references
BTOUCH : error CS1703: An assembly `System.Core' with the same identity has already been imported. Consider removing one of the references
BTOUCH : error CS0518: The predefined type `System.Object' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.ValueType' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Attribute' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Int32' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.UInt32' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Int64' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.UInt64' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Single' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Double' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Char' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Int16' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Decimal' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Boolean' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.SByte' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Byte' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.UInt16' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.String' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Enum' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Delegate' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.MulticastDelegate' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Void' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Array' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Type' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Collections.IEnumerator' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Collections.IEnumerable' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.IDisposable' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.IntPtr' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.UIntPtr' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.RuntimeFieldHandle' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.RuntimeTypeHandle' is not defined or imported
BTOUCH : error CS0518: The predefined type `System.Exception' is not defined or imported
Done building project "MyBindingProject.csproj" -- FAILED.
---------------------- Done ----------------------
Build: 35 errors, 1 warning
I can confirm this brokenness.
I'm looking into how this got past our testing and a work around now.
This should absolutely work, full stop.
So this was found (by me actually) in https://bugzilla.xamarin.com/show_bug.cgi?id=59930 and is fixed in 15.6, which is in Alpha/Beta channel.
Our testing didn't point out the brokeness since we were using pre-created test projects before the regression.
There are two ways of working around this bug:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7ED3EB7D-9925-446A-932E-9CC8F38BE9D9}</ProjectGuid>
<ProjectTypeGuids>{810C163F-4746-4721-8B8E-88A3673A62EA};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>MyBindingProject</RootNamespace>
<AssemblyName>MyBindingProject</AssemblyName>
<MacResourcePrefix>Resources</MacResourcePrefix>
<UseXamMacFullFramework>True</UseXamMacFullFramework>
</PropertyGroup>
I just confirmed that Version 7.4 Preview (7.4 build 1026) works if you load the existing project and re-target the Full framework in the binding project.
Sorry again for the trouble.
@chamons Thanks for the response, but this is still not working 100%. I have updated to the Beta channel and have confirmed that the csproj has:
<UseXamMacFullFramework>True</UseXamMacFullFramework>
It now builds, but it is not getting built with the correct target (notice TargetFramework should be .NETFramework,Version=v4.5):

Also, in VS for Mac it shows that it is an incompatible framework with the Xamarin.Mac full app:

In looking at Xamarin.Mac.ObjCBinding.CSharp.props, it doesn't appear to handle the "Full" framework at all, and just defaults it to "Mobile".
Just FYI is my hack to make this work correctly on Beta or Stable channels in the binding csproj:
<PropertyGroup>
<!-- use these properties to compile an ObjectiveC binding project for XamMac Full. Remove if/when UseXamMacFullFramework is supported. -->
<TargetFrameworkName>Full</TargetFrameworkName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<XamarinMacFrameworkRoot>/Library/Frameworks/Xamarin.Mac.framework/Versions/Current</XamarinMacFrameworkRoot>
<AssemblySearchPaths>$(XamarinMacFrameworkRoot)/lib/mono/4.5;$(AssemblySearchPaths)</AssemblySearchPaths>
<MacBclPath>$(XamarinMacFrameworkRoot)/lib/mono/4.5</MacBclPath>
<TargetFrameworkDirectory>$(MacBclPath);@(DesignTimeFacadeDirectories)</TargetFrameworkDirectory>
</PropertyGroup>
So a few things:
With no TargetFrameworkVersion set, I can build the entire solution, and even reference code in the binding assembly:
MyBindingProject.Foo f = MyBindingProject.Foo.a;
System.Console.WriteLine (f);
with no trouble.
It does appear we're getting "lucky" however, as the csc invocation is wrong:
/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/mono/4.5/csc.exe /noconfig /unsafe+ /nowarn:1701,1702,2008 /nostdlib+ /errorreport:prompt /warn:4 /define:__UNIFIED__;__MACOS__;DEBUG /errorendlocation /preferreduilang:en-US /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/mscorlib.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/System.Core.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/System.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/Xamarin.Mac.dll /debug+ /debug:portable /optimize- /out:obj/Debug/MyBindingProject.dll /target:library /utf8output Properties/AssemblyInfo.cs StructsAndEnums.cs /Users/donblas/Downloads/MyBindingProject-1/MyBindingProject/obj/Debug/mac/ObjCRuntime/Messaging.g.cs "/var/folders/gc/7vct49652r1df_tp36ffvph00000gn/T/Xamarin.Mac,Version=v2.0.AssemblyAttributes.cs"
So I'm going to reopen and figure out what's wrong.
Beyond the cosmetic "red X", is anyone seeing behavior issues with bindings projects with UseXamMacFullFramework set? Can you attach an example project.
@chamons yes it is lucky for this particular instance, as our actual project doesn't compile as it's referencing the mobile BCL vs. the .net 4.5 BCL. Thanks for taking another look!
The logic in ObjCBinding.CSharp.props is stale, as you noted. Working on a patch now.
While hacking on this I noticed - https://github.com/xamarin/xamarin-macios/issues/3654
Things really were stale/a mess. I have an initial rough patch here that successfully builds/links: https://github.com/chamons/xamarin-macios/commit/d97762ac2242be848b0cf98fb06a691cbbedfc69
I'll obviously need to clean up duplication, tests and the like before PR. I'll post here when I have something more showable.
Should be fixed in latest master. You can get a copy from the locations listed at https://github.com/xamarin/xamarin-macios/wiki#continuous-builds if you'd like to test it early.
Thanks for the quality bug report and feedback. It made tracking down this mess significantly easier.
@chamons AFAICS you closed the issue with only a commit to master while the milestone is d15-7
@spouliot Apologies, I forgot to update.
This fix involved refactoring the msbuild significantly, and it was the one I mentioned I was not comfortable cherry-picking into d15-7.
It turns out my paranoia was correct, as there is a report of internal breakage on a binding project already (that I'm going to look at today).
There is an (ugly) work around https://github.com/xamarin/xamarin-macios/issues/3608#issuecomment-370035492 so I see no need to force a messy fix into 15-7 currently.
Turns out this was more difficult than expected, after knowing that msbuild changes are treacherous. Reworking now.
From the master branch (master branch), I saw the commit for "Rework XM Binding Projects (commit)" but you also reverted it later.
Can I still build master branch and use it or I need to use a different branch or commit.
So you could build _before_ the revert or wait until https://github.com/xamarin/xamarin-macios/pull/3738 lands (or just check out that branch from my fork).
After landing the first attempt, I realized that the problem was more complicated, since there were plenty or forms of projects in the wild, more than I was originally testing.
Thanks, Chris. And I am pretty new to use Xamarin Mac. I am trying to download a specific build following this.
"If you go to our commits page you should be able to see a green checkmark (✔) or a red cross mark (✘) at the right side of the committer's handle. If you click the green checkmark (✔) you should see a details link which will provide download links for both Xamarin.iOS and Xamarin.Mac packages for that specific commit."
However, I don't have a Microsoft account that has permission to download Xamarin.Mac packages files. So now I am trying to build it locally but the script takes a very long time each time.
Is there a way to get access to download specific version and that would be better for me to test my project.
When you build locally make sure to ./configure --disable-ios if you just want macOS. The XI section of the build drastically increases build time.
You should be able to grab the package once it hits master (that shouldn't require any permissions).
@chamons Hi Chris, I have combined the workaround provided with @cwensley and local build of Xamarin.Mac including the temporary fix. I still have that red cross for Xamarin.Mac reference in my binding project.
But now I can build my solution successfully and call Objective-C native code using my c# binding interface.
I am still waiting for the fix to hit the master. But thanks a lot for this solution you provided for now.
The red cross is a known cosmetic issue that you can ignore.
QA just approved my change last night, so assuming the build machine decide to play nice it'll land today.
I noticed that this is merged into master. But the latest release Xamarin.Mac 4.4 which is based on branch d15-7 which I think doesn't include the fix on master.
Do we have a date to release the package file build from master (or contains this fix)?
Right now I am using my local build Xamarin.Mac and Mono.framework 5.10 without error but I tried to give both frameworks to other teammate to build the solution but it will generate some errors with "Xamarin.Mac.ObjCBinding.CSharp.targets" saying that 'bgen' exited with code 2.
Yes, it takes awhile before master makes it "out" as a release. There is a lot of testing and such that happens.
We can "cherry-pick" safe and high priority fixes to release branches, but considering this fix involved rewriting large chunks of the msbuild logic, I do not consider it safe.
A few things:
@chamons Hello Chris, do you have a plan to release d15-8.
I am still waiting to use an official build to use instead of using local build Xamarin.Mac.
Yes, 15-8 is scheduled, but it looks to be awhile still until it hits stable. You can read about it here - https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2017-release-rhythm
Since we release along side VS/VS for Mac/Xamarin.iOS/etc, those releases only happen a few times a year.
However, there is a preview 15-8 in Alpha that I believe should have the fix (https://dl.xamarin.com/XamarinforMac/Mac/xamarin.mac-4.5.0.280.pkg).