2

I am trying to import and use the OAuthSwift library in the Swift iOS project. I followed their directions:

  • Drag OAuthSwift.xcodeproj to your project in the Project Navigator.
  • Select your project and then your app target. Open the Build Phases panel.
  • Expand the Target Dependencies group, and add OAuthSwift framework. import OAuthSwift whenever you want to use OAuthSwift.

After completing these steps, importing OAuthSwift using import OAuthSwift causes the error No such module 'OAuthSwift' and the project fails to build.

I have tried the following steps, based on a number of other SO questions about similar issues:

  • Clean and rebuild
  • Add the OAuthSwift framework to many different combinations of Build Phases > Target Dependencies, Build Phases > Link Binary With Libraries, Build Phases > Embed Frameworks, and General > Embedded Libraries
  • Set Build Settings > Search Paths > Framework Search Paths and Build Settings > Search Paths > Library Search Paths to $(SRCROOT) and recursive.
  • Verify that my deployment target matches the deployment target of the OAuthSwift Xcode project.

I have tested this using the latest version of OAuthSwift from their master branch using a git submodule, as well as manually downloading and importing each of the two latest tagged versions (0.6.0 and 0.5.2).

I have also created a brand new Xcode project, imported OAuthSwift as above, and encountered the same error.

Finally, I also tried importing a different Swift Framework (Alamofire), following the steps as stated on the README at https://github.com/Alamofire/Alamofire. This caused the same error as well: No such module 'Alamofire'.

I am using:

  • OSX 10.11.6
  • Xcode 7.3.1
  • Swift 2.2

I'm still fairly new to Xcode and the Swift module system, so any help or suggestions is appreciated.

Jordan Schalm
  • 147
  • 2
  • 13
  • Try: build the project, close Xcode, reopen Xcode, import – alessionossa Aug 17 '16 at 16:57
  • if you are new, adding frameworks can be a bit hard some times, you can add it using cocoapods,, they have it (pod 'OAuthSwift', '~> 0.5.0') – Aziz Aug 17 '16 at 17:18
  • 1
    If they have cocoapods as @Aziz says then I would highly recommend going that route. If your not familiar with it then I suggest you do as almost any popular or good/maintained open source libraries for iOS will use it. Once set up it is super easy to put in/remove 3rd party libraries. As easy as changing one line in a `podfile` and then running `pod install` in command line. Highly recommend it. – NSGangster Aug 17 '16 at 17:49
  • [Link for Installing](https://guides.cocoapods.org/using/getting-started.html) // [Creating podfile with your desired frameworks](https://guides.cocoapods.org/using/using-cocoapods.html) Then run $ pod install in your projects directory. Clean and build project. May need to restart xcode but its pretty straightforward and can find a lot of examples on cocoapods website. – NSGangster Aug 17 '16 at 17:56
  • USE COCOAPODS! It is awesome. – Sethmr Aug 17 '16 at 20:41

1 Answers1

1

Your life will be a lot easier if you import the framework using CocoaPods. If you haven't used them before, it's really easy once you get set-up. You use Ruby Gems on the command line to install CocoaPods (sudo gem install cocoapods) and then create a create a pod file using pod init. After this you modify it to include:

platform :ios, '8.0'

use_frameworks!

pod 'OAuthSwift', '~> 0.5.0'

Save the file and run pod install.

Once this is complete you will have to close out the Xcode project and use the newly created .xcworkspace project file (not the .xcodeproj) from here forward.

Here is a link to another post for a secondary reference. How to install cocoapods?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Joel Nieman
  • 746
  • 4
  • 13