我正在尝试让一个项目与 Parse 和 Facebook 合作。运行此项目时,构建失败,并且我收到Mach-O Linker Error:

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)

View Controller .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

任何帮助表示赞赏,谢谢。

最佳答案

就我所见,您似乎没有在项目中添加 Social.framework。尝试按照那里的说明链接它:

Linking to a Library or Framework

关于ios - 为什么我会收到 Apple Mach-O 链接器错误?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23142121/

10-09 12:52