Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String is not identifcal to NSObject #14

Closed
danshev opened this issue Mar 27, 2015 · 25 comments
Closed

String is not identifcal to NSObject #14

danshev opened this issue Mar 27, 2015 · 25 comments

Comments

@danshev
Copy link

danshev commented Mar 27, 2015

Following the Usage steps and I get:

eh

Also, minor, but there's no note about the need for import Oauth2

I'm new, perhaps I missed a step and am causing my own problems? Note: xCode 6.2 (6C131e)

@danshev
Copy link
Author

danshev commented Mar 27, 2015

Adding as OAuth2JSON on to the declaration of settings seems to silence the error.

@danshev
Copy link
Author

danshev commented Mar 27, 2015

Nevermind, doing that then just causes build errors.

Undefined symbols for architecture x86_64:
"_TFC6Oauth215OAuth2CodeGrantCfMS0_FT8settingsGVSs10DictionarySSPSs9AnyObject___S0", referenced from:
_TFC6Svelte14ViewController11viewDidLoadfS0_FT_T in ViewController.o

@p2
Copy link
Owner

p2 commented Mar 27, 2015

That is weird. I have just updated OAuth2App and am not getting this error.

@p2
Copy link
Owner

p2 commented Mar 27, 2015

Can you try building OAuth2App and see if this error also occurs (should be in GitHubLoader.swift and RedditLoader.swift)? Try CMD + SHIFT + K to clean out the cache before building.

@danshev
Copy link
Author

danshev commented Mar 27, 2015

OAuth2App worked (OSX) ... perhaps something with iOS?

@p2
Copy link
Owner

p2 commented Mar 27, 2015

My iOS project seems to work as well. Can you create a gist with the whole method/function that you've posted a screenshot of above and add the link here?

@danshev
Copy link
Author

danshev commented Mar 27, 2015

https://gist.github.com/danshev/8a81b82636b89b1a4f65

Maybe I screwed up linking / embedding?

@danshev
Copy link
Author

danshev commented Mar 27, 2015

meh

@p2
Copy link
Owner

p2 commented Mar 27, 2015

Thanks, I have created a fresh iOS project, pasted your code and get the same error. Will take a look!

@danshev
Copy link
Author

danshev commented Mar 27, 2015

Sure thing, thank you for your knowledge!

@p2
Copy link
Owner

p2 commented Mar 27, 2015

It seems to create an NSDictionary explicitly, interesting. Does it work without crash for you if you use this?

let settings = [...] as OAuth2JSON

@danshev
Copy link
Author

danshev commented Mar 27, 2015

That's what I tried first, I get a bunch of exotic compile errors.

@p2
Copy link
Owner

p2 commented Mar 27, 2015

It seems to work for me...?

@danshev
Copy link
Author

danshev commented Mar 27, 2015

errors

@danshev
Copy link
Author

danshev commented Mar 27, 2015

more

@danshev
Copy link
Author

danshev commented Mar 27, 2015

Undefined symbols for architecture x86_64 seems to indicate some problem with how I've linked the files, but I'm not sure what.

http://stackoverflow.com/questions/25820810/undefined-symbols-for-architecture-x86-64-ios-swift

@danshev
Copy link
Author

danshev commented Mar 27, 2015

Care to share the app you just tested with?

@p2
Copy link
Owner

p2 commented Mar 27, 2015

I simply created a new Swift one-view iOS app, added the OAuth2 framework as a submodule, added it to the project and linked it (like in your screenshot above) and hit "Run".

Is your app an Objective-C app with some Swift code? Also make sure, in build settings, to set "Embedded content contains Swift code" to YES.

@p2
Copy link
Owner

p2 commented Mar 27, 2015

I was able to receive an access token with this code (client secret/key are real, you can use them for testing):

import UIKit
import OAuth2

class ViewController: UIViewController
{
    var oauth: OAuth2CodeGrant?

    override func viewDidLoad() {

        super.viewDidLoad()
        println("viewDidLoad")

        let settings = ["client_id": "773fuzwnerneye",
            "client_secret": "KtGhKdYPZyOFlz0T",
            "authorize_uri": "https://www.linkedin.com/uas/oauth2/authorization",
            "token_uri": "https://www.linkedin.com/uas/oauth2/accessToken",
            "scope": "r_basicprofile",
            "redirect_uris": ["https://localhost/oauth/callback"],   // don't forget to register this scheme
        ] as OAuth2JSON

        oauth = OAuth2CodeGrant(settings: settings)
        oauth!.onAuthorize = { parameters in
            println("Did authorize with parameters: \(parameters)")
        }
        oauth!.onFailure = { error in        // `error` is nil on cancel
            if nil != error {
                println("Authorization went wrong: \(error!.localizedDescription)")
            }
        }
    }

    override func viewDidAppear(animated: Bool) {
        oauth!.authorizeEmbeddedFrom(self, params: nil)
    }
}

@danshev
Copy link
Author

danshev commented Mar 27, 2015

My app is pure Swift and it says Yes for contains embedded ... are you needing an import oAuth2 line? I am, which might indicate I've done something wrong while adding the submodule.

@p2
Copy link
Owner

p2 commented Mar 27, 2015

Ah yes; add "import OAuth2" at the top. But the compiler would complain if you didn't.

@danshev
Copy link
Author

danshev commented Mar 27, 2015

Ya, fresh app worked for me. Will troubleshoot why I'm not able to bring it in to my existing app.

Thanks for the help.

@p2
Copy link
Owner

p2 commented Mar 27, 2015

Great, glad I could help and thanks for your helpful responses! I'll update the example in the README and close this issue when done. 👍

@danshev
Copy link
Author

danshev commented Mar 27, 2015

Found it ... frustratingly simple

I had: import Oauth2

Correct: import OAuth2 (capital A)

@p2
Copy link
Owner

p2 commented Mar 27, 2015

Ha! Definitely something the compiler should have noticed.

Closing as I've updated the README. Thanks!

@p2 p2 closed this as completed Mar 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants