evgenyneu / Auk

An image slideshow for iOS written in Swift.
MIT License
277 stars 44 forks source link

Objective-c support #43

Closed taher-mosbah closed 8 years ago

taher-mosbah commented 8 years ago

Hello,

I'm trying to integrate Auk into an Obective-c project using cocoapods. I modified Auk class declaration to add @objc

@objc public class Auk : NSObject {

  public override init() {

  }

I added use_frameworks! to my podfile and set Defines Module to YES in my build settings. In my class I import it like this #import <Auk/Auk-Swift.h> //(I tried @import Auk; too) and then : [self.gallerySV.auk showWithUrl:imageUrl accessibilityLabel:nil]; The code is working but I only can access methodes in Auk.swfit (AukSettings for example is not recognised by Xcode ..)

Do you have any idea how to properly do this and do you intend to support integrating with objective-c (maybe in a branch ?)

Thanks !

evgenyneu commented 8 years ago

Hello @taher-mosbah, thanks for bringing this up. You did everything correctly. The reason the AukSettings is not visible in ObjC is because, to my knowledge, ObjC does not recognize swift structures, only classes (stackoverflow link).

One way to use Auk in an ObjC app is to create a wrapper class in Swift. Here is such sample class with few methods and instrutions on how to use it in ObjC app.

I am not planning to add ObjC support at this moment because it would add complexity and require additional maintenance.

Let me know how it goes.

taher-mosbah commented 8 years ago

Hello @evgenyneu thanks for your answer and for adding the sample 👍 It's working great but I ended using another lib (https://github.com/zvonicek/ImageSlideshow) as I wanted to use the image manager I already have on my project (using ImageSlideshow this is done by subclassing InputSource), maybe this can be a nice addition to Auk ? Thanks again ! Cheers

evgenyneu commented 8 years ago

Thanks for the tip about the InputSource, I will investigate that.

All the best