简体   繁体   中英

SwiftyJSON in Watchkit Extension not working

Using iOS-9.2, watchOS-2.1, Swift-2.1.1 under XCode-7.2:

Trying to use SwiftyJSON (v2.3.2) inside my Watchkit Extension! The install of the SwiftyJSON was done by the following 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:

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).

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")

在此处输入图片说明

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...

I managed to get it fixed by: - Updating cocoapods then modifying the Podfile to specify the platform

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
  • Finally, clear project data by clicking window -> projects -> "Select your project" and Delete the Derived Data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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