FacebookShare causing compiler error after update

大憨熊 提交于 2019-12-20 11:04:20

问题


I just ran pod update for my app, and now it won't compile, giving these issues from LinkShareContent.swift in FacebookShare.

Cannot assign to property: 'contentDescription' is a get-only property
Cannot assign to property: 'contentTitle' is a get-only property
Cannot assign to property: 'imageURL' is a get-only property

These were the Facebook-related lines in my pod update:

Installing FBSDKCoreKit 4.23.0 (was 4.22.0)
Installing FBSDKLoginKit 4.23.0 (was 4.22.0)
Installing FBSDKShareKit 4.23.0 (was 4.22.0)
Using FacebookCore (0.2.0)
Using FacebookLogin (0.2.0)
Using FacebookShare (0.2.0)

Does anyone know about this problem? Did I do something wrong?


回答1:


Regarding docs of FBSDKShareLinkContent these properties have been deprecated:

@deprecated contentDescription is deprecated from Graph API 2.9. For more information, see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations.

@deprecated contentTitle is deprecated from Graph API 2.9. For more information, see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations

@deprecated imageURL is deprecated from Graph API 2.9. For more information, see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations

You should probably use quote and contentURL instead of them.

As a temporary solution, you can unblock the file LinkShareContent.swift and directly remove above lines until Facebook releases any update.




回答2:


I do not think referencing Github user 1amageek's repo with

pod 'FacebookShare', :git => 'https://github.com/1amageek/facebook-sdk-swift'

is a good idea, 1amageek could be the most awesome developer in the world and still delete his/her fork of the Facebook Swift SDKs

Until fixed you should change your Podfile to

pod 'FacebookCore', '~> 0.2'
pod 'FacebookLogin', '~> 0.2'
pod 'FacebookShare', '~> 0.2'
pod 'FBSDKCoreKit', '~> 4.22.1'
pod 'FBSDKLoginKit', '~> 4.22.1'
pod 'FBSDKShareKit', '~> 4.22.1'

And run pod update again.

Note that this code is not adding "duplicate" pods (older FBSDK[Core etc] + newer Facebook[Core etc]), the code is just being completely explicit about the Pods you are installing. If you were to list only pods FacebookCore, FacebookLogin, and FacebookShare, the FBSDKs will be installed by Cocoapods as dependencies anyways.

Reference: https://github.com/facebook/facebook-sdk-swift/issues/157  




回答3:


Replace your Podfile content with this:

pod 'FacebookCore'
pod 'FacebookLogin'
pod 'FacebookShare', :git => 'https://github.com/1amageek/facebook-sdk-swift'


来源:https://stackoverflow.com/questions/44248118/facebookshare-causing-compiler-error-after-update

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!