Added AFNetworking via cocoapods - AFHTTPClient.h/m are not included - ios7

When I use cocoapods to add AFNetworking to my workspace, everything appears to be in place but I am unable to instantiate any AFHTTPClient instances in my code. The files: AFHTTPClient.h and .m are not present anywhere within the AFNetworking hierarchy.
Currently, my Podfile looks like this:
platform :ios, '7.0'
pod 'AFNetworking', '~> 2.0'
pod 'Parse', '1.2.17'
And my CLI pod update command runs fine from the terminal as shown below:
nmaster >> pod update
Analyzing dependencies
Downloading dependencies
Using AFNetworking (2.0.3)
Using Facebook-iOS-SDK (3.11.0)
Using Parse (1.2.17)
Generating Pods project
Integrating client project
The error I am seeing in my code is shown below:
I've seen a number of posts referring to the HEADER SEARCH PATH being insufficient but I've already confirmed that the files themselves do not exist. Has AFHTTPClient been deprecated? I did find a copy in one of Ray W.'s tutorials of both the AFHTTPClient.h and .m files and tried to drag/drop those into my project but that led to duplicate references and other problemos.
Anyone have any ideas of where I should attack this problem?
Thanks, Phil

AFHTTPClient has been replaced by other classes in AFNetworking version 2.0. See also here: https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-2.0-Migration-Guide. If you specify version 1.6.x (from memory) and iOS 6.1 in your podfile, you can still use the old version and keep your code.

Related

How to handle Cocoapod dependency?

I'm creating my first cocoapod. It has a dependency on RMStore, so I added s.dependency "RMStore" to the podspec file. However, when I'm working on my framework, I always get errors saying that RMStore isn't available. So how do I handle this?
After adding s.dependency, you do indeed need to run pod install against your project so that the pods download and the pods project correctly references everything. Assuming you have an Example/Tester project with a Podfile that points to "your pod", this will download RMStore and configure everything for you.
I prepared an example of how to do dependencies in developed pods and it's available here:
https://github.com/ericwastaken/CocoaPod-Dependency-Demo

Swift pod in objective-c project issue

I tried to update a Pod that is in swift now.
So I added use_frameworks! into my Podfile and pod install.
I also checked "Embedded Content Contains swift Code" is YES
The error that my other pods that are in Objective-C cannot be found. (file not found)
If I understoof, use_frameworks compiles all pods as frameworks even the objective C ones that don't need that, but anyone can help me fix this issue ?
Do I need to use a Bridging-Header ?
When using frameworks with Swift pods, instead of using a bridging header, in the files that you wish to use the framework in, you just have to import FrameworkName

Solve namespace collision for pod dependency

I have a CocoaPod that has AFNetworking as a dependency (current version is 2.6.3).
At the same time I want to use RestKit which still uses AFNetworking 1.3.0.
Is there a "sane" way of mangling my AFNetworking symbols so that they don't conflict with RestKit?
Example podspec file snippet:
s.dependency 'JSONModel', '~> 1.1'
s.dependency 'tolo','~> 1.0'
s.dependency 'AFNetworking', '~> 2.0'
In another project, I have:
pod 'RestKit'
pod 'MyLibrary'
The result:
[!] Unable to satisfy the following requirements:
- 'AFNetworking (= 1.3.4)' required by 'Podfile.lock'
- 'AFNetworking (~> 2.0)' required by 'MyLibrary (2.0)'
I've also tried using CocoaPods packager but without success. The dependencies of MyLibrary for some reason are not included in the mangled framework.
I've also tried to mangle only AFNetworking, but again no success as I can't point to a local dependency in the podspec file (!?).
If your using RestKit in your project you can't use AFNetworking 2.x as RestKit is tightly integrated with AFNetworking 1.3.x Your options are to use AFNetworking 2.x and remove RestKit from your Podfile or use RestKit and remove your dependencies for AFNetworking 2.x A quick google search for AFNetworking 2.x vs RestKit should bring up a lot of articles covering the subject. I hope my comments help you out.

RestKit and CocoaLumberjack integrated as frameworks in Xcode7

I'm working on a project that uses both RestKit and CocoaLumberjack. The project also uses some other pods, some of them only exist in swift. I use cocoapods 0.38.2 for dependency management, my podfile looks like this (removed other pods for readability):
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'RestKit'
pod 'CocoaLumberjack'
I need to use use_frameworks! because of those other pods that are swift-only. I try to compile this using Xcode7 beta 5, I get the following errors:
"_OBJC_CLASS_$_DDLog", referenced from:
objc-class-ref in RKLumberjackLogger.o
ld: symbol(s) not found for architecture x86_64
So I took a look into the offending file and found this:
#if __has_include("DDLog.h")
#import "RKLumberjackLogger.h"
#import "DDLog.h"
Looks like the entire file resolves to nothing if the DDLog.h is not present, in which case I think the RestKit logging falls back to NSLog or whatever. Otherwise, the Lumberjack logging is used, which is what I want.
After some investigation, my suspicion is that the RestKit somehow sees the CocoaLumberjack headers (where the DDLog.h is), but is not properly linked against it when the project is built. Feel free to question this in case you have better ideas, but I can confirm that going to the CocoaLumberjack sources and manually adding DDLog.m as a member to the RestKit framwork target allows me to compile the project properly.
So, my question is, what is the correct way of fixing this? RestKit is not directly dependent on CocoaLumberjack, but tries to detect it and use it if possible, but fails miserably. Is there a way to link RestKit with Lumberjack from my project level so I don't have to modify the pods?
Example project can be found here
Your suspicion is correct.
RestKit somehow sees the CocoaLumberjack headers (where the DDLog.h is), but is not properly linked against it when the project is built
This is a problem with RestKit and everything that you would do within your own project would be a workaround. So arguably, there is no single correct way to fix this in your project.
I have filed a Pull Request with a fix for this issue.
Update:
The pull request has been merged, but at the time of writing this update, no new version of RestKit has been released yet.
pod "RestKit", :head, :subspecs => ['Core', 'CocoaLumberjack']
RestKit's Lumberjack logging functionality has been moved into a separate subspec that you have to specify if you want to use it.
:head will tell CocoaPods to use the current master instead of a released version.

target overrides the FRAMEWORK_SEARCH_PATHS build settings

I'd like to ask and then answer this question.
I'd like to update the CocoaPods built into my app, so I ran pod install from the terminal.
That's when I got this error:
[!] The `APP_NAME [Debug]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
How do you Use the $(inherited) flag?
Selected the Project, targets-> app, then Build Settings where I added the $(inherited) line, deleting whatever specific pod had been referenced there before:
I was encountering this issue as well.
Aside from doing what Peter mentioned above, remember to double check if the correct Xcode project is selected in your podfile. This is because it is possible that you are changing the Build Settings of the incorrect Xcode project. It was a silly mistake, but it took quite some time before I realized it.
Normally, pod install works automatically if there is only one .xcodeproj file in the directory. However, if you are migrating your project to begin using cocoapods from the old way of manually adding frameworks/3rd party projects to your Xcode project, it is possible that you will have multiple .xcodeproj files in your folder. Doing the abovementioned fix didn't solve it for me, because I was editing the incorrect .xcodeproj file.
Go to your project directory, check the file named Podfile and make sure you specify the xcodeproj:
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!
xcodeproj 'APP_NAME.xcodeproj'
target 'APP_NAME' do
# Your dependencies here
# pod 'NAME_OF_DEPENDENCY'
pod 'Google/CloudMessaging'
pod 'RxSwift', '~> 2.0'
pod 'RxCocoa', '~> 2.0'
pod 'RxBlocking', '~> 2.0'
pod 'Fabric'
pod 'Crashlytics'
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
After selecting the correct .xcodeproj on your Podfile, go to Xcode and do the following:
From the Project Navigator on the left side, select your project.
On the center screen, go to Build Settings
Add a filter for 'Framework Search Paths'
Enter $(inherited) as the value; it should auto-fill with data evaluating that expression
Below is an image of Xcode with Version 7.2 (7C68).
I had a $(inherited) but recursive, just change it to non-recursive
project target -> build settings -> framework_search_path
I had this same problem (error build: Framework not found Pods_xxx) when updating cordova-onesignal from v2 to 3.3.0 on an old Ionic 3 project.
This solved it for me:
In Xcode, navigate Project + Target + General + Scroll down to Frameworks, Libraries, and Embedded Content
In the list I simply deleted (minus sign at bottom of list) the related file Pods_xxx.framework (it was a little grayed out)
After rebuild everything worked (incl OneSignal)
If I do pod install it comes back and I have to do it all over again.