locked
Tool for import XCode-Project RRS feed

  • Question

  • User228883 posted

    Hello,

    i created an Cross-Platform App for Android and iOS. My Problem now is, that I want to implement an XCode-Project. How can I do that or is there a possibility to Import an Project like this ?

    In the XCode-Project there is some Code which I want to use in my Xamarin.Forms Project.

    Do you have any idea to do that ?

    Tuesday, July 24, 2018 11:08 AM

Answers

  • User21936 posted

    @PhilippWegener said: Is it Right, that I can at least Import the .a file or Xamarin.iOS Binding Library in my Xamarin.Forms Portable Project and use the Methods?

    No. Your Xamarin.iOS Binding library ( or .a file) cannot be referenced by the Xamarin.Forms Portable (or .NET Standard) project directly because the Portable (or .NET Standard) project has no way of referencing the Xamarin.iOS SDK assemblies. So the iOS Binding Library project has to be referenced by an iOS App (or iOS Class Library) project. To call into code in the iOS Binding library from the Xamarin.Forms Portable project you would then need to use a Dependency Service that will allow you to call into methods in your Xam.iOS app project, which would have a reference to your iOS Binding Library.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, September 12, 2018 6:17 PM

All replies

  • User21936 posted

    @PhilippWegener

    I am not sure 100% what you are asking. You have a cross platform app for iOS and Android, that I get, and I assume you mean this is a Xamarin Cross-Platfrorm app, is that correct?

    Assuming that is correct you say that you now want to implement an Xcode project and then import it into your Xamarin Cross-Platform app. Is that correct? If so, my first question is why? Anything you can do in XCode you can do in Xamarin.iOS, IOW the entire iOS SDK is available in Xamarin. Every iOS, class, control, protocol etc. is available in Xamarin.iOS. So you could create your iOS specific library as a Xamarin.iOS library project rather than an XCode project and then use Dependency Injection (DependencyService) to access that Xam.iOS library from Xamarin.Forms core project.

    That said, you basically have two options to bring an XCode project into a Xamarin iOS project.

    1. Port the Obj-C / Swift code to C# code, which means basically re-writing the functionality in the XCode project in Xamarin.iOS, i.e. what I suggested above.
    2. Bind the Obj-C library, i.e. XCode project, (currently you cannot directly bind swift, but you can wrap your swift code in Obj-C wrappers and then bind to those Ob-C wrappers to C#) and then reference the binding from your Xam.iOS project. You will still need to use Dependency Injection (DependencyService) to access code from the bound iOS library in your Xam.Forms core project.

    Also moving this post to Xamarin.iOS as that is the more appropriate category for this thread.

    Wednesday, August 1, 2018 1:55 AM
  • User228883 posted

    @JGoldberger

    Yes, you understand it Right.

    I have to implement this Code because I dont want to rewrite the Code and use the functions.

    I think your second answer is what i want to do. Because in the first answer, i have to rewrite the Obj-C/Swift Code, that is not what i want to do. I want to implement the Obj-C Project in my Cross-Platfrom Project. Is there a description how to implement a Project like this?

    In my Cross-Plattform App I know how to use DependencyService.

    Thursday, September 6, 2018 8:34 AM
  • User21936 posted

    @PhilippWegener

    I would start with these documents to get you going: https://docs.microsoft.com/en-us/xamarin/ios/platform/binding-objective-c/ https://docs.microsoft.com/en-us/xamarin/cross-platform/macios/binding/

    Once you get your binding project built and working, you can reference it from your iOS app project and call into it from Forms core code using a DependencyService.

    Saturday, September 8, 2018 12:19 AM
  • User228883 posted

    @JGoldberger

    I have created an .a file and imported this file in my Xamarin.iOS Project. How can I call a method from the .a file? Is there a possibility to do it in Portable Project or in .iOS Project?

    Tuesday, September 11, 2018 1:40 PM
  • User21936 posted

    @PhilippWegener said:

    I have created an .a file and imported this file in my Xamarin.iOS Project. How can I call a method from the .a file? Is there a possibility to do it in Portable Project or in .iOS Project?

    Did you read through the guides I sent you above? You have to create a Xamarin.iOS Binding Library project to add the .a file to. You also need to use Objective-Sharpie to bootstrap the C# wrappers that you will eventually use to call into your library. All of this is outlined in the links I sent.

    In the first link above, there is a link to a walk through that should take you step by step through the process.

    Please do note that creating bindings can be simple or difficult largely depending on the library that is being bound and how complex and/or well formed it is. But a good start is to go through that walk through using your own .a file instead of the one being used in the walkthrough.

    You will need to know what iOS frameworks and/or other native libraries that your static library (.a) depends on as well. Some familiarity with Objective-C is helpful as well.

    Wednesday, September 12, 2018 12:18 AM
  • User228883 posted

    @JGoldberger Is it Right, that I can at least Import the .a file or Xamarin.iOS Binding Library in my Xamarin.Forms Portable Project and use the Methods?

    Wednesday, September 12, 2018 6:08 AM
  • User21936 posted

    @PhilippWegener said: Is it Right, that I can at least Import the .a file or Xamarin.iOS Binding Library in my Xamarin.Forms Portable Project and use the Methods?

    No. Your Xamarin.iOS Binding library ( or .a file) cannot be referenced by the Xamarin.Forms Portable (or .NET Standard) project directly because the Portable (or .NET Standard) project has no way of referencing the Xamarin.iOS SDK assemblies. So the iOS Binding Library project has to be referenced by an iOS App (or iOS Class Library) project. To call into code in the iOS Binding library from the Xamarin.Forms Portable project you would then need to use a Dependency Service that will allow you to call into methods in your Xam.iOS app project, which would have a reference to your iOS Binding Library.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, September 12, 2018 6:17 PM