Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot use Parse library in WatchKit Extension (CocoaPods)

I'm attempting to use parse in a WatchKit extension. I started with a new project (objective-c) and installed the latest Parse (1.7.5) through CocoaPods. Here is my Podfile.

# Uncomment this line to define a global platform for your project
platform :ios, '8.3'

target 'WatchBumpTesting' do
        pod 'Parse', '~> 1.7.5'
end

target 'WatchBumpTesting WatchKit App' do

end

target 'WatchBumpTesting WatchKit Extension' do

end

I began by following the tutorial on their site. It described how to enable local data sharing, keychain sharing, and app groups. Here is where I began to encounter issues...

I enabled data sharing in my iOS app no problem. I imported <Parse/Parse.h> in my AppDelegate.h file and was able to complete the setup with the following code.

// Enable data sharing in main app.
[Parse enableDataSharingWithApplicationGroupIdentifier:@”group.com.parse.parseuidemo”];
// Setup Parse
[Parse setApplicationId:@”<ParseAppId>” clientKey:@”<ClientKey>”];

Next, I went on to enable data sharing on the WatchKit Extension. I opened my InterfaceController.h and attempted to import Parse but no luck, the library could not be found. "Okay - this makes sense, I suppose I have to add it to my Podfile"...so I did! I tried a few updated Podfiles.

V1

# Uncomment this line to define a global platform for your project
platform :ios, '8.3'

target 'WatchBumpTesting' do
        pod 'Parse', '~> 1.7.5'
end

target 'WatchBumpTesting WatchKit App' do

end

target 'WatchBumpTesting WatchKit Extension' do
        pod 'Parse', '~> 1.7.5'
end

V2

# Uncomment this line to define a global platform for your project
platform :ios, '8.3'

def shared_pods
        pod 'Parse', '~> 1.7.5'
end

target 'WatchBumpTesting' do
        shared_pods
end

target 'WatchBumpTesting WatchKit App' do

end

target 'WatchBumpTesting WatchKit Extension' do
        shared_pods
end

V3

# Uncomment this line to define a global platform for your project
platform :ios, '8.3'

link_with 'WatchBumpTesting', 'WatchBumpTesting WatchKit Extension'

target 'WatchBumpTesting' do
        pod 'Parse', '~> 1.7.5'
end

target 'WatchBumpTesting WatchKit App' do

end

target 'WatchBumpTesting WatchKit Extension' do

end

All three produced different results, none of which were desired. V3 would not install the pod. It stated [!] Targets with different platforms.

V1 and V2 resulted in a warning and an error. The warning...

Pods-WatchBumpTesting WatchKit Extension was rejected as an implicit dependency for 'libPods-WatchBumpTesting WatchKit Extension.a' because it doesn't contain platform 'watchsimulator' in its SUPPORTED_PLATFORMS 'iphonesimulator, iphoneos'

The error changed depending on if I imported the library in the extension or not. The good thing which has come from all of this was that my WatchKit Extension InterfaceController.h file could now see <Parse/Parse.h> However, when I imported it it complained that PFPurchase.h could not find the StoreKit library.

enter image description here

I attempted to import the library in the WatchKit Extension targets "Linked Frameworks and Libraries" but it could not be found - I'm assuming this is because it is iOS 9 and not WatchKit. Importing it in the iOS App's target did not fix the problem.

The second error I received was when I left the Podfile as is (V1 and/or V2) but didn't import <Parse/Parse.h> or <Parse.h> in my InterfaceController.h This time I recieved...

ld: library not found for -lPods-WatchBumpTesting WatchKit Extension-Bolts
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am at a complete and utter loss. I've exhausted all options! Any thoughts would be greatly appreciated. I'm using the latest Xcode 7 Beta as well as CocoaPods 0.37.2

like image 790
Atlas Wegman Avatar asked Nov 09 '22 10:11

Atlas Wegman


1 Answers

Looks like you have to specify the watchos platform for CocoaPod configurations targeting WatchOS apps. Take a look at this for more info: https://github.com/neonichu/native-watchOS-example?

like image 165
g0ld2k Avatar answered Nov 14 '22 22:11

g0ld2k