CoronaCards for iOS with Unity 5?

I’m trying to get CoronaCards to build in a Unity 5.3.4 project using Xcode 7.2.1.

I’ve been able to get Xcode to compile with some adjustments to the docs (see below), but I’m still getting errors in the linking stage.

Undefined symbols for architecture armv7:

  “std::__1::__shared_weak_count::~__shared_weak_count()”, referenced from:

      std::__1::shared_ptr<Pfx::Asm::UnpackedData> std::__1::shared_ptr<Pfx::Asm::UnpackedData>::allocate_shared<Alg::UserAllocator<Pfx::Asm::UnpackedData>, Pfx::Asm::Assembly&>(Alg::UserAllocator<Pfx::Asm::UnpackedData> const&, Pfx::Asm::Assembly&&&) in libiPhone-lib.a(asmdecodedassemblies.o)

      std::__1::__shared_ptr_emplace<Pfx::Asm::UnpackedData, Alg::UserAllocator<Pfx::Asm::UnpackedData> >::~__shared_ptr_emplace() in libiPhone-lib.a(asmdecodedassemblies.o)

      std::__1::__shared_ptr_emplace<Pfx::Asm::UnpackedData, Alg::UserAllocator<Pfx::Asm::UnpackedData> >::~__shared_ptr_emplace() in libiPhone-lib.a(asmdecodedassemblies.o)

 

Any ideas?

Some things I had to do to get things to compile in Xcode with the build files for Unity 5:

  1. createViewHierarchy has been deprecated–the CoronaView has to go in createUI in UnityAppController+ViewHanlding.mm

  2. Automatic Reference Counting has to be disabled for Objective C (in build settings) for autorelease not to throw an error in _coronaController = [[[CoronaViewController alloc] init] autorelease];

  3. Error thrown because ‘context’ in    

//Added for OpenGL context

    [EAGLContext setCurrentContext:_mainDisplay->surface.context];

didn’t exist as a property. Removed this line, which probably wasn’t a good idea.

You can check to make sure that the C++ standard library is set to use libstdc++ (GNU C++ Standard Library)

Also try adding libstdc++.6.dylib to your xcode project.

Rob

Hm, that didn’t work for me. (Don’t know Xcode that well, but I’m assuming you meant to link libstdc++.6.dylib in the “Link Binary With Libraries” build phase, which adds it to the Frameworks folder.)

2nd question before pursuing this any further: It looks like, unless I’m misunderstanding something, every time I build from Unity I’ll need to adjust the Xcode project it generates. If so, that’s a bit finicky for what I’m trying to accomplish.

I’ve never tried to build out of Unity before so I don’t know how it makes projects. It seems rather silly that it would write out a new project file every time. Perhaps somewhere in Unity you can add things that it needs to add to the project, much like our SDK builds can update the Info.plist, AndroidManifest.xml for you, copy libraries to the right folder and link them, etc. If you have to go adjust the Xcode project every time  you build that’s going to be super annoying.

As for the libstc++.6.dlyb, the engineer wasn’t clear when he said to add it. I would have assumed I would need to copy it to the project folder and then add it in Xcode as a library, but it sounds like the Link Binary with Libraries is adding it.

I’ll see if I can get a more indepth answer from the engineers.

Rob

Thanks Rob–I hadn’t thought of that. I didn’t see anything obvious, but it makes sense that there might be somewhere in Unity to specify Xcode project settings. I’ll dig around a little.

Cheers,

-mark.

An engineer got back to me with more information today. He said:

You can do this using something unity has called postprocessbuild script. You need to write a script in js or python and you can execute this script.

He’s not 100% sure how to do this, but this example should get you close.  For reference, in the script you can pass the xcode project location and then create a variable in python :

import os, sys from mod\_pbxproj import XcodeProject import shutil if sys.argv[2] != 'iPhone' and sys.argv[2] != 'iOS' : &nbsp; &nbsp; sys.exit(1) &nbsp;XCODE\_PROJECT\_PATH = sys.argv[1] + '/Unity-iPhone.xcodeproj' project = XcodeProject.Load(XCODE\_PROJECT\_PATH +'/project.pbxproj') project.add\_file\_if\_doesnt\_exist('System/Library/Frameworks/CoreGraphics.framework', tree='SDKROOT', parent=framework\_group) project.add\_file\_if\_doesnt\_exist('System/Library/Frameworks/CoreTelephony.framework', tree='SDKROOT', parent=framework\_group) project.add\_file\_if\_doesnt\_exist('System/Library/Frameworks/CoreText.framework', tree='SDKROOT', parent=framework\_group) project.add\_file\_if\_doesnt\_exist('System/Library/Frameworks/MobileCoreServices.framework', tree='SDKROOT', parent=framework\_group) project.add\_file\_if\_doesnt\_exist('System/Library/Frameworks/Security.framework', tree='SDKROOT', parent=framework\_group) project.add\_file\_if\_doesnt\_exist('System/Library/Frameworks/QuartzCore.framework', tree='SDKROOT', parent=framework\_group) project.add\_file\_if\_doesnt\_exist('usr/lib/libsqlite3.dylib', tree='SDKROOT', parent=framework\_group) project.add\_file\_if\_doesnt\_exist('usr/lib/libz.dylib', tree='SDKROOT', parent=framework\_group) if project.modified: &nbsp; &nbsp; project.backup() # take project.pbxproj backup, &nbsp; &nbsp; project.save() &nbsp; # save modified pbxproj

You will need to call this script from unity.

Rob

Thanks, that helps. I’ll give it a try.

You can check to make sure that the C++ standard library is set to use libstdc++ (GNU C++ Standard Library)

Also try adding libstdc++.6.dylib to your xcode project.

Rob

Hm, that didn’t work for me. (Don’t know Xcode that well, but I’m assuming you meant to link libstdc++.6.dylib in the “Link Binary With Libraries” build phase, which adds it to the Frameworks folder.)

2nd question before pursuing this any further: It looks like, unless I’m misunderstanding something, every time I build from Unity I’ll need to adjust the Xcode project it generates. If so, that’s a bit finicky for what I’m trying to accomplish.

I’ve never tried to build out of Unity before so I don’t know how it makes projects. It seems rather silly that it would write out a new project file every time. Perhaps somewhere in Unity you can add things that it needs to add to the project, much like our SDK builds can update the Info.plist, AndroidManifest.xml for you, copy libraries to the right folder and link them, etc. If you have to go adjust the Xcode project every time  you build that’s going to be super annoying.

As for the libstc++.6.dlyb, the engineer wasn’t clear when he said to add it. I would have assumed I would need to copy it to the project folder and then add it in Xcode as a library, but it sounds like the Link Binary with Libraries is adding it.

I’ll see if I can get a more indepth answer from the engineers.

Rob

Thanks Rob–I hadn’t thought of that. I didn’t see anything obvious, but it makes sense that there might be somewhere in Unity to specify Xcode project settings. I’ll dig around a little.

Cheers,

-mark.

An engineer got back to me with more information today. He said:

You can do this using something unity has called postprocessbuild script. You need to write a script in js or python and you can execute this script.

He’s not 100% sure how to do this, but this example should get you close.  For reference, in the script you can pass the xcode project location and then create a variable in python :

import os, sys from mod\_pbxproj import XcodeProject import shutil if sys.argv[2] != 'iPhone' and sys.argv[2] != 'iOS' : &nbsp; &nbsp; sys.exit(1) &nbsp;XCODE\_PROJECT\_PATH = sys.argv[1] + '/Unity-iPhone.xcodeproj' project = XcodeProject.Load(XCODE\_PROJECT\_PATH +'/project.pbxproj') project.add\_file\_if\_doesnt\_exist('System/Library/Frameworks/CoreGraphics.framework', tree='SDKROOT', parent=framework\_group) project.add\_file\_if\_doesnt\_exist('System/Library/Frameworks/CoreTelephony.framework', tree='SDKROOT', parent=framework\_group) project.add\_file\_if\_doesnt\_exist('System/Library/Frameworks/CoreText.framework', tree='SDKROOT', parent=framework\_group) project.add\_file\_if\_doesnt\_exist('System/Library/Frameworks/MobileCoreServices.framework', tree='SDKROOT', parent=framework\_group) project.add\_file\_if\_doesnt\_exist('System/Library/Frameworks/Security.framework', tree='SDKROOT', parent=framework\_group) project.add\_file\_if\_doesnt\_exist('System/Library/Frameworks/QuartzCore.framework', tree='SDKROOT', parent=framework\_group) project.add\_file\_if\_doesnt\_exist('usr/lib/libsqlite3.dylib', tree='SDKROOT', parent=framework\_group) project.add\_file\_if\_doesnt\_exist('usr/lib/libz.dylib', tree='SDKROOT', parent=framework\_group) if project.modified: &nbsp; &nbsp; project.backup() # take project.pbxproj backup, &nbsp; &nbsp; project.save() &nbsp; # save modified pbxproj

You will need to call this script from unity.

Rob

Thanks, that helps. I’ll give it a try.