mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 12:45:52 +03:00
[GH-ISSUE #415] Support for integration into Objective-C project for Swift 4.0 #267
Labels
No labels
bug
cocoapod
duplicate
enhancement
feature-request
help wanted
help wanted
invalid
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/OAuthSwift#267
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @gallymon on GitHub (Oct 23, 2017).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/415
Description: Help Wanted. I've been unable to get the Swift 4.0 version of this framework to integrate successfully with my Objective-C project.
I have, however, successful integrated the Swift 3.2 version of this framework.
In both cases, I add OAuthSwift to my project using cocoapod. For Swift 3.2, I use pod 'OAuthSwift', '~>1.1.2' and for Swift 4.0, I use pod 'OAuthSwift', '~>1.2.0' in my podfile.
In both cases, after the add, when I next fire up Xcode (9.0), it complains about encountering Swift 2.0 code so I go to targets > OAuthSwift > Build Settings > Basic > Swift Compiler Language and set both 'OAuthSwift' & 'Pods' columns to 3.2 or 4.0, as appropriate.
After this, I can build both projects (Swift 3.2 or 4.0) successfully. But note that I am not doing anything yet with OAuthSwift.
To try to use OAuthSwift, in one of my Objective-C .m files, I add the line @import OAuthSwift near the top.
Then, further down, in a method, I add the following code (which I gleaned from issue #269 ):
In the version of my project which has the Swift 3.2 version of OAuthSwift integrated into it, this code builds and the call to initWithParameters: parameters resolves.
In the version with Swift 4,.0, the call does not resolve and I get this:
No visible @interface for 'OAuth1Swift' declares the selector 'initWithParameters:'
I've been playing with this now for a day and I'm baffled where to go next - hence this issue report.
OAuth Provider (Twitter, Github, ..): GitHub
OAuth Version:
OS (Please fill the version) :
Installation method:
Library version:
Xcode version:
9.0 (Swift 4.0)
9.0 (Swift 3.2)
8.x (Swift 3.x)
8.0 (Swift 2.3)
7.3.1
other: (Please fill in the version you are using.)
objective c
@gallymon commented on GitHub (Oct 24, 2017):
A bit of addition information: I've taken a version of my Objective-C project and added OAuthSwift Library (using Swift 3.2) to it and generated a working version (as I described above).
Then I created another podfile and upgraded this project in-place from OAuthSwift (3.2) to (4.0). The upgraded version fails as I've described, above.
I get the feeling that there's something I need to do with Swift 4.0 to make it visible to Objective-C. Something that I did not have to do with Swift 3.2.
@phimage commented on GitHub (Oct 24, 2017):
Have you a .swift-version file? With inside 4.0
Maybe try head instead of tagged version
If it could work, good thing , but I do not maintain compatibility with obj-c.
@gallymon commented on GitHub (Oct 25, 2017):
phimage,
I'm afraid I am in over my head here. This is my first occasion to try to include a Swift framework into my Objective-C project, my first time to use something from GitHub, my first time to use Cocoapds and, at this time, I have only a passing familiarity with Swift.
I've looked at a few OAuth libraries. Currently, I'm using STTwitter which is written in Objective-C but I think it is no longer in development and it seems Twitter specific. It looks like OAuthSwift is my best bet because it is generic (OAuth1 & OAuth2) and it is in active development.
For now, I think I'll stick with OAuthSwift 1.1.2 for Swift 3.2 which is working for me.
Maybe, as further work on the Swift 4.0 version of OAuthSwift occurs, someone will be able to take a look at why the Swift 3.2 version (1.1.2) integrates well with Objective_C whereas the Swift 4.0 version (1.2.0) does not.
I know at this point, my skills are no where near being able to sort this out.
Cheers, from New Zealand!
@gallymon commented on GitHub (Oct 25, 2017):
phimage,
Sorry, I should have also answered your specific questions and suggestions.
I can see the swift-version file in the GitHub listing of files. But here on my local system, I cannot find a swift-version file in either my swift 3.2 or swift 4.0 versions of OAuthSwift as integrated with my Objective-C project using cocoapods.
As far as trying to use cocoapod to install from 'head' rather than from a tagged version like 1.1.2, I confess to being a noobie and having no idea how to modify my podfile to do that.
Cheers!
@phimage commented on GitHub (Oct 26, 2017):
Not a "swift+version" file but a ".swift-version" file, with a . so an hidden file in file system.
Sometimes cocoapod compile with the wrong version, so by putting a file at root of your project to indicate the version of swift you use could help
for cocoapod and head, just put the git after the pod 'OAuthSwift'
, :git => 'https://github.com/OAuthSwift/OAuthSwift.git' (then you can add a git commit, a branch a tag, see doc)
To be helped you can create a project with the issue but not your full code and commit it to github
So maybe I have time I will open it and see the issue.
@gallymon commented on GitHub (Oct 26, 2017):
phimage,
Many thanks for your willingness to help a noobie here. It is much appreciated. But, after wrestling with all this for several days, I think it is clear that I need to divide and conquer.
The best way, I think, to do that is to remove the complexity and confusion of trying to span from Objective-C, which I understand quite well, over to Swift, which I am still quite unfamiliar with. At every step, I am confronted with syntax and concepts which are new to me.
So, I think I'm going to go in search of an OAuth library written in Objective-C.
Cheers and best wishes from New Zealand!
@deberle commented on GitHub (Dec 29, 2017):
I am in the same situation as @gallymon
Are there any guides available to integrate OAuthSwift into an ObjC project?
@phimage commented on GitHub (Jan 13, 2018):
@deberle sorry there is no guide