Cannot use Parse library in WatchKit Extension (CocoaPods) - ios

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

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?

Related

CocoaPods: can my framework depend on other frameworks?

I'm creating a framework called MyFramework. This framework depends on ZipFoundation.
In order to test MyFramework I've created a new target application called MyFrameworkShowcase.
The workspace looks like the following:
MyFramework.xcworkspace
MyFramework.xcodeproj
MyFramework
MyFrameworkShowcase
Pods.xcodeproj
The Podfile looks like the following:
platform :ios, '11.0'
target 'MyFramework' do
use_frameworks!
pod 'ZIPFoundation', '~> 0.9'
end
target 'MyFrameworkShowcase' do
use_frameworks!
end
Running the showcase app I receive the following error:
dyld: Library not loaded: #rpath/ZIPFoundation.framework/ZIPFoundation
Any way I can adjust the Podfile in order to fix this issue?

Starscream on iOS and WatchOS - Cocoapods

im trying to use Starscream both on iOS and WatchOS with Cocoapods.
here's my podfile:
inhibit_all_warnings!
def all_pods
pod 'Starscream', '~>3.0.5'
end
target ‘ProjTest’ do
platform :ios, '10.0'
use_frameworks!
all_pods
end
target 'ProjTestTests' do
inherit! :search_paths
end
target 'ProjTestUITests' do
inherit! :search_paths
end
target 'ProjTestWatch' do
platform :watchos, '5.0'
all_pods
end
I have a class, SocketManager, that I use on the app already, I just want to use that same class on the watchApp Target, but the only error im getting is : No such module 'Starscream' on the import line.
The most weird for me, is if im go look the Framework Search paths, and Header Search Paths on the Watch Target, they're both empty. But if I try to do the same as the iOS app target. and put an $(inherited), they inherit the libs from the iOS App.

Library not found for -lBraintree

I have added Braintree with other lib using pods. My build is failed because it can't find library for Braintree. Here's what I have:
ld: library not found for -lBraintree
clang error: linker command failed with exit code 1 (use -v to see
invocation)
Things I've tried:
Used .xcworkspace instead of .xcodeproj
Set build active architecture NO
Removed any red lib.a
This is what my project looks like:
I don't see a -lBraintree flag in the last picture yet it shows here -ObjC -ObjC -l"AdIdAccessLibrary" -l"Braintree" -l"DI... why?
Podfile
target 'MyProject' do
pod 'Braintree', '3.9.3'
pod 'Google/Analytics', '~> 1.0.0'
pod 'GoogleIDFASupport'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.1'
pod 'GoogleMaps'
end
target 'MyProjectTests' do
end

How to use cocoapod to include shared framework for both ios app and watch extension

I tried to use one framework (Realm.framework) for both of my ios app and ios watch kit.
I tried many ways, none of them work. Could anyone give me an example of how to write a pod file to share a framework between ios app and watch app?
With out any watch extension target in pod file, I got an error saying:
Target 'Realm' of project 'Pods' was rejected as an implicit dependency for 'Realm.framework' because it doesn't contain platform 'watchsimulator' in its SUPPORTED_PLATFORMS 'iphonesimulator, iphoneos'
Target 'RealmSwift' of project 'Pods' was rejected as an implicit dependency for 'RealmSwift.framework' because it doesn't contain platform 'watchsimulator' in its SUPPORTED_PLATFORMS 'iphonesimulator, iphoneos'
Target 'Pods' of project 'Pods' was rejected as an implicit dependency for 'Pods.framework' because it doesn't contain platform 'watchsimulator' in its SUPPORTED_PLATFORMS 'iphonesimulator, iphoneos'
Then I added target for watch extension to my pod file. Here is my pod file:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
link_with 'myApp', 'myApp Watch Extension'
def shared_pods
pod 'RealmSwift'
end
target 'myApp' do
podspec :path => 'myapp.podspec'
pod 'SnapKit'
pod 'ChameleonFramework/Swift'
pod 'Google-Mobile-Ads-SDK'
shared_pods
end
target 'myApp Watch Extension' do
podspec :path => 'myapp.podspec'
platform :watchos, '2.0'
shared_pods
end
I got it run with warnings with "pod install", but my workspace failed to run.
2015-12-07 15:45:46.402 ruby[17042:4339468] warning: The file reference for "Realm.framework" is a member of multiple groups ("Products" and "Products"); this indicates a malformed project. Only the membership in one of the groups will be preserved (but membership in targets will be unaffected). If you want a reference to the same file in more than one group, please add another reference to the same path.
2015-12-07 15:45:46.402 ruby[17042:4339468] warning: The file reference for "RealmSwift.framework" is a member of multiple groups ("Products" and "Products"); this indicates a malformed project. Only the membership in one of the groups will be preserved (but membership in targets will be unaffected). If you want a reference to the same file in more than one group, please add another reference to the same path.
There are so many errors in my Pods-myApp Watch Extension-Realm file.
I also tried pod file like:
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
link_with 'myApp', 'myApp Watch Extension'
def shared_pods
pod 'RealmSwift'
end
target 'myApp' do
podspec :path => 'myapp.podspec'
platform :ios, '8.0'
pod 'SnapKit'
pod 'ChameleonFramework/Swift'
pod 'Google-Mobile-Ads-SDK'
shared_pods
end
target 'myApp Watch Extension' do
podspec :path => 'myapp.podspec'
platform :watchos, '2.0'
shared_pods
end
Then I got "[!] Targets with different platforms" error.
In my podspec, I already added lines:
s.platform = :ios
s.platform = :ios, "8.0"
s.platform = :watchos
s.platform = :watchos, "2.0"
Could anyone show me how it should be done?
The warnings, you saw, after running pod install shouldn't appear and are definitively a bug in CocoaPods / Xcodeproj. That seems to be related to the UUID generation and the warning you might have seen about that as well:
[!] [Xcodeproj] Generated duplicate UUIDs:
…
You have two target specific dependency definition groups in your Podfile.
You can't link to the implicit root target in the Podfile to both your app and its extension as their are on different platforms. That means you have to remove the 3rd/4th line:
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
#link_with 'myApp', 'myApp Watch Extension' # <= REMOVE this line.
…
I can't reproduce the error you're seeing in Xcode about the rejection of targets as implicit dependencies. As I don't have your podspec, I can't reproduce it exactly, but from what I see it shouldn't matter as long as your podspec doesn't declare any dependencies.
Beside that, it is sufficient to declare the platform availability by just those two lines in the podspec:
s.platform = :ios, "8.0"
s.platform = :watchos, "2.0"

Headers not found when referencing CocoaPods project from Swift

I would like to include iOS-WebP as a pod to my Swift project.
The pod spec reads
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'iOS-WebP', '0.4'
In Swift, I use import iOS_WebP to use the library.
However, compilation fails with the relative header paths inside the library not resolving correctly:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/.../Products/Debug-iphoneos/Pods/iOS_WebP.framework/Headers/Pods-iOS-WebP-umbrella.h"
^
/Users/.../Build/Products/Debug-iphoneos/Pods/iOS_WebP.framework/Headers/Pods-iOS-WebP-umbrella.h:3:9: note: in file included from /Users/.../Build/Products/Debug-iphoneos/Pods/iOS_WebP.framework/Headers/Pods-iOS-WebP-umbrella.h:3:
#import "UIImage+WebP.h"
^
/Users/.../Build/Products/Debug-iphoneos/Pods/iOS_WebP.framework/Headers/UIImage+WebP.h:10:9: error: 'WebP/decode.h' file not found
#import <WebP/decode.h>
^
/Users/...ViewController.swift:3:8: error: could not build Objective-C module 'iOS_WebP'
import iOS_WebP
^
Building the library standalone via the scheme switcher works fine, it's only the integration into the Swift project that fails.
Cleaning DerivedData did not help, and the .xcconfig properly references the library both in OTHER_CFLAGS and OTHER_LDFLAGS.
Update
It works if I remove use_frameworks! and include the library via the ObjC Bridging header. Is there a way to disable use_frameworks! for a single pod?
Update 2
With this pod file, it compiles.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
xcodeproj 'xxx'
target "Frameworks", :exclusive => true do
link_with "xxx"
use_frameworks!
pod ....
end
target "StaticLibraries", :exclusive => true do
link_with "xxx"
pod 'iOS-WebP', '0.4'
end
Problem is that now when I launch the app, it doesn't seem to find the frameworks:
dyld: Library not loaded: #rpath/XXX.framework/XXX
Referenced from: /private/var/mobile/Containers/Bundle/Application/...
Reason: image not found
(lldb)

Resources