使用FBTestSession *fbSession = [FBTestSession sessionWithSharedUserWithPermissions:@[@"email"]];时,使用FBTestSession出现异常

如果查看下面的代码,您会看到Facebook决定从NSProcessInfo加载应用程序设置:
https://github.com/facebook/facebook-ios-sdk/blob/master/src/FBTestSession.m#L506

NSDictionary *environment = [[NSProcessInfo processInfo] environment];
    NSString *appID = [environment objectForKey:FBPLISTAppIDKey];
    NSString *appSecret = [environment objectForKey:FBPLISTAppSecretKey];
    if (!appID || !appSecret || appID.length == 0 || appSecret.length == 0) {
        [[NSException exceptionWithName:FBInvalidOperationException
                                 reason:
          @"FBTestSession: Missing App ID or Secret; ensure that you have an .xcconfig file at:\n"
          @"\t${REPO_ROOT}/src/tests/TestAppIdAndSecret.xcconfig\n"
          @"containing your unit-testing Facebook Application's ID and Secret in this format:\n"
          @"\tIOS_SDK_TEST_APP_ID = // your app ID, e.g.: 1234567890\n"
          @"\tIOS_SDK_TEST_APP_SECRET = // your app secret, e.g.: 1234567890abcdef\n"
          @"To create a Facebook AppID, visit https://developers.facebook.com/apps"
                               userInfo:nil]
         raise];
    }

问题是,我无法弄清楚如何正确设置FBPLISTAppIDKey和FBPLISTAppSecretKey,并且没有其他设置器可以使用。

最佳答案

您需要将它们添加为方案中的环境变量。

{scheme} >> Run >> Arguments (Tab) >> add the test app id and test app secret.

关于ios - 如何使用FBTestSession设置FBPLISTAppIDKey和FBPLISTAppSecretKey,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15570013/

10-15 02:03