6

I'm currently trying to implement Facebook SDK into my Unity App but I can't find the AppDelegate.m that I must modify in order to implement the SDK.

I tried searching everywhere in my Xcode folder but it seems nowhere to be found.

I search on google too but as I really don't understand anything to Xcode (except from building my Unity Project), I don't understand the answers too...

Thanks, and have a nice day !

Nirav Kotecha
  • 2,493
  • 1
  • 12
  • 26
SamuelRousseaux
  • 107
  • 1
  • 1
  • 8

3 Answers3

5

The file name “AppDelegate.m” is a generic reference to “the file that contains the definition of your application delegate class”. Your app is not required to name the file “AppDelegate.m” however, so you’ll need to find yours.

Somewhere in your app there is a class that implements the UIApplicationDelegate protocol. You should search for “UIApplicationDelegate” using Xcode’s search function. That should put you on the right track to finding the class. Whichever file that class is in is the file you need to refer to when other documentation says AppDelegate.m

Update:

I forgot that in objective-c you don't declare adoption of a protocol. Here is a different way to find your app delegate.

Find your main.m file (this file is required, so you'll definitely have one). It will contain code like this:

int main(int argc, char * argv[]) {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([YourAppDelegateClassName class]));
    }
}

The interesting piece is [YourAppDelegateClassName class], since this represents the class of your application delegate. Do a search for the first word in the square brackets, in this case it is YourAppDelegateClassName.

Community
  • 1
  • 1
allenh
  • 6,582
  • 2
  • 24
  • 40
  • Found a file named Unity_iPhone_Tests.m with "UIApplicationDelegate" inside, is this my "AppDelegate.m" ? – SamuelRousseaux Oct 17 '17 at 11:34
  • Thanks ! I'll try this as soon as I'll have access to the mac at work – SamuelRousseaux Oct 18 '17 at 09:30
  • In this file, I have "UIApplicationMain(argc, argv, nil, NSString stringWithUTF8String: AppControllerClassName]); – SamuelRousseaux Oct 18 '17 at 12:29
  • @LeVentilo Yeah, `main.mm` is correct. The `mm` extension means [something specific](https://stackoverflow.com/a/3684159/5099014). So it looks like your app has its app delegate's class name stored in a string. You need to find where `AppControllerClassName` is defined. When you find it, that string should be the name of the class you're looking for. [These docs](https://docs.unity3d.com/Manual/StructureOfXcodeProject.html) might help you as well. – allenh Oct 18 '17 at 14:25
  • Thanks ! Seems like the SDK is integrated as I successfuly compiled and ran the code :) Now waiting to see if it worked ! Thanks for your explanations, they were clear even for a xcode noobie like me – SamuelRousseaux Oct 20 '17 at 14:10
  • @LeVentilo Glad to hear you're making progress. Once you let me know that it worked for you, I'll update my answer to more clearly address the question in the context of Unity, and please accept the answer to let others who might come across the question know the answer worked for you (and I wouldn't say no to an upvote, too ;-) – allenh Oct 20 '17 at 21:02
  • Hi ! I'm here for an update, it worked ! Thanks a lot for your help :) – SamuelRousseaux Oct 30 '17 at 09:06
1

You can find it by searching UIApplicationDelegate in xcode search, then you will find the implemenation of this protocol in some file named as something.h.that's the file which you needed.

Aravinth
  • 27
  • 3
1

In Xcode 13.3.1 the file would be the (AppName)App file. This file defines the entry point for the app. This file is where you would define the app delegate class.

thejdah
  • 335
  • 2
  • 3
  • 17