【发布时间】:2015-10-24 17:26:14
【问题描述】:
我正在尝试在这里安装 cocoapods:https://github.com/SwiftyJSON/SwiftyJSON 但是当我在我的视图文件中import SwiftyJSON 时,它显示No such module 'SwiftyJSON'
我的播客文件:
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 并打开了“AppName.xcworkspace”,但没有任何效果。我错过了一步吗?我正在使用 pod v. 0.39.0,我的部署目标是 8.0。
【问题讨论】:
-
我有同样的问题,因为没有在progect的测试目标中使用它,尝试将此框架添加到测试目标
-
测试目标是什么?你的意思是把它放在链接框架和库中?
-
我的意思是 imagehost.spark-media.ru/i4/… 如果您在项目中有测试,则在使用 swiftyJSON 的文件中
-
您是否使用正确版本的 swifty json 和正确版本的 swift?
-
是的,就是@bolnad。我需要将 xcode 升级到 7
标签: ios swift cocoapods swifty-json