D
D
Denis2015-10-14 18:50:30
iOS
Denis, 2015-10-14 18:50:30

What am I doing wrong when connecting frameworks via Cocoapods in iOS?

Hello. I'm trying to connect third-party libraries to my iOS project via Cocoapods.
Here is the contents of the Podfile

platform :ios, "7.0"
target 'MyApp' do
  pod 'Fabric'
  pod 'Crashlytics'
  pod 'SDWebImage', '~> 3.7'
  pod 'SVProgressHUD', '~> 1.1'
  pod 'TPKeyboardAvoiding', '~> 1.2'
end
Did everything according to the instructions. First pod init, then pod install. Judging by the logs on the command line, the installation was successful.
What I get in the project itself (project file with the .xcworkspace extension):
There is a separate Pods module/project. In it, in the "Pods" group, there are folders with plug-in frameworks and libraries. In general, everything is as it should be.
But further strangeness. The "Products" group contains 4 libraries:
  • libPods-MyApp.a
  • libSDWebImage.a
  • libSVProgressHUD.a
  • libTPKeyboardAvoiding.a

In order for SDWebImage, SVProgressHUD and TPKeyboardAvoiding to work, you need to connect the last 3 libraries from the list above to the main project. I did not find any explicit connection of libraries in this way in any tutorial. As far as I understand, they should have been packed into one library "libPods-MyApp.a" which should be used in the main project. In my case, this is a dead weight that does not give anything.
Okay, let me connect the libraries in the way I described and calm down. But with Fabric and Crashlytics, this trick does not work. When I try to compile I get the following error:
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_Crashlytics", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_Fabric", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Logically. After all, the libraries are not connected. I click on the project file, select the appropriate Target, on the General tab, go to the "Linked Frameworks and Libraries" group and try to add the necessary frameworks. They are not in the list, so I press the "Add another .." button and indicate the path to them. The frameworks are located in the folders .\Pods\Fabric and .\Pods\Crashlytics (The path is relative to the project folder).
But in the end, when I try to compile, I stumble upon the following error:
ld: framework not found Fabric
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I go to the Target of my project, on the tab "Build Settings" I look in the group "Search Paths" settings for "Framework Search Paths". For both Debug and Release there are the following lines:
$(PROJECT_DIR)/Pods/Fabric
$(PROJECT_DIR)/Frameworks
$(PROJECT_DIR)/Pods/Crashlytics
All non-recursive.
Actually, I have a few questions:
1) What needs to be done to connect the Fabric and Crashlytics frameworks?
2) Did I do everything right?
3) Is this generally normal behavior for coocapods? Judging by the tutorials, this should not be.
PS: I connected Crashlytics according to the instructions and judging by the progress, it remains only to launch the application. Run script added and it works.
PPS: I would be glad to receive any answer. I started using Cocoapods quite recently and so far this is new to me. Actually, I don’t have much experience with iOS either, the main platform for me is Android, but there this is done through Gradle and with less trouble.
UPD: I tried to connect the libraries to a clean project. Everything is connected and working. Perhaps the problem is in the settings of my project. But I have no idea what could cause such an effect.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sojik, 2015-10-14
@KamiSempai

Apparently you are doing everything wrong )) took the time, although I already have 0-50 and took an empty project on ObjC, Xcode 7.0.1, El Captain and added your entire Podfile, only for me it looks like
source ' https:// github.com/CocoaPods/Specs.git '
platform :ios, "7.0"
target 'testNewCoreData' do
pod 'Fabric'
pod 'Crashlytics'
pod 'SDWebImage', '~> 3.7'
pod 'SVProgressHUD', '~> 1.1'
pod 'TPKeyboardAvoiding', '~> 1.2'
end
then I had to do the standard
sudo gem install cocoapods
pod install
got the workspace going
I added the AppDelegate lines

#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>

and
everything is going great. I recommend doing the same as me.
If it doesn't work, try to remove cocoapods from the project and try to install them again.
here I will post my test project now, so that you can see how they see me. Just have to pod install after downloading and unpacking)
https://www.dropbox.com/s/c7bnn8jhugx4q2r/testNewC...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question