Lê Khánh Vinh Lê Khánh Vinh - 1 year ago 192
Objective-C Question

Update AFNetworking from version 1.2.1 to 3.1.0

Iam about to update our post project in Objective C to meet the new Apple requirement for support Ipv6 only. My

libray is now 1.2.1. I doubt it is the problem. I want to update to latest version support IPv6 but when running pod install I get this error

[!] Unable to satisfy the following requirements:

  • AFNetworking (~> 3.1.0)
    required by

  • AFNetworking (= 3.1.0)
    required by

  • AFNetworking (~> 1.2.1)
    required by
    AFRaptureXMLRequestOperation (1.0.2)

Here is my complete pod file

platform :ios, '7.0'

def shared_pods
pod 'RaptureXML'
pod 'Realm'

def ios_pods

pod 'AFRaptureXMLRequestOperation'
pod 'GoogleAnalytics-iOS-SDK', '~> 3.0.9'
pod 'KGModal', '~> 0.0.1'
pod 'MagicalRecord'
pod 'MHNatGeoViewControllerTransition', '~> 1.0'
pod 'SVProgressHUD', '~> 1.0'
pod 'UALogger', '~> 0.2.3'
pod 'Reachability', '~> 3.1.1'
pod 'RegexKitLite', '~> 4.0'
pod 'SSKeychain', '~> 1.2.1'
pod 'TTTAttributedLabel'
pod 'TPKeyboardAvoiding', '~> 1.1'
pod 'UIAlertView+Blocks', '~> 0.7'
pod 'UIActivityIndicator-for-SDWebImage', '~> 1.0.3'
pod 'SevenSwitch', '~> 1.3.0'
pod 'ZXingObjC', '~> 3.0'
pod 'DeviceUtil', '~> 1.2'

Is there any way to use
with AFNetworking 3.0? or any other solution? Any help is much appreciate. Thanks

Rob Rob
Answer Source

AFRaptureXMLRequestOperation subclasses AFHTTPRequestOperation, but this class no longer exists in AFNetworking 3.x. You will not be able to use AFRaptureXMLRequestOperation with AFNetworking 3.x.

If you're just parsing XML response with AFNetworking 3.x, you can use AFXMLParserResponseSerializer. It returns a NSXMLParser.

So, set the delegate for that responseObject, and then call parse on it:

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.responseSerializer = [AFXMLParserResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"application/rss+xml"];  // this line is only needed if parsing RSS feed

[manager GET:@"https://developer.apple.com/news/rss/news.rss" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
    NSXMLParser *parser = responseObject;
    parser.delegate = self;
    self.titles = [NSMutableArray array];
    [parser parse];
    NSLog(@"%@", self.titles);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
    NSLog(@"%@", error);

You'll have to write your own NSXMLParserDelegate code, though. So, to parse the titles out of the XML of Apple's RSS feed, I added two properties:

@property (nonatomic, strong) NSMutableArray *titles;
@property (nonatomic, strong) NSMutableString *elementValue;

And then implemented the following NSXMLParserDelegate methods:

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary<NSString *,NSString *> *)attributeDict {
    if ([elementName isEqualToString:@"title"]) {
        self.elementValue = [NSMutableString string];

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
    [self.elementValue appendString:string];

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
    if ([elementName isEqualToString:@"title"]) {
        [self.titles addObject:self.elementValue];
        self.elementValue = nil;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download