我尝试在此处安装cocoapod: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'
我甚至关闭了我的Xcode并打开了#34; AppName.xcworkspace&#34;但没有任何作用。我错过了一步吗?我使用的是pod v.0.39.0,我的部署目标是8.0。
答案 0 :(得分:2)
修改:误读您的问题。如果您使用Cocoapods安装它,您仍然需要import SwiftyJSON
。
尝试Product -> Clean
然后Product -> Build
。这可以解决问题。
您不需要导入它。只是使用它。对于分离的模块:Swift Access Controll,您只需要import
,而不是源文件。