在 iOS 上查找 Facebook SDK 版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15736831/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 22:58:22  来源:igfitidea点击:

Find Facebook SDK Version on iOS

iosfacebook

提问by tom19830924

I know I'm using the latest version (v3.2.1). But I want find it in header or programmatically.

我知道我使用的是最新版本 (v3.2.1)。但我想在标题中或以编程方式找到它。

In iOS I can't find version number in FacebookSDK.framework headers.

在 iOS 中,我在 FacebookSDK.framework 标头中找不到版本号。

回答by poloDelaVega

After about 2014, simply do this:

大约在 2014 年之后,只需执行以下操作:

NSLog( @"### running FB sdk version: %@", [FBSDKSettings sdkVersion] );


For very old versions. Before about 3.6:

对于非常旧的版本。大约 3.6 之前:

I found an undocumented way to print the SDK version (FB_IOS_SDK_VERSION_STRING), try this

我发现了一种打印 SDK 版本(FB_IOS_SDK_VERSION_STRING)的未公开方式,试试这个

NSLog(@"### FB SDK VERSION : %@",
    [[FBRequestConnection class] performSelector:@selector(userAgent)]);

Worked for me with sdk 3.5.1

使用 sdk 3.5.1 为我工作

Hope that helps...

希望有帮助...



Update: As of FB SDK 3.6, "The SDK version number is defined in FacebookSDK.h and available from [FBSDKSettings sdkVersion]"

更新:自 FB SDK 3.6 起, “SDK 版本号在 FacebookSDK.h 中定义并可从 [FBSDKSettings sdkVersion] 获得”

https://developers.facebook.com/ios/change-log-3.x/

https://developers.facebook.com/ios/change-log-3.x/

回答by Adeel

You can find the version of your Facebook SDK in FBSDKCoreKit.hdefined as

您可以在FBSDKCoreKit.h定义中找到 Facebook SDK 的版本

#define FBSDK_VERSION_STRING @"X.XX.X". Have a look at the image below.

#define FBSDK_VERSION_STRING @"X.XX.X". 看看下面的图片。

enter image description here

在此处输入图片说明

回答by Marcelo Fabri

Take a look at FBSDKVersion.h. There's a define there:

看看FBSDKVersion.h。那里有一个定义:

#define FB_IOS_SDK_VERSION_STRING @"3.2.1"

#define FB_IOS_SDK_VERSION_STRING @"3.2.1"

回答by John Erck

For those running SDK version >= 4, [FBSDKSettings sdkVersion].

对于那些运行 SDK 版本 >= 4 的,[FBSDKSettings sdkVersion].

#import <FBSDKCoreKit/FBSDKCoreKit.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    NSLog(@"### Running FB SDK Version: %@", [FBSDKSettings sdkVersion]);
}

回答by jules

From the SDK directory I did:

从我做的SDK目录:

% 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.

Facebook 可能是世界上唯一一家在 tar/zip 文件和解压后的根目录中省略版本号的科技公司。我觉得这令人困惑。

回答by bJacoG

In swift 2, FBSDK 4.4 you can output the version string:

在 swift 2, FBSDK 4.4 中,您可以输出版本字符串:

print("FBSDK Version: \(FBSDK_VERSION_STRING)");
//outputs:
//FBSDK Version: 4.4.0

FBSDKSettings.version() returned 0 for me.

FBSDKSettings.version() 为我返回 0。

回答by Himanshu Mahajan

To check the current version of facebook SDK use below line:

要检查 facebook SDK 的当前版本,请使用以下行:

    print("SDK version \(FBSDKSettings .sdkVersion())")

In my case, SDK version 4.8.0

就我而言,SDK 版本 4.8.0

Tested against swift 2.0 and xCode 7.0+

针对 swift 2.0 和 xCode 7.0+ 进行测试

回答by Shaheen Ghiassy

For Facebook SDK 3.18, I had to do

对于 Facebook SDK 3.18,我必须这样做

#import <FacebookSDK/FacebookSDK.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    NSLog( @"My app is running FB sdk version: %@", [FBSettings sdkVersion]);
}

回答by pewpew

Try(Android) - I only posted this because I was looking for this answer and didn't see for android.

Try(Android) - 我发布这个只是因为我正在寻找这个答案并且没有看到 android。

String s = FacebookSdk.getSdkVersion();
                Log.d("FacebookSKD_V",s);

回答by Gabi Dj

If you are using pods you can check in the Info.plist file:

如果您使用的是 Pod,您可以查看 Info.plist 文件:

"Pods/FBSDKCoreKit/Support Files/Info.plist"

"Pods/FBSDKCoreKit/Support Files/Info.plist"

The version is the key CFBundleShortVersionString

版本是关键 CFBundleShortVersionString

My version was 4.18.0

我的版本是 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>