I am trying to port cocoapods to xamarin.
Objective C based cocoapods can be ported by converting it into a static library(.a) and subsequently converting that as binding library in xamarin studio or visual studio
But Swift based cocoapods can not be converted into a static library and so it can't be ported to xamarin.
but swift can be converted into a dynamic framework but I couldn't find any way to port that to xamarin
Is there any other way to port swift based cocoapods or ios project into xamarin ?
Binding a Swift Library in Xamarin.iOS follows the same process for Objective-C as shown in xamarin documentation
but with some caveats.
A swift class must inherit from NSObject to be binded.
Swift compiler will translate class and protocol names into something else, so you must specify the final name in the
ApiDefinition.
In runtime your APP must include some swift core libraries alongside your binded framework in a folder called Frameworks;
When the App is pushed to AppStore it must include a SwiftSupport folder alongside your Payload folder. Those are inside the IPA file.
Here you can find a simple sample binding: https://github.com/Flash3001/Xamarin.BindingSwiftLibrarySample
And a full binding sample: https://github.com/Flash3001/iOSCharts.Xamarin
Related
I'm currently looking at Maui as the replacement for Xamarin Forms.
I currently have an Android class library for the Camera2 api that I would like to reuse.
How can I set up a Maui project that includes platform dependent class libraries?
So that when building and Android version I use the Android version of the class library. When building for Window I get the Windows version and IOS, I get the IOS version.
I think I figured it out.
A Maui class library appears to be divided into platform specific sections plus a common section. So it appears I put the platform related code into the specific platform section and interface through the common section.
I am trying to make use of an swift based iOS Framework in xamarin.iOS
But after some research, I found that xamarin doesn't support swift language using Embedding Mono too.
How can I make use of Framework in Xamarin.iOS ?
Binding Objective C based static library is officially supported in Xamarin.
But there is no official support for Swift based framework in Xamarin.iOS
You can import Swift based framework in Objective C based project and
you can expose the APIs using Objective C and you can convert that into .a static library then you can turn that static library into a binding library in xamarin studio and make use of that in xamarin
Try porting the Swift to C# and it should be faster as well
My understanding is the compiler directives in a Share Access Project (SAP) make use of platform specific code.
For SAP Xamarin has,
Application projects can include platform-specific references that the
shared code can utilize (such as using Community.CsharpSqlite.WP7 in
the Tasky sample for Windows Phone).
https://developer.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/sharing_code_options/#Shared_Projects
I didn't see anything on this page for PCL about not writing platform specific code. If I include the Xamarin Android library in the PCL, is that not specific code that would be in a SAP?
Does it mean that I could tweak or have some feature on Android and Windows Phone that I couldn't on iOS (maybe iOS didn't support it?)
EDIT: What does it look like to access the camera, for example, from PCL via DI, vs accessing the camera in a SAP (platform doesn't matter; Android is fine.)
I have a WPF application that uses a F# library for calculations. I'm trying to refactor so that I have WPF Application -> C# Portable Class Library (models) -> F# Portable Class Library (calculations).
My end goal is to use Xamarin Forms to put a UI on it that I can use on other platforms. This is currently mostly an experiment to assess the viability of the approach.
Every time I try to add a reference to the F# library from the C# library, I get an error message that says "Unable to add reference to X, Portable class libraries can only reference other portable class libraries".
I can reference either library from the WPF project and I've tried every permutation that I can think of to make it work.
There are quite a few similar questions, but they either don't have an answer or state that it is fixed in VS 2013. It doesn't seem to work in VS 2015 Update 2.
Does anyone have a link to a sample that works, or a workaround to get past the problem?
Steps for VS 2015 Update 2:
Create new(tested with new solution) Class Library (Portable)
As target choose only Windows 10 or Windows 8.1(maybe other target would work too - haven't tested though)
Add F# Portable Library(tested with .Net 4.5, Windows Store, Xamarin
and with .Net 4.5, Windows Store, Silverlight 5, Xamarin)
Now you can reference F# library without any errors
Now You can change properties of C# project(Right click on c# project and
choose properties) to match the targets You would like to have (Section Library, subsection Targeting)
I would like to use an android project in xamarin for example this one: https://github.com/jaydeepw/poly-picker
This project is written in java and has resources and activities.
As far as I understand it is not possible to compile such a project into a jar and then to create a binding library.
Is this correct?
What options do exist to use such a project, apart from porting the source code?
Unfortunately, only you can binding Java libraries, not apps.
You can read this post:
https://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)/