I'm having troubles setting up OCMockito (and OCHamcrest) with Cocoapods on Xcode 5. This is my Podfile:
platform :ios, '5.0'
pod 'RestKit', '~> 0.20.0'
pod 'OCMockito', '~> 1.0.0'
link_with ['WeatherApp', 'WeatherAppTests']
When I try to follow iOS Project Setup (https://github.com/jonreid/OCMockito#adding-ocmockito-to-your-project), Xcode can't find this imports:
#define HC_SHORTHAND
#import <OCHamcrestIOS/OCHamcrestIOS.h>
#define MOCKITO_SHORTHAND
#import <OCMockitoIOS/OCMockitoIOS.h>
So I tried to do this insted:
#define HC_SHORTHAND
#import <OCHamcrest/OCHamcrest.h>
#define MOCKITO_SHORTHAND
#import <OCMockito/OCMockito.h>
It's working, but I don't know if that's fine.
Also, I have another question. As far as I understand, I'm linking RestKit and OCMockito to both my main target and my test target. Is it possible to link RestKit on both targets but link OCMockito only to the test target?
Thanks in advance for the help.
UPDATE:
This is the Pods.xcconfig generetad by Cocoapods:
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/AFNetworking" "${PODS_ROOT}/Headers/OCHamcrest" "${PODS_ROOT}/Headers/OCMockito" "${PODS_ROOT}/Headers/RestKit" "${PODS_ROOT}/Headers/RestKit/RestKit" "${PODS_ROOT}/Headers/RestKit/RestKit/CoreData" "${PODS_ROOT}/Headers/RestKit/RestKit/Network" "${PODS_ROOT}/Headers/RestKit/RestKit/ObjectMapping" "${PODS_ROOT}/Headers/RestKit/RestKit/Support" "${PODS_ROOT}/Headers/SOCKit" "${PODS_ROOT}/Headers/TransitionKit"
OTHER_LDFLAGS = -ObjC -framework CFNetwork -framework CoreData -framework CoreGraphics -framework MobileCoreServices -framework Security -framework SystemConfiguration
PODS_ROOT = ${SRCROOT}/Pods
It seems that the IOS headers aren't setup correctly, is the pod wrong then?
UPDATE:
This are the contents of Pods/Headers/OCMockito
OCHamcrestIOS applies only to using the prebuilt iOS framework. When using CocoaPods, just import OCHamcrest.
To use OCHamcrest (or OCMockito) in your test target bundle and not your main app you can add something like this to the Podfile:
target :YourTestTarget, :exclusive => true do
pod 'OCHamcrest', '~> 3.0'
pod 'OCMockito', '~> 1.0'
#pod 'RestKit/Testing'
end
If you plan to unit test your RestKit mapping (etc) then you may want to include RestKit/Testing in your bundle also.
Then you'd just include it like this:
#define HC_SHORTHAND
#import <OCHamcrest/OCHamcrest.h>
#define MOCKITO_SHORTHAND
#import <OCMockito/OCMockito.h>
This is what your complete Podfile might look like:
platform :ios, '5.1'
pod 'Appirater', '~> 0.0.2'
pod 'FlurrySDK', '~> 4.0.5'
pod 'RestKit', '~> 0.21.0'
target :FooBarTests, :exclusive => true do
#pod 'RestKit/Testing'
pod 'OCHamcrest', '~> 3.0'
pod 'OCMockito', '~> 1.0'
end
Related
I am trying to upgrade to FirebaseCrashlytics from Crashlytics. I am able to import Firebase but not FirebaseCrashlytics. Here is my podfile:
platform :ios, :deployment_target => "9.0"
def shared_pods
pod 'Firebase/Crashlytics'
pod 'Firebase/Analytics'
pod 'SVProgressHUD'
pod 'IGHTMLQuery'
pod 'OpenTok', '~> 2.16.3'
end
target 'MyApp' do
#use_frameworks!
shared_pods
end
I cannot uncomment use_frameworks! since it breaks other pods I am already using.
My bridging header:
#import "FirebaseCrashlytics/FirebaseCrashlytics.h"
#import "FirebaseCore/FirebaseCore.h"
This is what I am getting:
According to the firebase docs then you just have to import Firebase, not FirebaseCrashlytics.
https://firebase.google.com/docs/crashlytics/get-started?platform=ios
If you're using it as a Swift framework then make sure you add it to your target's Frameworks, Libraries, and Embedded Content
My build failed with swift linker command failed with exit code 1. The logs specifically say symbol(s) not found for architecture x86_64
This happened ever since I tried setting up Google-Maps-iOS-Utils.
This is my Podfile. There is a pre_install portion because without it, pod install will have a 'Pods-Project' target has transitive dependencies that include static binaries error.
# platform :ios, '9.0'
target 'My App' do
use_frameworks!
platform :ios, '11.3'
# Pods for My App
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils' #the new pod that caused issues
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'GoogleSignIn'
pod 'Firebase/Database'
pod 'Firebase/Storage'
pod 'FirebaseUI/Storage'
pod 'Fabric', '~> 1.7.9'
pod 'Crashlytics', '~> 3.10.5'
target 'My AppTests' do
inherit! :search_paths
# Pods for testing
end
end
pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
end
This is my Bridging-Header.h
#ifndef Bridging_Header_h
#define Bridging_Header_h
#import <Google-Maps-iOS-Utils/GMUMarkerClustering.h>
#endif /* Bridging_Header_h */
Some troubleshooting measures I tried:
Cleaning Build Folder and Building again;
de-integrating pods and pod installing again.
Any help is appreciated. Thanks.
This solution worked for me. There is no need for this portion in the Podfile as well.
pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
end
I also had to delete the framework the binary search path in Build Phases.
Try to add library location in binary search path of build setting.
I create a Xcode Framework project, and then I use CocoaPods to import another module. Then I want to write a Unit Test.
But when Unit Test run, there has been an run time error
2019-02-02 10:20:39.157536+0800 xctest[90385:6327514] The bundle “XXX” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2019-02-02 10:20:39.157855+0800 xctest[90385:6327514] (dlopen_preflight(/Users/XXX/Library/Developer/Xcode/DerivedData/XXX-dfsjsywxidmqgmaudrhgrhgniihc/Build/Products/Debug-iphonesimulator/XXX.xctest/XXXTests): Library not loaded: #rpath/XXX1.framework/XXX1
Referenced from: /Users/XXX/Library/Developer/Xcode/DerivedData/XXX-dfsjsywxidmqgmaudrhgrhgniihc/Build/Products/Debug-iphonesimulator/XXX.framework/XXX
Reason: image not found)
Program ended with exit code: 82
How can solve this problem.
In your Podfile, make sure that your module is also available for your Unit Test target.
Here is an example, some pods inherited from the main target, other only available for testing purpose.
platform :ios, '8.0'
use_frameworks!
target 'MyApp' do
pod 'AFNetworking', '~> 2.6'
pod 'ORStackView', '~> 3.0'
pod 'SwiftyJSON', '~> 2.3'
target 'MyAppTests' do
inherit! :search_paths
pod 'Quick'
end
end
This question already has answers here:
ld: framework not found Stripe for architecture x86_64
(4 answers)
iOS , ld: framework not found GoogleMaps for architecture arm64
(3 answers)
Closed 6 years ago.
I got the following error testing my test target in Xcode:
ld: framework not found GoogleMapsBase for architecture x86_64
My project is an iOS project so I don't really understand why it builds with a x86_64 architecture. When examining my Pods project, the build settings feature the following settings:
Base SDK: No SDK (Latest macOS)
Supported Platforms: macOS
Valid architectures: i386 x86_64
My Podfile looks like this:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target 'Foo' do
use_frameworks!
...
pod 'GooglePlaces', '2.0.1'
...
target 'FooTests' do
inherit! :search_paths
pod 'Quick', '~> 1.0'
pod 'Nimble', '~> 5.0'
end
end
What can I do to fix this issue?
UPDATE: cf this link for the answer of a similar question that helped me fix my issue.
A question. Do you literally included ... in your podfile? Or is it you are omitting other pods with this sign?
Now, the simpler edition of your podfile would be like this:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target 'Foo' do
use_frameworks!
pod 'GooglePlaces', '2.0.1'
end
target 'FooTests' do
pod 'Quick', '~> 1.0'
pod 'Nimble', '~> 5.0'
end
This should work. Let us know what you got.
I spend hours trying Extension target to use separate pods config from main target. The reason for that is that Pods are duplicated for extension target and thus making your whole app about twice in size. Need to make Extension contain only pods that's necessary there.
There seem to be some magic that XCode does when embedding Extension into main target, and CocoaPods seem to be oblivious to that whole procedure? Or I am doing it wrong? I tried al kinds of Podfile configurations, nothing works.
Anyone was able to successfully achieve that?
to reproduce:
Create a new project, target "MainTarget"
select Add Target > Today Extension, name target "Extension"
Create podfile:
target 'MainTarget' do
pod 'RestKit', '~> 0.20.3'
pod 'AFNetworking', '~> 1.3.1'
pod 'SSKeychain', '~> 1.2.0'
pod "MagicalRecord/Shorthand", '~> 2.2'
pod 'StyledPageControl', '~> 1.0'
pod 'GoogleAnalytics-iOS-SDK', '~> 3.0.2'
end
target 'Extension' do
pod 'AFNetworking', '~> 1.3.1'
end
4 run pod install
5 build
result:
/Users/d/Library/Developer/Xcode/DerivedData/MainTarget-fvmcyblwdybpkdgfzflcjhqpjxab/Build/Products/Debug-iphonesimulator/libPods.a(AFHTTPRequestOperation.o)
/Users/d/Library/Developer/Xcode/DerivedData/MainTarget-fvmcyblwdybpkdgfzflcjhqpjxab/Build/Products/Debug-iphonesimulator/libPods-MainTarget.a(AFHTTPRequestOperation.o)
duplicate symbol _OBJC_IVAR_$_AFHTTPRequestOperation._successCallbackQueue in:
/Users/d/Library/Developer/Xcode/DerivedData/MainTarget-fvmcyblwdybpkdgfzflcjhqpjxab/Build/Products/Debug-iphonesimulator/libPods.a(AFHTTPRequestOperation.o)
/Users/d/Library/Developer/Xcode/DerivedData/MainTarget-fvmcyblwdybpkdgfzflcjhqpjxab/Build/Products/Debug-iphonesimulator/libPods-MainTarget.a(AFHTTPRequestOperation.o)
...(and so on... every file repeated 4 times.)
ld: 2148 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is because you're including AFNetworking at least twice. If it is the only library you need in your extension you should use:
target 'Extension', :exclusive => true do
pod 'foo'
end
Documented here
If you would instead like all your libraries linked to your extension you should remove your 'MainTarget' group and use link_with as shown here
I figured out how to do it thanks to Keith Smiley.
It required me a little testing. Here is what I did
platform :ios, 7.0
link_with ['Target', 'Target todays widget']
pod 'AFNetworking', '~> 2.2'
Than I had to remove the libPods.a and the others before redoing a pod install and it worked.