我想在這裏安裝的CocoaPods:https://github.com/SwiftyJSON/SwiftyJSON,但是當我在查看文件import SwiftyJSON
,它說:No such module 'SwiftyJSON'
Swift:如何使用cocoapods安裝SwiftyJson?
我Podfile:
[~/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.
:
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
後成功地
當我不導入它會給我錯誤:
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。
我有同樣的問題,因爲沒有在測試目標中使用它,試圖添加這個框架來測試目標 –
什麼是測試目標?你的意思是把它放入鏈接框架和庫? – Edmund
我的意思是這個http://imagehost.spark-media.ru/i4/453DE3BF-F5FA-DE51-0D6B-15EC8EBBB3C3.png在你使用swiftyJSON的文件中,如果你在你的項目中有測試 –