Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI Facebook SDK : App ID not found. Add a string value with your app ID for the key FacebookAppID to the Info.plist

I have added the the correct Facebook sdk values into info.plist as the Quick Start guide shows & added the SDK using the package manager, but I still get this error

Thread 1: App ID not found. Add a string value with your app ID for the key FacebookAppID to the Info.plist or call [FBSDKSettings setAppID:].

The app Id is 100% correct & it is in my info.plist. If I set the name & app Id in my app delegate I just get this error instead:

Thread 1: fbappid is not registered as a URL scheme. Please add it in your Info.plist

It seems as though the Facebook SDK can't find any values in my info.plist?

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb823445029398455</string>
            </array>
        </dict>
    </array>
    <key>FacebookAppID</key>
    <string>823445029398455</string>
    <key>FacebookDisplayName</key>
    <string>vertoo-dev</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fbapi20130214</string>
        <string>fbapi20130410</string>
        <string>fbapi20130702</string>
        <string>fbapi20131010</string>
        <string>fbapi20131219</string>
        <string>fbapi20140410</string>
        <string>fbapi20140116</string>
        <string>fbapi20150313</string>
        <string>fbapi20150629</string>
        <string>fbapi20160328</string>
        <string>fbauth</string>
        <string>fb-messenger-share-api</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
    </array>

This is a screenshot of my error

like image 804
Andrew Jang Avatar asked May 30 '21 19:05

Andrew Jang


3 Answers

Add this in new file

class AppDelegate: NSObject, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        // Initialize Facebook SDK
        FBSDKCoreKit.ApplicationDelegate.shared.application(
            application,
            didFinishLaunchingWithOptions: launchOptions
        )
        return true
    }
}
like image 72
Ahmed Al-Imran Avatar answered Oct 08 '22 14:10

Ahmed Al-Imran


Tested in Xcode 12.5

make an AppDelegate.swift and add this code below.

import SwiftUI
import FacebookCore

class AppDelegate: NSObject, UIApplicationDelegate {
    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
    
    func application(_ app: UIApplication,
                     open url: URL,
                     options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        return ApplicationDelegate.shared.application(app, open: url, options: options)
    }
}

next in your @main App file add this line

 @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
like image 28
Pramodya Abeysinghe Avatar answered Oct 08 '22 16:10

Pramodya Abeysinghe


I had the same issue because I forgot to add fb as prefix of App Id in URL Schemes.

Make sure that you've added like this fb{app_id} into url schemes like image below.

enter image description here

Navigation to here: Project Navigator > Select Your Target > Info > URL Types

like image 4
miletliyusuf Avatar answered Oct 08 '22 16:10

miletliyusuf