[GH-ISSUE #585] OAuth2Swift class is no longer able to be subclassed completely. #379

Closed
opened 2026-03-03 16:48:13 +03:00 by kerem · 2 comments
Owner

Originally created by @BrianDoig on GitHub (Apr 17, 2020).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/585

Description:

Due to a recent change in Swift, convenience initializers are no longer available to be called by subclasses, or users of that subclass. Only default initializers may be called by a subclass. Since OAuth2Swift default initializer does not allow you to set all parameters, subclasses are left calling only the default initializer and there is no way to implement all the init methods required. This caused my OAuth2Swift subclass to stop compiling because the convenience initializers become private.

I tried wrapping OAuth2Swift in a class and forwarding all calls to it, but that broke when I needed to use a Safari controller because my wrapper could not be used with its init method because it is no longer a subclass of OAuth2Swift.

OAuth Version:

  • Version 1
  • Version 2

OS (Please fill the version) :

  • iOS :
  • OSX :
  • TVOS :
  • WatchOS :

Installation method:

  • Carthage
  • CocoaPods
  • Swift Package Manager
  • Manually

Library version:

  • head
  • v2.1.0
  • v2.0.0
  • v1.4.1
  • v1.2 (Swift 4.0)
  • other: (Please fill in the version you are using.)

Xcode version:

  • 11.x (Swift 5.1)

  • 10.x (Swift 5.0)

  • 10.x (Swift 4.1)

  • 9.3 (Swift 4.1)

  • 9.0 (Swift 4.0)

  • other: (Please fill in the version you are using.)

  • objective c

Originally created by @BrianDoig on GitHub (Apr 17, 2020). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/585 ### Description: Due to a recent change in Swift, convenience initializers are no longer available to be called by subclasses, or users of that subclass. Only default initializers may be called by a subclass. Since OAuth2Swift default initializer does not allow you to set all parameters, subclasses are left calling only the default initializer and there is no way to implement all the init methods required. This caused my OAuth2Swift subclass to stop compiling because the convenience initializers become private. I tried wrapping OAuth2Swift in a class and forwarding all calls to it, but that broke when I needed to use a Safari controller because my wrapper could not be used with its init method because it is no longer a subclass of OAuth2Swift. ### OAuth Version: - [ ] Version 1 - [X] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [x] Carthage - [x] CocoaPods - [x] Swift Package Manager - [x] Manually ### Library version: - [x] head - [ ] v2.1.0 - [ ] v2.0.0 - [ ] v1.4.1 - [ ] v1.2 (Swift 4.0) - [ ] other: (Please fill in the version you are using.) ### Xcode version: - [X] 11.x (Swift 5.1) - [ ] 10.x (Swift 5.0) - [ ] 10.x (Swift 4.1) - [ ] 9.3 (Swift 4.1) - [ ] 9.0 (Swift 4.0) - [ ] other: (Please fill in the version you are using.) - [ ] objective c
kerem closed this issue 2026-03-03 16:48:13 +03:00
Author
Owner

@phimage commented on GitHub (Apr 30, 2020):

I replace by one init with default value fde7795 , more clean way to do it
@BrianDoig Let me know if it work for you

ps: do not hesitate to PR for a change like that

<!-- gh-comment-id:621994017 --> @phimage commented on GitHub (Apr 30, 2020): I replace by one `init` with default value fde7795 , more clean way to do it @BrianDoig Let me know if it work for you ps: do not hesitate to PR for a change like that
Author
Owner

@phimage commented on GitHub (May 4, 2020):

feel free to comment or reopen if the issue is still there

<!-- gh-comment-id:623464373 --> @phimage commented on GitHub (May 4, 2020): feel free to comment or reopen if the issue is still there
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#379
No description provided.