0

I'm trying to build my simple app to run on the iPad. What my app is doing is trying to read from the on board pastebin which is having some data sent to it via a second app.

However, upon building the app on xcode I have the following linker errors:

Undefined symbols for architecture armv7: "_importString", referenced from: RegisterMonoModules() in RegisterMonoModules.o "_exportString", referenced from: RegisterMonoModules() in RegisterMonoModules.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Now I know that it is looking at my import and export strings but nothing is ever started with a double underscore. Take a look at my dll file I wrote in XCode:

#define MakeStringCopy( _x_ ) ( _x_ != NULL && [_x_ isKindOfClass:[NSString class]] ) ? strdup( [_x_ UTF8String] ) : NULL
#define GetStringParam( _x_ ) ( _x_ != NULL ) ? [NSString stringWithUTF8String:_x_] : [NSString stringWithUTF8String:""]


//send clipboard to unity
extern "C" const char * importString()
{
    NSString *result = [UIPasteboard generalPasteboard].string;
    return MakeStringCopy(result);
}

//get clipboard from unity
extern "C" void exportString(const char * eString)
{
    [UIPasteboard generalPasteboard].string = GetStringParam(eString);//@"the text to copy";
}

And the sister class I have in my Unity application:

    [DllImport("__Internal")]
private static extern string _importString();

//retrieves the clipboard contents from xcode
public static string ImportString()
{
    //Debug.Log ("import: "+_importString());
    if( Application.platform == RuntimePlatform.IPhonePlayer )
    {
        return _importString();
    }

    else
    {
        return "";
    }
}



[DllImport("__Internal")]
private static extern void _exportString(string exportData);

//passes string to xcode and xcode copies to clipboard
public static void ExportString(string exportData)
{

   // Debug.Log ("export: "+exportData);
    if( Application.platform == RuntimePlatform.IPhonePlayer )
    {
        _exportString(exportData);
    }
}

I have stored the dll file in the following folder structor in Unity:

Assets -> Plugin -> iOS

But I'm at a loss as to how to fix my errors. Can anyone please help?

update

Based on a suggestion below I have ommited the underscore from both the import string and export string and I still have the same issues.

N0xus
  • 2,674
  • 12
  • 65
  • 126
  • Is the Obj-C file copied to Libraries folder when Unity is building the iOS player? What extension does it have, .m or .mm? – Kay Sep 24 '13 at 11:34
  • yes the file is copied over and it is a .mm – N0xus Sep 24 '13 at 11:35
  • Try to omit the leading underscore. This can lead to confusion with reserved names even when a lower case letter follows. see [What are the rules about using an underscore in a C++ identifier?](http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier) – Kay Sep 24 '13 at 11:54
  • Just tried that and I still get the same error. – N0xus Sep 24 '13 at 12:02

0 Answers0