Swift:如何使用cocoapods安装SwiftyJson?

我试图在这里安装cocoapods: https : //github.com/SwiftyJSON/SwiftyJSON但是当我在我的视图文件中import SwiftyJSON时,它说No such module 'SwiftyJSON'

我的Podfile:

 platform :ios, '8.0' inhibit_all_warnings! use_frameworks! target 'SherpaNewYork' do pod 'GoogleMaps' pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git' end 

添加完成后,我成功地运行了pod install

 [~/Documents/ios/Sherpa]$ pod install ✭ git:master ruby:2.2.2 Updating local specs repositories Analyzing dependencies Pre-downloading: `SwiftyJSON` from `https://github.com/SwiftyJSON/SwiftyJSON.git` Downloading dependencies Using GoogleMaps (1.10.4) Installing SwiftyJSON (2.3.0) [!] Pods written in Swift can only be integrated as frameworks; add `use_frameworks!` to your Podfile or target to opt into using it. The Swift Pod being used is: SwiftyJSON [~/Documents/ios/Sherpa]$ pod install ✭ git:master ruby:2.2.2 Updating local specs repositories Analyzing dependencies Pre-downloading: `SwiftyJSON` from `https://github.com/SwiftyJSON/SwiftyJSON.git` Downloading dependencies Using GoogleMaps (1.10.4) Installing SwiftyJSON (2.3.0) Generating Pods project Integrating client project Sending stats Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed. 

当我不导入它会给我错误:

 let jsonResponse: [Dictionary<String, AnyObject>] = [ ["id": "1", "name": "Crumbs Bakery", "icon_image": "food_icon_small", "latitude": 40.714, "longitude": -74.000 ], ["id": "2", "name": "Shake Shack", "icon_image": "food_icon_small", "latitude": 40.715, "longitude": -74.001 ] ] let data = NSJSONSerialization.dataWithJSONObject(jsonResponse, options: nil, error: nil JSON(data) // Use of unresolved identifier 'JSON' 

我甚至closures了我的Xcode,并打开“AppName.xcworkspace”,但没有任何工作。 我错过了一个步骤? 我使用的是pod v。0.39.0,我的部署目标是8.0。

编辑 :误读你的问题。 如果您使用Cocoapods进行安装,则仍然需要import SwiftyJSON

尝试Product -> Clean然后Product -> Build 。 这可以解决问题。


你不需要导入它。 只要使用它。 你只需要import一个独立的模块 : Swift Access Controll ,而不是源文件