简体   繁体   English

Watchkit Extension中的SwiftyJSON无法正常工作

[英]SwiftyJSON in Watchkit Extension not working

Using iOS-9.2, watchOS-2.1, Swift-2.1.1 under XCode-7.2: 使用iOS-9.2,watchOS-2.1,XCode-7.2下的Swift-2.1.1:

Trying to use SwiftyJSON (v2.3.2) inside my Watchkit Extension! 尝试在我的Watchkit Extension中使用SwiftyJSON(v2.3.2)! The install of the SwiftyJSON was done by the following podfile: SwiftyJSON的安装由以下Podfile完成:

podfile: Podfile:

xcodeproj 'TableTestKOS001.xcodeproj'
workspace 'TableTestKOS001.xcworkspace'
platform :ios, '9.0'
inhibit_all_warnings!

use_frameworks!
link_with 'TableTestKOS001', 'TableTestKOS001 WatchKit Extension'

def shared_pods
      pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
end

target 'TableTestKOS001' do
    shared_pods
end

target 'TableTestKOS001Tests' do
    shared_pods
end

target 'TableTestKOS001 WatchKit Extension' do
    platform :ios, '9.0'
    shared_pods
end

Using "pod install", I get: 使用“ pod install”,我得到:

Updating local specs repositories
Analyzing dependencies
Pre-downloading: `SwiftyJSON` from `https://github.com/SwiftyJSON/SwiftyJSON.git`
Downloading dependencies
Installing SwiftyJSON (2.3.2)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `TableTestKOS001.xcworkspace` for this project from now on.
Sending stats
Sending stats
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total
pod installed.

That tells me, that so far everything is ok ! 这告诉我,到目前为止一切都还好!

After that I open the project (not with the .proj-file) but with the newly created workspace-File (ie in my case TableTestKOS001.xcworkspace). 之后,我打开项目(不使用.proj文件),而是使用新创建的工作区文件(即我的TableTestKOS001.xcworkspace)。

Now the problems start: 现在问题开始了:

As soon as I "import SwiftyJSON" into any of my WatchKit-Extension's WKInterfaceControllers, I get the following error (ie "No such module SwiftyJSON") 一旦我将“ SwiftyJSON”“导入”我的WatchKit-Extension的WKInterfaceControllers中,我就会收到以下错误(即“没有这样的模块SwiftyJSON”)

在此处输入图片说明

And moreover, next to the above error, I get the following warning : 而且,在上述错误旁边,我收到以下警告:

在此处输入图片说明

Can anybody help with this ?? 有人可以帮忙吗? Any support is appreciated !! 任何支持表示赞赏!

PS The same error and warning occur also when I am importing SwiftyJSON to any of the iOS-target's ViewControllers... PS当我将SwiftyJSON导入任何iOS目标的ViewController时,也会发生相同的错误和警告...

I managed to get it fixed by: - Updating cocoapods then modifying the Podfile to specify the platform 我设法通过以下方法解决此问题:-更新cocoapods,然后修改Podfile以指定平台

target 'My App' do
    pod 'Google/Analytics'
    pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
end

target 'My App Watch Extension' do
    platform :watchos, '2.0'
    pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
end
  • Then run pod install again 然后再次运行pod install
  • Finally, clear project data by clicking window -> projects -> "Select your project" and Delete the Derived Data 最后,通过单击窗口->项目->“选择您的项目”并删除导出的数据来清除项目数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM