• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Understanding Xcode build errors from using Objective-C runtime function in OS X's Foundation app template.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Understanding Xcode build errors from using Objective-C runtime function in OS X's Foundation app template.


  • Subject: Re: Understanding Xcode build errors from using Objective-C runtime function in OS X's Foundation app template.
  • From: Chris in Public <email@hidden>
  • Date: Thu, 30 May 2013 12:32:07 +0800

I'm learning how to use the Objective-C runtime function. To do this, I used Xcode Version 4.6.2 (4H1003) and chose from the OS X's Foundation template to create a new project with sample code I found in Apple's documentation.

There are only three files in the project.

main.m 

#import <Foundation/Foundation.h>
#include "ObjectiveCRuntime.h"

int main(int argc, const char * argv[])
{
    @autoreleasepool {
        listObjectiveC_ClassesUsedInThisApp();
    }
    return 0;
}


ObjectiveCRuntime.h

#ifndef ObjCWithoutCocoa_ObjectiveCRuntime_h
#define ObjCWithoutCocoa_ObjectiveCRuntime_h

void listObjectiveC_ClassesUsedInThisApp(void); /* list Objective-C classes used by this executable */

#endif


and ObjectiveCRuntime.c

#import <Foundation/Foundation.h>
#import <Foundation/NSObjCRuntime.h>
#import "ObjectiveCRuntime.h"

extern int objc_getClassList(Class *buffer, int bufferLen);

/* list Objective-C classes used by this executable */
void listObjectiveC_ClassesUsedInThisApp(void)
{
    int numClasses;
    Class * classes = NULL;

    

    classes = NULL;
    numClasses = objc_getClassList(NULL, 0);

    

    if (numClasses > 0 )
    {
        classes = malloc(sizeof(Class) * numClasses);
        numClasses = objc_getClassList(classes, numClasses);
        printf("This application has %u classes. Note that you cannot assume these classes inherit from NSObject.\n", numClasses);
        free(classes);
    }
}


When I build, Xcode emits build fail errors 
<XcodeScreenSnapz001.jpeg>

Since Apple provided headers shouldn't be the source of errors, I'm not sure where to start looking for the error. The ObjectiveCRuntime.c and main.m are listed in the Target's Build Phases under Compile Sources.


Thanks for any hints.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: SenTestCase link error but framework clearly linked
  • Next by Date: Re: Understanding Xcode build errors from using Objective-C runtime function in OS X's Foundation app template.
  • Previous by thread: Re: SenTestCase link error but framework clearly linked
  • Next by thread: Re: Understanding Xcode build errors from using Objective-C runtime function in OS X's Foundation app template.
  • Index(es):
    • Date
    • Thread