facebook / facebook-sdk-swift
- вторник, 19 июля 2016 г. в 03:12:48
Swift
Integrate your iOS apps in Swift with Facebook Platform.
Swift-taylored experience to integrate your app with Facebook. Including:
Make sure you are running the latest version of CocoaPods by running:
gem install cocoapods
# (or if the above fails)
sudo gem install cocoapods
We support any version of CocoaPods 1.0.1 or later.
Add the following lines to your Podfile:
pod 'FacebookCore'
pod 'FacebookLogin'
pod 'FacebookShare'
pod install
You may also exclude any of these dependencies, if you do not need the features of those parts of the SDK.
Add the following line to your Cartfile:
github "facebook/Facebook-SDK-Swift"
Run carthage update
.
This will fetch dependencies into a Carthage/Checkouts
folder, then build each one.
General
settings tab, in the Linked Frameworks and Libraries
section:
Carthage/Build
folder on disk:FacebookCore.framework
FBSDKCoreKit.framework
Bolts.framework
FacebookLogin.framework
FacebookCore.framework
(and it's dependencies)FacebookShare.framework
FacebookCore.framework
(and it's dependencies)On your application targets' Build Phases
tab:
+
icon and choose New Run Script Phase
./bin/sh
).Add the following to the script area below the shell:
/usr/local/bin/carthage copy-frameworks
Add the paths to the frameworks you want to use under Input Files
, for example:
$(SRCROOT)/Carthage/Build/iOS/FacebookCore.framework
$(SRCROOT)/Carthage/Build/iOS/FBSDKCoreKit.framework
$(SRCROOT)/Carthage/Build/iOS/Bolts.framework
Using Facebook SDK as a sub-project
While not recommended, it is entirely possible for you to build the Facebook SDK for Swift outside of any dependency management system.
Note that you will have to manage updating this solution (as well as the dependencies on the Facebook SDK for iOS) on your own.
git submodule update --init --recursive
FacebookSwift.xcodeproj
as a sub-project to your applications' project.FacebookCore.framework
, FacebookLogin.framework
, and FacebookShare.framework
build products from the sub-project to your applications Link Frameworks and Libraries
and Embedded Binaries
sections.Don't forget to also embed/link FBSDKCoreKit.framework
, FBSDKLoginKit.framework
, FBSDKShareKit.framework
and Bolts.framework
too!
The frameworks for the Facebook SDK in Swift are organized in the same way that the Facebook SDK for iOS is.
They also currently depend upon the Facebook SDK for iOS, although this may change at some point in the future.
Depends on FBSDKCoreKit.framework
and Bolts.framework
.
The following types are included, with enhancements for Swift:
AccessToken
ApplicationDelegate
AppEvents
A myriad of improvements, including type-safe built-in AppEvent
s, an AppEvent
struct, and more.
GraphRequest
You can now implement your own type-safe GraphRequest
s, including native-typed results.
SDKSettings
Logging behaviors are now implemented as a type-safe set, based on Swift enums.
Permission
Are no longer stringly-typed (string-based), but separate types for read and write permissions (also includes a built-in permission list, which includes most common permissions by default).
Depends on FacebookCore.framework
and FBSDKLoginKit.framework
.
The following types are included, with enhancements for Swift:
LoginManager
Now uses the type-safe permissions from FacebookCore
, and has constructors with LoginBehavior
and DefaultAudience
, instead of requiring manual setting of properties.
LoginButton
Can no longer change permissions after creation, helping to enforce using a single login button for a given set of permissions.
Note that LoginButton
is not intended to work with interface builder or storyboards at this time. We may re-address this in the future.
Depends on FacebookCore.framework
and FBSDKShareKit.framework
.
The following types are included, with enhancements for Swift:
LinkShareContent
Now a struct, and has a proper initializer enforcing required properties.
OpenGraphShareContent
Now a struct, uses type-safe OpenGraphPropertyName
and OpenGraphPropertyValue
, as well as structs for OpenGraphObject
and OpenGraphAction
.
PhotoShareContent
Now a struct, and better type-safety for properties on it.
VideoShareContent
Now a struct, and better type-safety for properties on it.
GraphSharer
Now a generic type, that can handle any type of content.
ShareDialog
Now a generic type, that can handle any type of content.
MessageDialog
Now a generic type, that can handle any type of content.
GameRequest
Now a struct, contains proper type-safe enum for Recipient
, Result
.
GameRequest.Dialog
AppGroupRequest.Dialog
AppInvite
Now a struct, use a type-safe Promotion
property, instead of separate promotionCode
and promotionText
.
AppInvite.Dialog
Facebook SDK in Swift is still in beta, and we would love to hear your thoughts and feedback on it.
All of Facebook SDK for Swift development happens on GitHub. Contributions make for good karma and we welcome new contributors with tremendous joy. We encourage you also to read our contributing guidelines before submitting a Pull Request.
See the LICENSE
file.