Swiftyjson: Use of unresolved identifier 'JSON' if installed via Cocoapods

Created on 30 Mar 2015  Â·  35Comments  Â·  Source: SwiftyJSON/SwiftyJSON

Hi there,

I was wondering if this is a bug or if I'm doing something wrong.
I'm working with Cocoapods 0.36, Xcode 6.2 and followed the steps in the README of SwiftyJSON.

My Podfile looks like this

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'Alamofire', '~> 1.1'
pod 'SwiftyJSON', '>= 2.1.3'

I've updated my pods via pod install
This resulted in following output, so I guess everything is OK

pod install
Analyzing dependencies
Downloading dependencies
Using Alamofire (1.1.4)
Using SwiftyJSON (2.1.3)
Generating Pods project
Integrating client project

Now I tried the following code

Alamofire.request(.GET, "http://localhost/devine/students.json")
     .responseJSON { (request, response, data, error) in

         // Convert received JSON data to SwiftyJSON object
         let studentData = JSON(data) -> Got 'Use of unresolved identifier JSON here'
}

When I just drag and drop the SwiftyJSON files in my project (the 'manual' way) it does work, but I would like to use Cocoapods!

Kind regards,
Frederik

Most helpful comment

Project > General > Linked Framework and Libraries >
add SwiftyJSON

import SwiftyJSON

walaaaa!!!

All 35 comments

I have exactly the same problem

Did you import SwiftyJSON to the file?

Tried the import, now I get the error:

Cannot load underlying module for SwiftyJSON

+1

Project > General > Linked Framework and Libraries >
add SwiftyJSON

import SwiftyJSON

walaaaa!!!

Also having this issue. xerron's comment above didn't resolve it for me.

I'm having this issue as well and xerron's issue didn't resolve it. I'm also experiencing this problem with SwiftHTTP so I'm starting to suspect that it's a Cocoapods issue.

i've tried to import SwiftyJSON.. but this doesn't work eighter in the Linked Framework and Libraries

It works for me here is my Podfile:

platform :ios, '8.0'

use_frameworks!
pod "SwiftyJSON", ">= 2.2"

link_with "MyAppTarget"
link_with "MySecondTarget"

@patricks your solution doesn't work eighter ..

what version of xcode use?
work in 6.3
ios 8
osx 10.10

Xcode 6.3 and iOs 8
I have the same bug over and over again ...Use of unresolved identifier 'JSON'

+1

+1

Solved this with an import SwiftyJSON on each file used

On 8 May 2015, at 08:13, Leo Romanovsky [email protected] wrote:

+1

—
Reply to this email directly or view it on GitHub https://github.com/SwiftyJSON/SwiftyJSON/issues/192#issuecomment-100129328.

I tried what @bluedaniel suggested, but it did not work for me.

I had same problem

"Project > General > Linked Framework and Libraries >
add SwiftyJSON

import SwiftyJSON

walaaaa!!!"

This works for me, but shouldnt it work without adding the SwiftyJSON to Linked Frameworks (i mean cocoapods should be fine alone right )?
any other solution guys ?

After link library and "import SwiftyJSON"

I resolve this issue

1 deleting all the generated files by Cocoapods
2 pod install
3 open the project again

it works! :)

@fertejada Which files do you specifically mean? I'd like to try your solution on my project. Thanks!

@ndmeiri you need to delete only the . xcworkspace file, after that run the command "pod install"

This solution seems to have worked for me. In fact, I only needed to run pod install, rather than deleting the .xcworkspace file and then running that command. Strangely, I had tried this in the past, but it hadn't worked for me. But it did this time! Thanks @fertejada!

I solved this by deleting the derived data under the Window->Projects menu

When I get this issue, I just build the project and it usually goes away, probably something with the linker

@torrencio This worked for me also, thanks for the simple fix.

@xerron
Thanks, it helped!!!

Project > General > Linked Framework and Libraries >
add SwiftyJSON

import SwiftyJSON

walaaaa!!!

@xerron
Is wonderful fix ... but do not forget to clean and build the project ...

I had this error using Xcode7.1, the magic for me is do not import, I mean no need to write "import SwiftyJSON", just use it if your already drag-and-drop the .swift file.

@AllenConquest Thank you so much! This fixed the issue instantly.

Yes that worked for me, pod install -> clean -> run it !!!!!

All I had to do was 'Project > Clean Build Folder...' (holding down the alt key reveals this option), and it worked.

I'm using CocoaPods.

@oyvind-hauge Thanks,it works!

Kind of following @fertejada tip...
After link library and "import SwiftyJSON"

  1. closed xcode
  2. "pod deintegrate" (to erase the pod files)
  3. "pod install"
  4. opened project
  5. voile!

after pod install, cleaning + building fixed the error.

Good to know, @VicFrolov If you have any issue, feel free to open a new issue.

Solution: clean and build the project

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Dershowitz011 picture Dershowitz011  Â·  15Comments

zhigang1992 picture zhigang1992  Â·  10Comments

debayanb picture debayanb  Â·  12Comments

DarthRamone picture DarthRamone  Â·  17Comments

Xedart picture Xedart  Â·  13Comments