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?
Related
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
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"
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?
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)
I have the project, that contains two targets one for iOS and one for OSX.
Here's how the Podfile looks like.
# Pods
xcodeproj 'ipolypus.xcodeproj'
pod 'BlocksKit'
pod 'Reachability'
pod 'MKStoreKit'
# Objective C
pod 'libextobjc'
pod 'LinqToObjectiveC'
target :ipolypus, :exclusive => false do
platform :ios, '5.1.1'
pod 'CocoaLumberjack'
pod 'EGOTableViewPullRefresh'
pod 'SVProgressHUD'
pod 'FlurrySDK'
# AdMob SDK and AdMob mediation adapter
pod 'AdMob'
pod 'AdMobMediationAdapterIAd'
end
target :ipolypusTests, :exclusive => true do
pod 'CocoaLumberjack'
end
target :'ipolypus-osx', :exclusive => false do
platform :osx
pod 'CocoaLumberjack'
end
After running pod install I can see that two Pods libraries are linked against the first target (ipolypus).
libPods.a and libPods-ipolypus.a
If I try to build the project right away, I will get strange link errors, like missing FlurrySDK symbols.
To fix it, I have to remove libPods.a and libPods-ipolypus.a from the list of libraries to link with the target, run pod install again, then manually remove libPods.a for the first target and then it will build and link.
There must be something wrong with the way I make that Podfile. I checked related posts, couldn't find similar problem.
Update
Here's the link error
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_Flurry", referenced from:
objc-class-ref in IOSAppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
After I do the steps described above, I will have successful builds until next pod install or pod update.
I should also mention, that the project had single target for quite a while, then I added OSX target and modified Podfile for that, and that's when the problems started.
But I tried to remove Podfile.lock and to wipe Pods folder, still the problem occurs.
And I had another type of error, where linker failed because the same symbol was already defined, but I don't see that one anymore.
I got to the cause of "double-linking" problem.
It's caused by the structure of the Podfile, as expected.
Since I wanted to have some common pods available both for OSX and iOS targets, I put them all in the beginning.
xcodeproj 'ipolypus.xcodeproj'
pod 'BlocksKit'
pod 'Reachability'
pod 'MKStoreKit'
# Objective C
pod 'libextobjc'
pod 'LinqToObjectiveC'
These common pods will be in libPods.a library, also, CocoaPods can't stand the fact that some pods library is not linked against a target, so it will link libPods.a against default project target, in my example it's ipolypus.
Then there's libPods-ipolypus.a generated for ipolypus iOS target. Since this target is not exclusive, things like FlurrySDK will be included into both libPods.a and libPods-ipolypus.a, resulting into duplicated symbols while linking.
After trying to figure out the proper way to use exclusive/non-exclusive target configs, I ended up with separate list of pods for each target. Might be a bit longer than I would want, but does the job as expected.
# Pods
xcodeproj 'ipolypus.xcodeproj'
target :ios, :exclusive => true do
platform :ios, '6.0'
link_with 'ipolypus'
# shared
pod 'CocoaLumberjack'
pod 'Reachability'
pod 'MKStoreKit'
pod 'LinqToObjectiveC'
# pod 'EGOTableViewPullRefresh'
# platform
pod 'SVProgressHUD'
pod 'FlurrySDK'
# AdMob SDK and AdMob mediation adapter
pod 'Google-Mobile-Ads-SDK'
pod 'AdMobMediationAdapterIAd'
end
target :iosTests, :exclusive => true do
platform :ios, '6.0'
link_with 'ipolypusTests'
pod 'OCMock'
end
target :osx, :exclusive => false do
platform :osx, '10.7'
link_with 'ipolypus-osx'
# shared
pod 'CocoaLumberjack'
pod 'Reachability'
pod 'LinqToObjectiveC'
end
target :osxTests, :exclusive => true do
platform :osx, '10.7'
link_with 'ipolypus-osxTests'
pod 'OCMock'
end