delannoyk / SoundcloudSDK

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

Types in 'Soundcloud' module cannot be uniquely referenced #35

Closed bchrobot closed 8 years ago

bchrobot commented 8 years ago

It is not possible to uniquely reference a type in the Soundcloud module due to the Soundcloud module having the same name as the Soundcloud class within the module.

For example, using Soundcloud in a project with an existing User struct

/api/models/user.swift

struct User {
// my own user representation
}

SoundcloudAuthenticationController.swift


import struct Soundcloud.User
import class Soundcloud.Soundcloud

// This works fine as it refers to the singleton class within the Soundcloud module Soundcloud.clientIdentifier = "somethingsecret"

// The following refers to my own User struct var user: User

// The following results in error: 'User' is not a member type of 'Soundcloud' var user: Soundcloud.User



It seems that either the module or the type name need to be changed.

This problem is described in an [SO post](http://stackoverflow.com/q/36991735/3015709) and Swift bug [SR-1389](https://bugs.swift.org/browse/SR-1389) (incorrectly closed as duplicate)
delannoyk commented 8 years ago

Yes I can see how that is a problem and I'm also having it in my own project. I was thinking of ways to fix it but as you said, there's currently no other way around it except to rename something. I think renaming the type would be best. What's your opinion?

bchrobot commented 8 years ago

Submitted PR #36 for this. Renamed the type but added convenience methods / accessors so it shouldn't break the current API. This was based on the Alamofire implementation

delannoyk commented 8 years ago

Fixed.