Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors in main.mm file : Use of undeclared identifier #12

Closed
royken opened this issue Oct 31, 2017 · 31 comments
Closed

Errors in main.mm file : Use of undeclared identifier #12

royken opened this issue Oct 31, 2017 · 31 comments

Comments

@royken
Copy link

royken commented Oct 31, 2017

Hello,
thank you for this tutorial. Followed all the steps, but in the main.mm file i have the following
errors: (screen the image bellow)

  • use of undeclared identifier 'UnityParseCommandLine'
  • use of undeclared identifier 'nil'
  • use of undefined identifier 'NSLog'
    20171031_183039
    Sorry for the image quality

This is the file content:
`#include "RegisterMonoModules.h"
#include "RegisterFeatures.h"
#include

// Hack to work around iOS SDK 4.3 linker problem
// we need at least one __TEXT, __const section entry in main application .o files
// to get this section emitted at right time and so avoid LC_ENCRYPTION_INFO size miscalculation
static const int constsection = 0;

void UnityInitTrampoline();

// WARNING: this MUST be c decl (NSString ctor will be called after +load, so we cant really change its value)
const char* AppControllerClassName = "AppDelegate";

int main(int argc, char* argv[])
{
@autoreleasepool
{
UnityInitTrampoline();
UnityParseCommandLine(argc, argv);

    RegisterMonoModules();
    NSLog(@"-> registered mono modules %p\n", &constsection);
    RegisterFeatures();
    
    // iOS terminates open sockets when an application enters background mode.
    // The next write to any of such socket causes SIGPIPE signal being raised,
    // even if the request has been done from scripting side. This disables the
    // signal and allows Mono to throw a proper C# exception.
    std::signal(SIGPIPE, SIG_IGN);
    
    UIApplicationMain(argc, argv, nil, [NSString stringWithUTF8String:AppControllerClassName]);
}

return 0;

}

#if TARGET_IPHONE_SIMULATOR && TARGET_TVOS_SIMULATOR

#include <pthread.h>

extern "C" int pthread_cond_init$UNIX2003(pthread_cond_t *cond, const pthread_condattr_t *attr)
{ return pthread_cond_init(cond, attr); }
extern "C" int pthread_cond_destroy$UNIX2003(pthread_cond_t *cond)
{ return pthread_cond_destroy(cond); }
extern "C" int pthread_cond_wait$UNIX2003(pthread_cond_t *cond, pthread_mutex_t *mutex)
{ return pthread_cond_wait(cond, mutex); }
extern "C" int pthread_cond_timedwait$UNIX2003(pthread_cond_t *cond, pthread_mutex_t *mutex,
const struct timespec *abstime)
{ return pthread_cond_timedwait(cond, mutex, abstime); }

#endif // TARGET_IPHONE_SIMULATOR && TARGET_TVOS_SIMULATOR
`

@royken royken changed the title Erros in main.mm file : Use of unidentied Errors in main.mm file : Use of undeclared unidentified Oct 31, 2017
@royken royken changed the title Errors in main.mm file : Use of undeclared unidentified Errors in main.mm file : Use of undeclared identifier Oct 31, 2017
@yasirkula
Copy link
Owner

In your screenshot, there are two Data directories listed under Unity group. There should only be one Data directory there. Guess you dragged Data instead of Classes by mistake.

@royken
Copy link
Author

royken commented Nov 1, 2017

Thank you @yasirkula !!!

@royken royken closed this as completed Nov 1, 2017
@scarffy
Copy link

scarffy commented May 8, 2018

Hi guys,

I have kind of similar problem.

I followed the tutorial but I this error 'use of undeclared identifier' on UnityInitStartupTime(); and UnityInitRuntime(argc, argv);

screen shot 2018-05-08 at 11 02 36 am

@yasirkula
Copy link
Owner

Can you show the contents of the Unity group in Xcode?

@scarffy
Copy link

scarffy commented May 8, 2018

Here it is.

screen shot 2018-05-08 at 2 51 24 pm

@yasirkula
Copy link
Owner

If you are trying to test the app on a simulator, can you also try to test it on a real device and see if it changes anything? Unity produces slightly different output for simulators (see Target SDK/SDK Version), so it might be the issue here. Otherwise, if you have made all the adjustments to both PROJECT and TARGETS in Build Settings correctly, I couldn't spot the issue at first glance.

@scarffy
Copy link

scarffy commented May 8, 2018

Unfortunately, the error doesn't go away when I try to test it on a real device. :(

@yasirkula
Copy link
Owner

If you are sure that you have set all the configurations to unityconfig and that you have set the value of UNITY_IOS_EXPORTED_PATH to the path of your Unity build directory (not the one in the screenshot) for both PROJECT and TARGETS, then I guess any help is welcome at this point.

@yasirkula yasirkula reopened this May 8, 2018
@scarffy
Copy link

scarffy commented May 8, 2018

I am quite sure I set up this properly. Here's my screenshot of UNITY_IOS_EXPORTED_PATH and also in config

screen shot 2018-05-08 at 4 39 26 pm

screen shot 2018-05-08 at 4 42 02 pm

screen shot 2018-05-08 at 4 44 33 pm

@yasirkula
Copy link
Owner

Can you show the contents of /Users/Scarffy/Desktop/iOSNativeApp, as well? Just to be sure, if it is OK.

@scarffy
Copy link

scarffy commented May 8, 2018

Here you go.

screen shot 2018-05-08 at 5 08 55 pm

Edit : I'm using unity 2017.3.1 but UNITY_RUNTIME_VERSION says 5.5.2f1. Does it have an effect on this?

@yasirkula
Copy link
Owner

Thank you for providing all the info. Looking at the screenshots, everything does seem to be in order; and I currently have no clues to fix this error.

@scarffy
Copy link

scarffy commented May 8, 2018

That's a bummer. Thanks for trying to solve this issue.

@mateenagy
Copy link

At first I also get this kind of error and I am not sure how I solved this but try again the whole thing again. I also change the unityconfig.xconfig UNITY_RUNTIME_VERSION to the version I used but I don't think this is the problem. Maybe you missed something somewhere. When I tried to make it work it took me around 4 day to figure everything out. :D I also wrote a php script for changing the files after export which makes these steps a little bit faster. I will post this script today and you can try with that if you want.

@mateenagy
Copy link

I made the repo and a how-to for the script. Feel free to ask if you need more help with it.
https://github.com/mateenagy/UnityIonicIntegrationHelperiOS

@scarffy
Copy link

scarffy commented May 14, 2018

@yasirkula Sorry if I request too much but can you do a video tutorial on this project?
@mateenagy maybe I miss out on prefix header? I'm not sure how to set this up. I read the tutorial, delete if it revert to default value but not quite sure what is the default value.

screen shot 2018-05-14 at 4 26 11 pm

screen shot 2018-05-14 at 4 26 57 pm

edit : added screenshot

@yasirkula
Copy link
Owner

A video tutorial sounds nice but neither my current setup nor my motivation is ready for it :/ Sorry.

@mateenagy
Copy link

@scarffy Yes it can cause the problem. When you click on the prefix header and press DELETE it changes the path to the unity folder. And you need to do this in the TARGET and in the PROJECT

@yasirkula
Copy link
Owner

I didn't see the edit while commenting, sorry. Thanks @mateenagy for the assist :)

@scarffy
Copy link

scarffy commented May 15, 2018

@yasirkula No problem :)
@mateenagy From my screenshot, it should be correct. I tried with unity 2017.1 but it's the same thing. Maybe different xcode version that cause it?

Yasir using xcode 8.3.3 while I'm using xcode 9.3.1

@yasirkula
Copy link
Owner

yasirkula commented May 15, 2018

If your Unity build path is /Users/Scarffy/Desktop/iOSNativeApp, then both of them should point to /Users/Scarffy/Desktop/iOSNativeApp/Classes/Prefix.pch. When you select them and press Delete, their values should automatically revert to it.

@mateenagy
Copy link

No I also use Xcode 9.3.1 with Unity 2017.1 and 2018 and everything works well. I also use with the newest Vuforia(only Vuforia or camera usage can be cause problem in Xcode 9.3, but not like this). But yasirkula is right, both of the Prefix Header path should be the same if you delete them.

@jbgtmartin
Copy link

jbgtmartin commented May 16, 2018

I had the same issue. When I press delete, the Prefix Header just becomes blank (it doesn't change to the unity folder).
So I manually set the Prefix Header values to $(UNITY_IOS_EXPORTED_PATH)/Classes/Prefix.pch for both TARGET and PROJECT, and now I can build the project without errors.

I'm using Xcode 9.3 and Unity 2017.3.

@scarffy
Copy link

scarffy commented May 16, 2018

It shouldn't make any different if I don't use vuforia right?
I can also confirm my Prefix Header path is correct. It point to /Users/Scarffy/Desktop/iOSNativeApp/Classes/Prefix.pch.

@mateenagy
Copy link

@scarffy There is no difference. Did you set the prefix header for both TARGET and PROJECT?

@scarffy
Copy link

scarffy commented May 16, 2018

Yes I did. I'll try with blank project for both ionic and unity. I'll let you know how it goes

@scarffy
Copy link

scarffy commented May 22, 2018

Hi Guys, I think I run out of luck with this plugin. I'm not sure where I went wrong, I just can't make it work.

@yasirkula
Copy link
Owner

Did it work on a blank project, though?

@mateenagy
Copy link

@scarffy Can you upload the blank project you made to github so I or we can check your code?

@scarffy
Copy link

scarffy commented May 23, 2018

@yasirkula @mateenagy @jbgtmartin Happy news guys! I managed to make it work. From the bottom of my heart, I truly thank you for the help you guys give me.

I missed out @jbgtmartin comment. My prefix header for TARGET is already right but not for PROJECT. After I build, I ran to this error #15 which is easily solved.

@yasirkula
Copy link
Owner

Glad to hear it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants