为什么我会收到Apple Mach-O链接器错误?

4
我正在尝试使用Parse和Facebook使一个项目工作。但是在运行该项目时,构建失败并出现了“Mach-O链接器错误”的提示。
Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_SLComposeViewController", referenced from:
  objc-class-ref in Parse(PF_Twitter.o)
  "_OBJC_CLASS_$_SLRequest", referenced from:
  objc-class-ref in Parse(PF_Twitter.o)
  "_SLServiceTypeTwitter", referenced from:
       -[PF_Twitter getAccessTokenForReverseAuthAsync:localTwitterAccount:] in  Parse(PF_Twitter.o)
      -[PF_Twitter getLocalTwitterAccountAsync] in Parse(PF_Twitter.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

ViewController.h:

#import <UIKit/UIKit.h>
#import <Parse/Parse.h>

@interface ViewController : UIViewController

@end

// Implement both delegates
@interface DefaultSettingsViewController :
UIViewController <PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate>

@end

而 ViewController.m 文件:

#import "ViewController.h"


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{



[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

// Sent to the delegate to determine whether the log in request should be submitted to the     server.
- (BOOL)logInViewController:(PFLogInViewController *)logInController   shouldBeginLogInWithUsername:(NSString *)username password:(NSString *)password {
// Check if both fields are completed
if (username && password && username.length != 0 && password.length != 0) {
    return YES; // Begin login process
}

[[[UIAlertView alloc] initWithTitle:@"Missing Information"
                            message:@"Make sure you fill out all of the information!"
                           delegate:nil
                  cancelButtonTitle:@"ok"
                  otherButtonTitles:nil] show];
return NO; // Interrupt login process
}

// Sent to the delegate when a PFUser is logged in.
- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser   *)user {
[self dismissViewControllerAnimated:YES completion:NULL];
}

 // Sent to the delegate when the log in attempt fails.
- (void)logInViewController:(PFLogInViewController *)logInController didFailToLogInWithError:(NSError *)error {
    NSLog(@"Failed to log in...");
 }

// Sent to the delegate when the log in screen is dismissed.
- (void)logInViewControllerDidCancelLogIn:(PFLogInViewController *)logInController {
[self.navigationController popViewControllerAnimated:YES];
}


// Sent to the delegate to determine whether the sign up request should be submitted to  the server.
- (BOOL)signUpViewController:(PFSignUpViewController *)signUpController shouldBeginSignUp:(NSDictionary *)info {
BOOL informationComplete = YES;

// loop through all of the submitted data
for (id key in info) {
    NSString *field = [info objectForKey:key];
    if (!field || field.length == 0) { // check completion
        informationComplete = NO;
        break;
    }
}

// Display an alert if a field wasn't completed
if (!informationComplete) {
    [[[UIAlertView alloc] initWithTitle:@"Missing Information"
                                message:@"Make sure you fill out all of the information!"
                               delegate:nil
                      cancelButtonTitle:@"ok"
                      otherButtonTitles:nil] show];
}

return informationComplete;
}


// Sent to the delegate when a PFUser is signed up.
 - (void)signUpViewController:(PFSignUpViewController *)signUpController didSignUpUser:(PFUser *)user {
[self dismissModalViewControllerAnimated:YES]; // Dismiss the PFSignUpViewController
}

// Sent to the delegate when the sign up attempt fails.
- (void)signUpViewController:(PFSignUpViewController *)signUpController     didFailToSignUpWithError:(NSError *)error {
NSLog(@"Failed to sign up...");
}

// Sent to the delegate when the sign up screen is dismissed.
- (void)signUpViewControllerDidCancelSignUp:(PFSignUpViewController *)signUpController {
NSLog(@"User dismissed the signUpViewController");
}


- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];

if (![PFUser currentUser]) {
    // Customize the Log In View Controller
    PFLogInViewController *logInViewController = [[PFLogInViewController alloc] init];
    [logInViewController setDelegate:self];
    [logInViewController setFacebookPermissions:[NSArray arrayWithObjects:@"friends_about_me", nil]];
    [logInViewController setFields: PFLogInFieldsFacebook | PFLogInFieldsDismissButton];

    // Present Log In View Controller
    [self presentViewController:logInViewController animated:YES completion:NULL];
}
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
     // Dispose of any resources that can be recreated.
}

 @end

非常感谢任何帮助。

2个回答

25
从我看到的情况来看,似乎您没有在项目中添加Social.framework。请按照以下说明链接它:链接库或框架

5
在一个项目中,我没有遇到这个问题,在另一个项目中,我不得不同时添加Account.framework和Social.framework。尽管第二个项目使用了一些其他库(其中一个是来自CocoaPods的)。 - Barrett Clark

0

只需添加:

<framework>Social</framework>

<frameworks>标签下添加robovm.xml。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接