I am attempting to create a binding project for the StripeTerminal CocoaPod (Stripe Terminal iOS). I setup the pod file. Then using the Xamarin docs, I installed Objective Sharpie, and used
sharpie pod bind
which created two files. StripeTerminal_ApiDefinitions.cs and StripeTerminal_StructsAndEnums.cs. Those files look good and have the methods I am expecting when I was using a XCode project.
I then pointed added a Native Reference to the StripeTerminal framework file, but it seems a link file was not created. The Xamarin help documentions mention that a iOS Native Library ends in .a, while this framework does not. I tried pointing the native reference to the folder of the framework, to the extensionless library, and even renamed the library project to .a. Each time when I attempt to build it gives me an error of "No API definition file specified".
Your API definition file(s) should have a build action of ObjcBindingApiDefinition:
<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
</ItemGroup>
And your Enum|Structs file(s) should have a build action of ObjcBindingCoreSource:
<ItemGroup>
<ObjcBindingCoreSource Include="Structs.cs" />
</ItemGroup>
Related
Good afternoon,
I decided to play around with Xamarin today, and I've been having a few issues getting Vector images to work. I've followed the instructions here and have the following in my layout:
<ImageView
app:srcCompat="#drawable/fort"
android:layout_height="wrap_content"
android:id="#+id/imageView1" />
However, I get the following error at runtime:
Unhandled Exception: Java.Lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat. occurred
Throwing that error in Google, I get a few links, most notably, this StackOverflow post where most answers refer to the native Android SDK and include Gradle file modifications, but I'm not sure. I can't see any of the Gradle stuff from my VS project so I'm not sure I should edit them.
What should I do to fix this issue, is modifying the Gradle config the right answer?
Add the Xamarin.Android.Support.Vector.Drawable nuget package to your Xamarin.Android project.
NOTE: The Xamarin.Android.Support.Vector.Drawable nuget package contains a .targets file which appends the argument --no-version-vectors to AndroidResgenExtraArgs build property value to ensure the parameter is passed to the aapt invocation.
Which is basically the equivalent of editting the Gradle file. Information found here: https://components.xamarin.com/gettingstarted/xamandroidsupportvectordrawable?version=23.2.1
Where to define this command in csproj file?
bin\Debug\net47\MyApp.exe
I m using .net core 2.0.0 SDK. I m not getting RunCommand in Intellisense. Also while building my solution, I have 7 projects and main project is of type console application and its Output Type is EXE. Solution gets built successfully. While I press F5 it gives me MessageBox containing message like "Unable to run your project. The RunCommand is not defined."
How to solve this?
This is typically set by the SDK. Most likely you are targeting netstandard2.0 (was it a Class Library project that you later added a Main() to?). Try targeting the specific runtime+version - in your case netcoreapp2.0 or net47 - instead.
If you want to build both Core and Full Framework you can specify multiple target frameworks by separating them with a semicolon and changing the TargetFramework tag name to plural (TargetFrameworks):
<TargetFrameworks>net47;netcoreapp2.0</TargetFrameworks>
Alternatively, you should be able to specify a <RunCommand> inside <PropertyGroup> in your .csproj file. FWIW I can't seem to get anything to show up in Intellisense except the generic <PropertyName> and anything I've already added to the list.
An example would be:
<RunCommand>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).exe</RunCommand>
I need to add a Reference to a API in our multiplaform project for WinRT. If I add the reference it conflicts with the other plaforms - Win32 for example.
Is it possible to add a reference and make it invisible to other platforms somehow?
To solve this problem one needs to manually edit the project and add the necessary conditions to their project files by hand.
For example:
<ItemGroup Condition="'$(Platform)'=='Win32'">
<SDKReference Include="Chat API, Version=8.0" />
</ItemGroup>
I've been told by MS that they do not intend to add GUI support for SDKReferences.
I am getting this error when I try to compile my Xamarin.iOS app. I am referencing Catel.MVVM and Catel.Fody.
Any idea what to do?
MTOUCH: error MT0034: Cannot include both 'monotouch.dll' and 'Xamarin.iOS.dll' in the same Xamarin.iOS project - 'Xamarin.iOS.dll' is referenced explicitly, while 'monotouch.dll' is referenced by 'Catel.MVVM, Version=4.4.0.0, Culture=neutral, PublicKeyToken=null'.
One of your project parts uses the UnifiedAPI (Xamarin.iOS.dll) and another one uses the Classic API (monotouch.dll). They can not be both part of the project.
You goal should be to use the UnifiedAPI/ Xamarin.iOS.dll instead of the old monotouch assembly because with the new one you are able to get your app in the store. Xamarin Studio is able to convert your project to the UnifiedAPI. I am not sure but take a look under Project > "Convert to UnifiedAPI" or something like that.
I created a Xamarin iOS binding project that requires the following frameworks:
SystemConfiguration.framework
CoreTelephony.framework
libz.dylib
libsqlite3.dylib
I added the following line in my iOS binding project to the linkwith.cs file:
Frameworks = "SystemConfiguration CoreTelephony"
This seems to work correctly and tells that project to include these frameworks when binding. From what I have read, it sounds like the remaining 2 libraries need to be added as linker flags in the project referring to the DLL generated from my iOS binding project. So I created a test app, imported the DLL, and now need to add the linker flags but my project cannot find the right libraries.
My linker flags in Xamarin Studio are as follows:
-gcc_flags "-lz -lsqlite3.0"
When I build my Xamarin test app I get a few errors regarding the frameworks that cannot be found. Are there additional flags that need to be linked or do I need to do some additional configuration in my iOS binding project?
I found a great resource: http://ipixels.net/blog/specify-extra-gcc-flags-for-native-library-binding-in-xamarin-ios/
I needed to add LinkerFlags = "-lz -lsqlite3.0" to my .linkwith.cs file. I then rebuilt the library to generate a new DLL and added this to my test app. The test app builds correctly then.
If you are creating your bindings for a cocoapod using sharpie:
sharpie pod init ios nameOfCocoaPod
sharpie pod bind
you get a nameOfCocoaPod.framework file and .cs-binding files.
The nameOfCocoaPod.framework file should be added to your binding project under Native References. To change e.g. Frameworks or LinkerFlags, right-click and open properties.