The Facebook Share Sample included with the Facebook SDK for iOS has the source code and project files that you can build and run to demonstrate sharing a photo or a link to Facebook from an app.
This sample will only works on an iOS device and not in the Xcode simulator. Run this sample in a device.
You will need an App ID to run this sample. Learn more at App Development
In this step, you will download the SDK, open the sample project in Xcode, and update the package to the latest package version.
Clone or download the Facebook SDK for iOS at https://github.com/facebook/facebook-ios-sdk.
In Xcode, open /samples/FacebookShareSample/FacebookShareSample.xcodeproj
.
In Xcode, click File > Swift Packages > Update to Latest Package Version.
In this step, you will add your App ID to the information property list file (info.plist
)
Right-click Info.plist
, and choose Open As > Source Code.
Under <key>CFBundleURLSchemes</key>
in the <array> <string>
, replace {your-app-id} with your App ID.
Under <key><FacebookAppID> </key> <string>
, replace {your-app-id} with your App ID.
Run the sample on a device according to the steps in Running Your App in the Simulator or on a Device at developer.apple.com