Search code examples
xcodecocoapodsfacebook-ios-sdk

Trying to Rebuild a Legacy IOS App, Getting Error in Facebook-IOS-SDK Cocoapod


I've been asked to rebuild an existing IOS app that uses Facebook-IOS-SDK. The app is at least 5 years old so I expected things to be deprecated. I have some limited experience with XCode and IOS but I'm far from an expert. I've never used cocapods until today. I installed cocoapods and ran pod init. Facebook-IOS-SDK ver 3.24.4 loaded with no errors (other pods too, including Bolt, with no errors).

I've read the migration notes on the FB dev page regarding the versions and it's implied that I should be able to use 3.24. When I do a clean build I get the error:

(FBRequest *)requestForUpdateOpenGraphObject(id<FBOpenGraphObject>)object 
{
    return [FBRequest requestForUpdateOpenGraphObjectWithId:object[@"id"] graphObject:object];
}

Expected method to read dictionary element not found on object of type 'id<FBOpenGraphObject>'

This error is in FBRequest.m, the cocoapod code, not in my clients code. This code is marked read only. If this is the correct pod version, and I can't change it then is there some other dependency in the (large) project that needs to be updated?

Podfile:

# Uncomment this line to define a global platform for your project
platform :ios, "9.0"
target "tbd" do
   pod 'IQKeyboardManager'
   pod 'UICKeyChainStore'
   pod 'CocoaLumberjack', '~> 2.0.0-beta'
   pod 'SDURLCache'
   pod 'HockeySDK'
   pod 'Facebook-iOS-SDK', '~> 3.23'
   pod 'GoogleAnalytics-iOS-SDK'
   pod 'UIActionSheet-Blocks', '~> 1.0'
end

target "tbdTests" do

end

Solution

  • The only, nasty, solution I found is to change the code inside FBRequest.m manually.

    Change line 370 from:

    return [FBRequest requestForUpdateOpenGraphObjectWithId:object[@"id"] graphObject:object];
    

    to

    return [FBRequest requestForUpdateOpenGraphObjectWithId:object.objectID graphObject:object];
    

    this should make you project runs again.

    Again, this is not a nice solution, but it works :) Emilio