Facebook Login串接

Vince Lee
Vince Lee
Jul 27, 2017 · 3 min read

這次花了很多時間,對於還不是會寫程式的我,這根本跟魔法一樣啊。現在大部分的App會避免你額外申請帳號,會請你直接用Facebook帳號登入就好,所以是一個App必備的功能了,今天就來好好研究怎麼在你的App上實裝這個功能。請參考Facebook的網站,他會引導你使用,但是初學如我,途中遇到很多問題,像是:

  1. 開頭會跟你說如果要用Swift使用要去另一個頁面,但是跟著原本的Object-C步驟是可以做出來的,所以我建議不要使用Swift新增登入功能。

2. 下載 Facebook iOS SDK,把Bolts.framework、FBSDKCoreKit.framework、FBSDKLoginKit.framework 和 FBSDKShareKit.framework拖到Xcode的專案裡,將你Mac下載的SDK檔案夾加入 Build Settings的 Framework Search Paths(架構搜尋路徑)設定。這邊我卡了很久,因為找不到 Framework Search Paths,Google了一下才知道請善用搜尋功能,你的肉眼是打不贏電腦的

3. 後面我就跟著Youtube大神的操作完成串接,比較特別的是中間需要新增一個Object-C檔,寫入兩排code,一開始看想說Swift code有長這樣的嗎,看了解說才知道這是Object-C的語言。

#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>

Github:

彼得潘的 Swift iOS App 開發教室

學習 Swift iOS App 開發的學生作品集

Vince Lee

Written by

Vince Lee

彼得潘的 Swift iOS App 開發教室

學習 Swift iOS App 開發的學生作品集

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade