No such Module 'SwiftyJSON' on Swift 3.0
Asked Answered
E

11

29

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

Exarate answered 25/7, 2016 at 15:49 Comment(3)
Did you remove properly the Swift 2 version of SwiftyJSON then installed the Swift 3 version?Sapheaded
It was a cocoapod, so I commented out the line and reinstalled..Exarate
You may have to "clean your project" (menu Product - Clean) and delete the derived data.Sapheaded
S
44

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

Stodder answered 8/2, 2017 at 15:31 Comment(7)
Silly mistake, but this was my issue too. Thanks for contributing!Dewclaw
Glad it helped!Stodder
what does that mean ?Attalie
@HosMercury what does what mean?Stodder
@HosMercury it's a file generated by Xcode that is useful for including code in other projects. I am mobile right now and unable to easily provide links or screenshots, but you should see a .xcworkspace file in your folder and that should be opened by XcodeStodder
I made the same mistake. Thanks for the help!Brocket
@ElaineLin Its funny how common this problem is. This is my most upvoted answer and such a simple issue haStodder
N
12

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

Nubia answered 25/7, 2016 at 16:9 Comment(1)
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)Fontes
V
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

Vibes answered 21/10, 2016 at 22:18 Comment(0)
W
6

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

pod 'SwiftyJSON'
Weide answered 11/11, 2016 at 1:23 Comment(1)
pod 'SwiftyJSON' did it for me! But ONLY with the newest version of Cocoapods.Stane
C
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

Cockade answered 10/8, 2017 at 8:54 Comment(0)
L
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
Lavabo answered 3/10, 2016 at 16:18 Comment(0)
H
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.

Harleigh answered 21/4, 2017 at 16:15 Comment(1)
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!Interventionist
P
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.

Pianoforte answered 22/7, 2017 at 4:20 Comment(0)
R
0

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

https://mcmap.net/q/202520/-39-no-such-module-39-when-i-use-cocoapods

Runthrough answered 6/2, 2018 at 13:12 Comment(0)
S
0

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

Snapp answered 17/4, 2019 at 10:38 Comment(0)
B
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.

Berchtesgaden answered 4/9, 2019 at 11:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.