[GH-ISSUE #193] SharedApplication is unavailable (UIApplication+OAuthSwift.swift) #114

Closed
opened 2026-03-03 16:45:48 +03:00 by kerem · 3 comments
Owner

Originally created by @NSURLSession0 on GitHub (Feb 24, 2016).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/193

I get the following compiler-error:

UIApplication+OAuthSwift.swift:14:34: 'sharedApplication()' is unavailable: Use view controller based solutions where appropriate instead.

It refers to the following code from OAuthSwift:

static var topViewController: UIViewController? {
    return UIApplication.sharedApplication().topViewController
}

Of course I set OAUTH_APP_EXTENSIONS..

Everywhere else in the code, OAuthSwift uses:

#if !OAUTH_APP_EXTENSIONS
    UIApplication.sharedApplication()......
#endif

Is there a reason this if-statement is not used inside UIApplication+OAuthSwift.swift?

(Newest OAuthSwift version, installed with CocoaPods, but I also tried installing manually)

  • OS targeted (with version): iOS 9.0
  • OAuth provider: -
  • OAuthSwift version: 0.5.1
Originally created by @NSURLSession0 on GitHub (Feb 24, 2016). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/193 I get the following compiler-error: ``` UIApplication+OAuthSwift.swift:14:34: 'sharedApplication()' is unavailable: Use view controller based solutions where appropriate instead. ``` It refers to the following code from OAuthSwift: ``` static var topViewController: UIViewController? { return UIApplication.sharedApplication().topViewController } ``` Of course I set `OAUTH_APP_EXTENSIONS`.. Everywhere else in the code, OAuthSwift uses: ``` #if !OAUTH_APP_EXTENSIONS UIApplication.sharedApplication()...... #endif ``` Is there a reason this if-statement is not used inside `UIApplication+OAuthSwift.swift`? (Newest OAuthSwift version, installed with CocoaPods, but I also tried installing manually) - **OS targeted (with version):** iOS 9.0 - **OAuth provider:** - - **OAuthSwift version:** 0.5.1
kerem closed this issue 2026-03-03 16:45:48 +03:00
Author
Owner

@phimage commented on GitHub (Feb 24, 2016):

(issue template?...)

so no any reason, code has been extracted one day, and will be never be called in extensions but in fact code doesn't compile

UIApplication+OAuthSwift.swift must be excluded for extension
or

 #if !OAUTH_APP_EXTENSIONS
// all the code
#endif

must be added to this file

<!-- gh-comment-id:188432458 --> @phimage commented on GitHub (Feb 24, 2016): (issue template?...) so no any reason, code has been extracted one day, and will be never be called in extensions but in fact code doesn't compile `UIApplication+OAuthSwift.swift` must be excluded for extension or ``` swift #if !OAUTH_APP_EXTENSIONS // all the code #endif ``` must be added to this file
Author
Owner

@NSURLSession0 commented on GitHub (Feb 24, 2016):

How can I do this? I installed with CocoaPods so I can't exclude a file or change code?

<!-- gh-comment-id:188436613 --> @NSURLSession0 commented on GitHub (Feb 24, 2016): How can I do this? I installed with CocoaPods so I can't exclude a file or change code?
Author
Owner

@phimage commented on GitHub (Feb 24, 2016):

many ways to change code

1/ edit the code temporary, but each pod update will erase the code change
2/ clone repository, edit, change your podfile to specify the path of the repository , 'path' => '../the/local/path/where/OAuthSwift/is/OAuthSwift.podspec'
3/ the best: fork , clone your fork. edit the code, commit the fix with a clear message

  • change your podfile to specify your fork using , :git => 'url of your git' , until new OAuthSwift release
  • then you can also make a pull request to our repository
<!-- gh-comment-id:188438451 --> @phimage commented on GitHub (Feb 24, 2016): many ways to change code 1/ edit the code temporary, but each pod update will erase the code change 2/ clone repository, edit, change your podfile to specify the path of the repository `, 'path' => '../the/local/path/where/OAuthSwift/is/OAuthSwift.podspec'` 3/ the best: fork , clone your fork. edit the code, commit the fix with a clear message - change your podfile to specify your fork using `, :git => 'url of your git'` , until new OAuthSwift release - then you can also make a pull request to our repository
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#114
No description provided.