delannoyk / SoundcloudSDK

A Client for Soundcloud's API written in Swift!
MIT License
87 stars 27 forks source link

Can use this Swift codes in Objective-C #26

Closed nami13 closed 8 years ago

nami13 commented 8 years ago

Hi, How are you?

Thanks for your powerful SDK for Soundcloud. I'm building an iOS app that uses Soundcloud SDK.

I've started the project using Objective-C instead of Swift. When I integrated this SDK via Cocoapods, I've met an issue that I couldn't import your Swift structs in my objective-c code.

Is there any solution for this?

Hope your kindly assist. Thanks Nami

nami13 commented 8 years ago

Hi, Delannoyk Please help me on this? Thanks.

delannoyk commented 8 years ago

Hi Nami, Currently, this project isn't objc compatible, but that's something I'm willing to work on. Unfortunately I can't give you an ETA on this since I have to check first if the current architecture would allow it easily. I'll leave the issue open for now.

nami13 commented 8 years ago

Hi, Delannoyk Thanks for your reply. Now, I am really urgent for this. Shall I need to convert all my existing code into Swift for this library? I did convert all your structs into classes. But I can not import the external extension files into Obj-c. Could you please help me to find a solution quickly? Again, Thanks

delannoyk commented 8 years ago

Well, a quick solution for you would be to add a Objective-C friendly wrapper around this pod.

nami13 commented 8 years ago

I was trying to build a SCWrapper class. But all input and output parameters are Swift structs. Please give me an example idea?

I need only searching song function. Could you please help me on this?

Sorry for inconvenience. Thanks

delannoyk commented 8 years ago

Quick draft:

import Soundcloud

@objc struct MyTrack {
    var identifier: Int
    //and so on
}

@objc class SoundcloudProvider {
    func searchTracks(text: String, completion: ([Track]?, NSError?) -> Void) {
        //Here you use this library's method.
    }
}
nami13 commented 8 years ago

Thanks for your quick instructions. But, @objc is working for only class. Also, the structs can not be used in obj-c, and this is the problem.

The search query enum & completion block are also needed to be compatible with @objc. The return value are "[Track]", and this also should be @objc. This is the main issue.

I need your kindly assist. Do you like to meet on skype? Mine is "kay.eric7" Please add me if you have some time for me now. Thanks

nami13 commented 8 years ago

Or, could you please provide me the example swift project that use your library?

nami13 commented 8 years ago

I solved the issue. Thanks!