iPhone上的Facebook登录导致“lang:错误:链接器命令失败”
Posted
技术标签:
【中文标题】iPhone上的Facebook登录导致“lang:错误:链接器命令失败”【英文标题】:Facebook Login on iPhone causes "lang: error: linker command failed" 【发布时间】:2015-03-03 18:55:33 【问题描述】:以下是我的 UIViewController 用于请求 Facebook 登录和 publish_actions 权限。当我运行我的项目时,我得到了一个lang: error: linker command failed with exit code 1 (use -v to see invocation)
,我也在下面提供了它。感谢您的帮助
UIViewController
#import "FacebookViewController.h"
#import <MobileCoreServices/MobileCoreServices.h>
@interface FacebookViewController ()<FBLoginViewDelegate>
@end
@implementation FacebookViewController
- (void)viewDidLoad
[super viewDidLoad];
FBLoginView *loginview = [[FBLoginView alloc] init];
loginview.frame = CGRectOffset(loginview.frame, 5, 5);
#ifdef __IPHONE_7_0
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0
if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)])
loginview.frame = CGRectOffset(loginview.frame, 5, 5);
#endif
#endif
#endif
loginview.delegate = self;
[self.view addSubview:loginview];
[loginview sizeToFit];
- (void)didReceiveMemoryWarning
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
#pragma mark - FBLoginViewDelegate
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView
// ask for more permission
if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound)
// if we don't already have the permission, then we request it now
[FBSession.activeSession requestNewPublishPermissions:@[@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error)
if (!error)
//No error therefore dismiss this VC
[self dismissThisViewController];
else if (error.fberrorCategory != FBErrorCategoryUserCancelled)
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Permission denied"
message:@"Unable to get permission to post"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
];
- (void)loginView:(FBLoginView *)loginView handleError:(NSError *)error
// see https://developers.facebook.com/docs/reference/api/errors/ for general guidance on error handling for Facebook API
// our policy here is to let the login view handle errors, but to log the results
NSLog(@"FBLoginView encountered an error=%@", error);
-(void)dismissThisViewController
//TODO
@end
错误
Ld /Users/myname/Library/Developer/Xcode/DerivedData/Appname-
dbqrudioiirqmvckhvljpnmkbhlu/Build/Intermediates/Appname.build/Debug-
iphonesimulator/Appname.build/Objects-normal/x86_64/Appname normal x86_64
cd /my_git_dir/project_name/Appname_ios
export IPHONEOS_DEPLOYMENT_TARGET=7.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -
L/Users/myname/Library/Developer/Xcode/DerivedData/Appname-dbqrudioiirqmvckhvljpnmkbhlu/Build/Products/Debug-iphonesimulator -
F/Users/myname/Library/Developer/Xcode/DerivedData/Appname-dbqrudioiirqmvckhvljpnmkbhlu/Build/Products/Debug-iphonesimulator -F/my_git_dir/project_name/Appname_iOS/Appname_iOS -
F/Users/myname/Documents/FacebookSDK -filelist /Users/myname/Library/Developer/Xcode/DerivedData/Appname-
dbqrudioiirqmvckhvljpnmkbhlu/Build/Intermediates/Appname.build/Debug-iphonesimulator/Appname.build/Objects-normal/x86_64/Appname.LinkFileList -
Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -objc_abi_version -Xlinker 2 -ObjC -fobjc-arc -fobjc-link-runtime -Xlinker -
no_implicit_dylibs -mios-simulator-version-min=7.1 -framework AVFoundation -framework StoreKit -framework QuartzCore -framework
AudioToolbox -lsqlite3 -framework FacebookSDK -lz -framework CoreLocation -framework SystemConfiguration -framework Security -framework
MobileCoreServices -framework CFNetwork -framework Bolts -framework CoreTelephony -framework Parse -framework CoreGraphics -framework UIKit -
framework Foundation -Xlinker -dependency_info -Xlinker /Users/myname/Library/Developer/Xcode/DerivedData/Appname-
dbqrudioiirqmvckhvljpnmkbhlu/Build/Intermediates/Appname.build/Debug-iphonesimulator/Appname.build/Objects-
normal/x86_64/Appname_dependency_info.dat -o /Users/myname/Library/Developer/Xcode/DerivedData/Appname-
dbqrudioiirqmvckhvljpnmkbhlu/Build/Intermediates/Appname.build/Debug-iphonesimulator/Appname.build/Objects-normal/x86_64/Appname
…
duplicate symbol _OBJC_METACLASS_$_BFMeasurementEvent in:
/Users/myname/Documents/FacebookSDK/FacebookSDK.framework/FacebookSDK(BFMeasurementEvent.o)
/my_git_dir/project_name/Appname_iOS/Appname_iOS/Bolts.framework/Bolts(BFMeasurementEvent.o)
ld: 91 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: 91 duplicate symbols for architecture arm64
【问题讨论】:
【参考方案1】:您在 Bolts 和 Facebook 框架中有重复的方法名称 BFMeasurementElement。先解决这个。螺栓框架
【讨论】:
我不知道螺栓是用来做什么的。我把它拿出来,它现在可以工作了。在我找到需要螺栓的原因之前,这是正确的答案。谢谢!以上是关于iPhone上的Facebook登录导致“lang:错误:链接器命令失败”的主要内容,如果未能解决你的问题,请参考以下文章
iPhone应用程序,如何避免要求用户重新登录Facebook
Facebook Login 正在 Facebook Native 应用程序中打开,而不是在 ios 6.0 的 iphone 设备上的 Safari 浏览器中打开