I've been trying to implement Facebook Login functionality for react native app. Sad how a language developed by Facebook is not properly supporting its own functionalities. Here is the process I've followed:
I installed https://www.npmjs.com/package/react-native-fbsdk-next package as npm i react-native-fbsdk-next which installed "^4.0.0" of this.
I did pod install and it shows a success message as shown in the image below:
Then I opened the iOS project in XCode and added this in my info.plist file:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fbMY_APP_ID</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>MY_APP_ID</string>
<key>FacebookDisplayName</key>
<string>MY_APP_NAME</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
After that I opened AppDelegate.m and did the following:
...
#import <FBSDKCoreKit/FBSDKCoreKit.h>
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
return YES;
}
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options]) {
return YES;
}
return NO;
}
...
Then when I run the app react-native run-ios there is this really long error that appears and I cannot even copy the full one but here are the last few lines of that error:
Full Log of this error is posted https://github.com/thebergamo/react-native-fbsdk-next/issues/11
** BUILD FAILED **
The following build commands failed:
Ld /Users/chaudhrytalha/Library/Developer/Xcode/DerivedData/fbexampleapp-cbjnhmdbrulusmcwnknqvzbhuegw/Build/Products/Debug-iphonesimulator/fbexampleapp.app/fbexampleapp
normal
The failer message is ever larger than that.
So far what I've tried is I've started a new project from scratch made sure it's running and the moment I install react-native-fbsdk-next and then update pod and run the app again it starts to show this long error.
Open your project in xcode and create an empty .swift file in your project
click next and your project will build
Related
im facing an issue in one of my flutter apps. Im was using MapBox-SDK plugin but when I tested the app on IOS, it asked me to update my Mapbox-sdk to some version (which I did using pop install command). Now after everything, I am facing new errors in my info.plist file. I forgot to take a backup of my old info.plist file.
Anyways, the new info.plist is:
<plist version="1.0">
<dict>
<string>YES</string>
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>MGLMapboxAccessToken</key>
<string>Mapbox-key-not-visible</string>
<true/>
<key>NSLocationWhenInUseUsageDescription</key>
<key>NSLocationAlwaysUsageDescription</key>
<key>NSPhotoLibraryUsageDescription</key>
<key>NSCameraUsageDescription</key>
<key>NSMicrophoneUsageDescription</key>
<string>This app needs access to location when open.</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>project1</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist
the error im facing while building up the app is:
ERROR:
Users/apple/flutter-practice/Project-Casky/casky/ios/Runner/Info.plist: Property List error: Found non-key inside <dict> at line 10 / JSON error: JSON text did not start with array or object and option to allow fragments not set.
Xcode build done. 24.2s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
error: unable to read property list from file: /Users/apple/flutter-practice/Project- Casky/casky/ios/Runner/Info.plist: The operation couldn’t be completed. (XCBUtil.PropertyListConversionError error 1.) (in target 'Runner' from project 'Runner')
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
warning: Mapping architecture armv7 to i386. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'image_picker' from project 'Pods')
warning: Mapping architecture arm64 to x86_64. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'image_picker' from project 'Pods')
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the Runner editor. (in target 'Runner' from project 'Runner')
Could not build the application for the simulator.
Error launching application on iPhone 11 Pro Max.
Exited (sigterm)
GUYS I can't find a solution to this. Kindly help me in anyway possible. Thanks in advance.
The error error: unable to read property list from file: Info.plist is usually caused by missing config on the plist file. As previously mentioned in the comments, you need to have a value set on NSLocationWhenInUseUsageDescription. More details are explained in the package's docs.
<key>NSLocationWhenInUseUsageDescription</key>
<string>[Your explanation here]</string>
In my case, it was because the Info.plist file was poorly formatted. It hasn't to do with XML format, because when I tried to find if that file was correctly formatted according to XML rules, it was ok, but when I tried to open the .plist file as a property list, I realized Xcode couldn't read it, so I added my keys using the property list utility, not the "code view".
I have been facing the same problem with a newly imported Flutter project. After some debugging, it seems like the issue was caused by a corrupt GoogleService-Info.plist file! Dunno why and how it was corrupted, because I have newly imported and existing project.
To solve this problem, you can follow those steps;
Open your project in XCode
delete the existing GoogleService-Info.plist file
download the original one from Firebase
then reimport/re-copy this file into your project
When this is done, run flutter clean then try running it in iOS Simulator
This worked for me, hope it solves your problem too.
I solved this issue by including <string/> after each <key>...</key> like this :
<key>NSPhotoLibraryUsageDescription</key>
<string />
<key>NSCameraUsageDescription</key>
<string />
<key>NSMicrophoneUsageDescription</key>
<string />
I'm following those steps to be able to use the package in ios and no luck. It works fine in android:
https://github.com/GoldenOwlAsia/react-native-twitter-signin#prerequisites
Then I'm adding the twitter 3 sdk with cocoa pods:
https://github.com/twitter/twitter-kit-ios/wiki/Installation
The full error is
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_Twitter", referenced from:
objc-class-ref in libRNTwitterSignIn.a(RNTwitterSignIn.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I linked that library. I installed the cocoapod Twitter 3 sdk but I'm still getting the build error.
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'app' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for app
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'TwitterKit'
target 'appTests' do
inherit! :search_paths
# Pods for testing
end
end
My AppDelegate.m is:
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
// **********************************************
// *** DON'T MISS: THE NEXT LINE IS IMPORTANT ***
// **********************************************
// IMPORTANT: if you're getting an Xcode error that RCCManager.h isn't found, you've probably ran "npm install"
// with npm ver 2. You'll need to "npm install" with npm 3 (see https://github.com/wix/react-native-navigation/issues/1)
#import <Firebase.h>
#import "RCCManager.h"
#import <TwitterKit/TWTRKit.h>
#import <React/RCTRootView.h>
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
[[Twitter sharedInstance] startWithConsumerKey:#"dasdasdasasd" consumerSecret:#"dsadasdadasdasd"];
NSURL *jsCodeLocation;
#ifdef DEBUG
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:#"index" fallbackResource:nil];
#else
jsCodeLocation = [[NSBundle mainBundle] URLForResource:#"main" withExtension:#"jsbundle"];
#endif
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
[[RCCManager sharedInstance] initBridgeWithBundleURL:jsCodeLocation launchOptions:launchOptions];
return YES;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<NSString *,id> *)options {
BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
];
BOOL handledT = [[Twitter sharedInstance] application:application openURL:url options:options];
// Add any custom logic here.
return handled || handledT;
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
#end
My build phases:
My build settings for architectures:
My info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>twitterkit-XXXXXX</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>twitter</string>
<string>twitterauth</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fbXXXX</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
<key>NSCameraUsageDescription</key>
<string>Camera Permissions</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Gallery Permissions</string>
<key>UIAppFonts</key>
<array>
<string>Ionicons.ttf</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>App</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
<key>FacebookAppID</key>
<string>XXXXXXXX</string>
<key>FacebookDisplayName</key>
<string>MyApp</string>
</dict>
</plist>
Already tried to clean the project, update the TwitterKit cocoapod,clean build folder with going to options and holding the alt button but nothing works.
Any help on what could be the problem??
I fixed it....The solution in my case to the second problem that I mention on the comments to Pritish Vaidya of twitter complaining about me trying to login wihtout a URL scheme was that I had to unify duplicated keys on the info.plist since facebook and twitter they both have url schemes and you can't duplicate the entries, you have to put it all in the same array under one key and I also unified LSApplicationQueriesSchemes into one. As you can see in the plist above is duplicated for both entries. So the two entries now in unified format would be:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>twitterkit-key</string>
<string>fbkey</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>twitter</string>
<string>twitterauth</string>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
I'm trying to get the file icon for my electron app to work properly on mac.
My package.json has:
"fileAssociations": {
"ext": [ "x" ],
"name": "X",
"description": "An x file",
"icon": "xFile.icns",
"role": "Editor",
"isPackage": false
},
And I also have in package.json:
"extend-info": "Info.plist"
which contains:
...<plist version="1.0">
<dict>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>sql</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>xFile.icns</string>
<key>CFBundleTypeName</key>
<string>X File</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>X</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>NSDocumentClass</key>
<string>SPDocumentController</string>
</dict>
</array>
<key>CFBundleURLTypes</key>
<array>
</array>
</dict>
</plist>
After I package it and move it to my Applications folder, I check the contents of the app and Info.plist wasn't extended with the info above.
Double-clicking to launch an .x file works though, just no icon replacement.
Can anyone confirm if my paths for the .icns file and .plist file is correct? Is it relative to the build folder or something else?
My file structure is according to the guidelines:
app folder:
> package.json, main.js, etc.
> build
> icons & Info.plist
I ran into this issue myself. First of all, your first snippet in package.json is related to Electron Builder not Electron Packager.
So if you plan to use electron-packager make sure that your npm run build script uses it and not builder.
Here is how I fixed the icon issue with Electron Packager:
In you config for electron-packager you'll point to the plist file, as well as add an entry to copy the icon file into the resources folder of the app.
In your electron-packager config you need these two entries:
extraResource: "app/icons/document-icon.icns",
extendInfo: "build-files/Info.plist"
Then in your plist you can just use the icon name:
<key>CFBundleTypeIconFile</key>
<string>document-icon.icns</string>
Finally, you might need to relaunch the Finder for it to take effect if you've already associated the file before.
Hope this helps!
I try to upload my IPA by Application Loader, but I've got this error since i changed the version number CFBundleVersion
ERROR ITMS-90503: "Invalid Bundle. Apps that have 'arm64' in the list of UIRequiredDeviceCapabilities in Info.plist must only contain the arm64 slice."
But in my plist is all correct, also this key:
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
Thanks in advance.
The solution is to check the valid architectures in the build settings. Be sure to have selected "All" in the right top-right corner and verify that there is only arm64 in the valid architectures.
By default, the createIpa task builds for armv7 and arm64. If you want to build only the latter modify your build.gradle file:
jfxmobile {
...
ios {
arch = "arm64"
ipaArchs = ["arm64"]
...
}
}
In case it is needed you can also specify the architecture and the minimum iOS version in your pList file:
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>MinimumOSVersion</key>
<string>9.0</string>
I know I'm using the latest version (v3.2.1). But I want find it in header or programmatically.
In iOS I can't find version number in FacebookSDK.framework headers.
After about 2014, simply do this:
NSLog( #"### running FB sdk version: %#", [FBSDKSettings sdkVersion] );
For very old versions. Before about 3.6:
I found an undocumented way to print the SDK version (FB_IOS_SDK_VERSION_STRING), try this
NSLog(#"### FB SDK VERSION : %#",
[[FBRequestConnection class] performSelector:#selector(userAgent)]);
Worked for me with sdk 3.5.1
Update: As of FB SDK 3.6, "The SDK version number is defined in FacebookSDK.h and available from [FBSDKSettings sdkVersion]"
https://developers.facebook.com/ios/change-log-3.x/
You can find the version of your Facebook SDK in FBSDKCoreKit.h defined as
#define FBSDK_VERSION_STRING #"X.XX.X". Have a look at the image below.
Take a look at FBSDKVersion.h. There's a define there:
#define FB_IOS_SDK_VERSION_STRING #"3.2.1"
For those running SDK version >= 4, [FBSDKSettings sdkVersion].
#import <FBSDKCoreKit/FBSDKCoreKit.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog(#"### Running FB SDK Version: %#", [FBSDKSettings sdkVersion]);
}
From the SDK directory I did:
% find . -name \*.h -exec fgrep -i version {} /dev/null \;
Amongst other stuff, the following line was returned:
./FBSDKCoreKit.framework/Headers/FBSDKCoreKit.h:#define FBSDK_VERSION_STRING #"4.11.0"
This will help you identify the version without needing to actually link/run/log.
Facebook might possibly be the only technology company in the world that omits the version number from their tar/zip file, as well as the unpacked root directory. I find this baffling.
In swift 2, FBSDK 4.4 you can output the version string:
print("FBSDK Version: \(FBSDK_VERSION_STRING)");
//outputs:
//FBSDK Version: 4.4.0
FBSDKSettings.version() returned 0 for me.
To check the current version of facebook SDK use below line:
print("SDK version \(FBSDKSettings .sdkVersion())")
In my case, SDK version 4.8.0
Tested against swift 2.0 and xCode 7.0+
There is no way to get it on SPM after 11.0 from Xcode 12.
For Facebook SDK 3.18, I had to do
#import <FacebookSDK/FacebookSDK.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog( #"My app is running FB sdk version: %#", [FBSettings sdkVersion]);
}
Try(Android) - I only posted this because I was looking for this answer and didn't see for android.
String s = FacebookSdk.getSdkVersion();
Log.d("FacebookSKD_V",s);
If you are using pods you can check in the Info.plist file:
"Pods/FBSDKCoreKit/Support Files/Info.plist"
The version is the key CFBundleShortVersionString
My version was 4.18.0
Example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>4.18.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
import FBSDKCoreKit
print(Settings.shared.sdkVersion)