Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Using Parse Push with Swift app and get 25 'Apple Mach-O Linker Error'

I'm trying to link my app to parse to use for push notifications but I get 25 errors ('Apple Mach-O Linker Error') I created an Objective C header file i which i typed #import Parse/Parse.h

I only want to use Parse for Push Notifications and Analytics

My

AppDelegate.Swift
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) ->                Bool {




             return true  

        Parse.setApplicationId("xyxyxyxyxyxyxyx",clientKey: "xyxyxyxyxyxyxyxyx")




        // Register for Push Notitications
        let notificationTypes:UIUserNotificationType = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
        let notificationSettings:UIUserNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)

        UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)

        }

    func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
        UIApplication.sharedApplication().registerForRemoteNotifications()

    }

    func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {

        let currentInstallation:PFInstallation = PFInstallation.currentInstallation()
        currentInstallation.setDeviceTokenFromData(deviceToken)
        currentInstallation.save()


    }

    func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {

    }

    func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {

        println(error.localizedDescription)

    }

2 Answers

My bet is that you're not #importing Parse's framework properly. In Objective-C, you'd #import Parse's framework like this:

//Notice the < & > around "Parse/Parse.h"
#import <Parse/Parse.h>

I'm not sure if Parse's framework supports it, but if it does, the better way to #import it would be like this:

@import Parse;

That will intelligently determine what classes you're using, and only import them. Lastly, if you have a file of your own that you'd want to import with Objective-C, it'd look like this:

//Notice the quotes, and not the other characters
#import "YourFile.h"

I now have

@import Parse; @import Bolts

in my bridging header file.

Since i imported the Bolts framework i get 2 errors in total

"Module Bolts not found" - The Bolts framework is in my project though "Swift Compiler Error (Failed to import bridging header file" - This error isn't present when i have no code in the Bridging header file

Try #importing the Parse framework with my first method, then, like this:

#import <Parse/Parse.h>

Parse's framework probably doesn't support GCC module importing, so you can't use the @import syntax with it, apparently

I used

@import Parse;

and i still get the same errors

I've cleaned my build folder and tried using Xcode 6.1 (currently using Xcode 6.2 Beta 3)