I am trying to show the Facebook ShareDialog using FacebookShare Swift SDK 0.3.2 not FBSDKShareKit with the below function in a presented view controller
import FacebookShare
func facebookShare() {
let photo = Photo(image: image, userGenerated: true)
let myContent = PhotoShareContent(photos: [photo])
let shareDialog = ShareDialog(content: myContent)
shareDialog.presentingViewController = self
shareDialog.mode = .automatic
shareDialog.completion = { result in
print("- in completion")
}
do {
try shareDialog.show()
} catch {
print(error)
}
I am getting this error in the console.
2018-09-03 16:12:11.235865+0100 APPNAME[1865:386979] FBSDKLog: param { "advertiser_tracking_enabled" = 0; "anon_id" = "XXXXX-XXXXXX-XXXXX-XXXXX"; "application_tracking_enabled" = 1; "custom_events" = "[{\"_ui\":\"no_ui\",\"_eventName\":\"fb_dialog_share_result\",\"_logTime\":1535987524,\"fb_dialog_outcome_error_message\":\"Error Domain=com.facebook.sdk.share Code=2 \\"(null)\\" UserInfo={com.facebook.sdk:FBSDKErrorArgumentValueKey=, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Must have an asset, image, or imageURL value., com.facebook.sdk:FBSDKErrorArgumentNameKey=photo}\",\"fb_dialog_outcome\":\"Failed\",\"_implicitlyLogged\":\"1\"}]"; event = "CUSTOM_APP_EVENTS"; extinfo = "[\"i2\",\"com.APPNAME\",\"1\",\"1.0\",\"11.4.1\",\"iPhone8,4\",\"en_GB\",\"BST\",\"Three\",320,568,\"2.00\",2,60,46,\"Europe\/London\"]"; "url_schemes" = "[\"fbapiXXXXXXX\",\"fbXXXXXXXXX\",\"twitterkit-sasasasasasasa\",\"com.googleusercontent.apps.XXXXXXXXXX-XXXXXXXX\"]"; }
Although the error says:
Must have an asset, image, or imageURL value.
I have confirmed a UIImage is within the myContent let passed to the ShareDialog with breakpoints.
This is an issue with the FacebookSDK which has been raised here:
https://github.com/facebook/facebook-sdk-swift/issues/264
Temporary workaround until fix, remove Facebook pods from pod file and add the below, then run pod install.
pod 'FacebookCore', '0.3.1'
pod 'FacebookLogin', '0.3.1'
pod 'FacebookShare', '0.3.1'
pod 'FBSDKCoreKit', '4.35.0'
pod 'FBSDKLoginKit', '4.35.0'
pod 'FBSDKShareKit', '4.35.0'