27

After migrating to Swift 3.0, I am trying to import SwiftyJSON into my project. However, when I import the framework 'import SwiftyJSON' I get a No Such Module error.

If I remove the import statement, it does not recognize its classes.

Any advice as to why XCode might not be reading my imported framework?

See screenshots attached:

enter image description here

enter image description here

enter image description here

Jacobo Koenig
  • 11,728
  • 9
  • 40
  • 75

11 Answers11

43

My problem was I was opening the project file and not the workspace file...

Greg Hilston
  • 2,397
  • 2
  • 24
  • 35
12

Try to check Targets-> Build Phases Link Binary With Libraries There must be a link with SwiftyJSON Check

Dmitry
  • 2,963
  • 2
  • 21
  • 39
  • For the ones who are in confusion: this page is not the Build settings of the project, but the "Pods". (blue icon on the navigation menu) – Muhammed Gül Jun 18 '19 at 07:22
10

Updating my pod to reference the official SwiftyJSON gem worked for me! It updated from version 2.3.2 (what was installed by default via 'pod SwiftyJSON') to version 3.1.1.

So, in your Podfile, udpate your SwiftyJSON pod to:

 pod 'SwiftyJSON', :git =>'https://github.com/SwiftyJSON/SwiftyJSON.git'

HTH

Q A
  • 200
  • 2
  • 11
6

Clean your project and build again. Make sure you open project.xcworkspace.

pod 'SwiftyJSON'
Sour LeangChhean
  • 7,089
  • 6
  • 37
  • 39
5

remove import SwiftyJSON to solve No such Module 'SwiftyJSON' on Swift 3.0

Swift can load the SwiftyJSON.swift by itself. No need to specify it at import statement.

Ref: https://github.com/SwiftyJSON/SwiftyJSON/issues/49

oOEric
  • 1,069
  • 1
  • 10
  • 25
2

Try this.

# Uncomment this line to define a global platform for your project
platform :ios, '10.0'
# Uncomment this line if you're using Swift
use_frameworks!

target 'Project names' do
  pod 'SwiftyJSON', git: 'https://github.com/BaiduHiDeviOS/SwiftyJSON.git', branch: 'swift3'    
end

post_install do |installer|
   installer.pods_project.targets.each do |target|
       target.build_configurations.each do |config|
           config.build_settings['SWIFT_VERSION'] = '3.0'
       end
   end
end
Durul Dalkanat
  • 7,266
  • 4
  • 35
  • 36
1

If you have multiple targets, try building each of them. I had two targets - one would build and the other would not. This may help you trace the issue.

In my case I just nuked my dev target that was not working, duplicated the production target, made a few settings changes, and was back in action.

Derek Soike
  • 11,238
  • 3
  • 79
  • 74
  • Just letting you know I spent most of the day trying to solve this. After hours and hours I find your suggestion and it worked. All I had to do was build the project. Thanks! – rjcarr May 18 '17 at 08:37
0

clean your project and than build and run your project and than not work so remove your swiftyjson cocoa library in u r cocoapods and reinstall it should surely work and this 100% work for me ..so u try this.

ronak patel
  • 400
  • 5
  • 17
0

This solution helped me. Build the modules individually, and then build your project.

https://stackoverflow.com/a/37732248/4899943

Armin
  • 629
  • 6
  • 23
0

//import SwiftyJSON comment out first then pod install and then agian add import SwiftyJSON and pod install it work for me

Divesh singh
  • 409
  • 4
  • 12
0
  1. In your Xcode project go to podfile and enter :

     pod 'SwiftyJSON'
    
  2. Save and close the Xcode.

  3. Open terminal and go to project directory and enter :

     pod install
    
  4. Open the project and Import SwiftyJSON in which file you want to use.