[How to Solve] Xcode:No such module SwiftyJSON

SwiftyJSON is a great third-party library for the Swift language, mainly dealing with JSON data, written by ThoughtWorks’ engineering master Ruo Yu.

When using SwiftyJSON, Xcode reports an error: No such module ‘SwiftyJSON’

SwiftyJSON Github:

Manually (iOS 7+, OS X 10.9+):

To use this library in your project manually you may:
for Projects, just drag SwiftyJSON.swift to the project tree
for Workspaces, include the whole SwiftyJSON.xcodeproj

Initialization

import SwiftyJSON
let json = JSON(data: dataFromNetworking)
let json = JSON(jsonObject)

Problem recurrence:

Xcode: Version 7.1.1 (7B1005)

Create a new project and select Single View Application.

Follow the instructions in SwiftyJSON and drag and drop SwiftyJSON.swift directly into the project using the manual method.

Then use import in UIViewController to introduce SwiftyJSON.

import UIKit  
import SwiftyJSON  //Xcode ERROR: No such module 'SwiftyJSON'  

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}

Xcode: no such module ‘swiftyjson’

Solution:

After a search on the Internet, many people have encountered this problem. On stackoverflow, I found that someone answered:

If you added SwiftyJSON.swift to your project, you don’t need to import it.
It’s already available.

Originally, the swiftyjson.swift file was added to the project, so you don’t need to import it again, you can use it directly( (dizzy)

You can directly use the JSON () method in your code:
let JSON = JSON (data: datafromnetworking)
let JSON = JSON (JSON object)

References:

http://stackoverflow.com/questions/26754481/example-handling-json-with-swiftyjson
https://github.com/SwiftyJSON/SwiftyJSON
https://github.com/lingoer/SwiftyJSON

Similar Posts: