UnityIonicIntegration
UnityIonicIntegration copied to clipboard
iOS build fails: linker issues
After following steps outlined in readme, I am having issues building to an iOS device. Xcode provides the following error:
![Screen Shot 2019-03-29 at 1 31 03 PM](https://user-images.githubusercontent.com/5655773/55201281-2df8e800-5227-11e9-880a-dd44edbaee31.png)
Any ideas?
Edit: I see some references in the error log to "MetalRenderData"... I have double checked and my Unity project settings have auto graphics api unchecked and OpenGLES2 is the only enabled option
Can you compile and run the Unity project alone in Xcode (without Ionic integration)?
Yes, project works fine on its own without ionic integration.
Doing some more investigation I found this: https://stackoverflow.com/questions/51523567/error-undefined-symbols-for-architecture-arm64-when-embed-unityvuforia-in-ios/51547613
Which would indicate an issue with Vuforia versions >= 7.2.
I will attempt to apply that fix and report my findings
I am getting this error too. Working on iOS 12.1, latest Xcode, latest Unity, latest Vuforia and latest ionic. I imported all of the frameworks through copying, changed the prefix statements on the build settings to that of Unity. Was getting the il2cpp and mscorlib errors, after importing the frameworks I now get that error, symbols not linked for arm64... any advice on how to fix this? I noticed it says something about arm64 for androids in the walkthrough but not for iOS. What else can I do to get this working?
Are you trying to build to a real iphone device? I was getting this error too but when I was trying to build to an emulator, but when I built for my iphone it worked perfect.
Glad to hear it’s still working. Yeah I’m building it for my iPhone X device, not an emulator. I tried deleting the unity ads plugin and cleaning up my unity project more, hopefully this time around it compiles properly. I’m not sure why the arm64 error was coming up though. I set the project to compile to arm64 in unity with no luck, set it back to universal. I noticed that there is only an arm64 setting for some reason. I’m using Vuforia btw, did your project include Vuforia? Really want to get this working, any additional advice would be great. Thanks again.
update: still no luck.. not sure why though. Here's some pics.
I noticed that there was a difference between the C language dialects in my Unity project and my Ionic integrated project. Not sure if this is causing any issues..
Also, here is a picture of my unity build player settings.
I'd suggest you to compare your Unity build's Xcode folder structure and "Link Binary With Libraries" section with your final Ionic+Unity Xcode project's ones (especially the Unity group) and see if there are any additional directories or libraries in Unity's Xcode project.
I deleted DynamicLibEngineAPI.o and DynamicLibEngineAPI.mm as a reference and it fixed my problems. Now to the runtime error.. One weird thing I noticed is that when I click on button I'm using to open Unity, theres a plugin icon on the screen for like a second or so. I edited the info on the build to add the camera privacy settings request. And it works! I am now in Unity.. However my return to ionic button via FinishActivity doesn't appear to do a thing.
Here's what it looks like in Unity.
Am I missing something?
Glad it works now! IonicComms.FinishActivity is a static function. To call it from a button, you need to add the following function to one of your C# scripts and then add it to your button's "On Click()":
public void ReturnToIonic( string returnMessage )
{
IonicComms.FinishActivity( returnMessage );
}
One other thing that I really wanted to add but couldn't quite figure out... I am using the "plane finder" object along with the "ground plane" to position an object onto a surface. I know that doesn't necessarily belong to issues #49, but its an issue I am trying to figure out..
I want to send a message from ionic with a message associated with the button that I am clicking. (in my case it's an image). I am trying to figure out how to receive the message on the Unity side and switch the anchor to a second ground plane with a 3d object associated with the message.
ionic message -> unity receive message -> plane finder automatically loads anchor associated with message
Can you please help me figure out how I can modify my plane finder to load it's anchor according to the message received? Thanks again for all the assistance.
For example, if you are calling unityARCaller.sendMessage( "SwitchAnchor", "GroundPlane2" );
in Ionic, you can add the following code inside the IonicComms C# script:
public GameObject anchor1, anchor2; // Assign these values from the IonicComms object's Inspector
public void SwitchAnchor( string anchorName )
{
if( anchorName == "GroundPlane1" )
{
// set anchor1 as active anchor
}
else if( anchorName == "GroundPlane2" )
{
// set anchor2 as active anchor
}
}
hey again, appreciate the advice. do I have to uncomment
// set anchor1 as active anchor
and
// set anchor2 as active anchor
?
when I try to run my program on unity uncommenting those lines I appear to get a compilation error.
I don't know how changing the active anchor works, so I left the implementation part to you. You need to write the code that changes the active anchor under those commented lines.
Thanks for the help before. Trying to recompile my script now and I am running into another error...
What my issue came down to is:
Undefined symbols for architecture arm64: "_VuforiaRenderEvent", referenced from: -[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o ld: symbol(s) not found for architecture arm64
in AppDelegate.mm, it is having some type of issue with Vuforia.. any advice for this one?
One last thing, my player settings changed a little. Do you think that any of these settings are causing issues?
First, I'd recommend you to take a look at this post: https://github.com/yasirkula/UnityIonicIntegration/issues/16
Then, open your Unity build's Xcode project and see if its folder organization, referenced libraries, Prefix.pch etc. have any obvious differences than what you achieve after integrating that build to your Ionic Xcode project. In other words, compare the two Xcode projects to see if the latest version of Vuforia requires any additional steps/files/references.
First, I'd recommend you to take a look at this post: #16
Then, open your Unity build's Xcode project and see if its folder organization, referenced libraries, Prefix.pch etc. have any obvious differences than what you achieve after integrating that build to your Ionic Xcode project. In other words, compare the two Xcode projects to see if the latest version of Vuforia requires any additional steps/files/references.
I got it to compile again! The only thing that made it work is skipping the step:
for Vuforia users: in AppDelegate.mm, uncomment the lines marked with //for vuforia:
After skipping it Unity appears to still have the same functionality that I was expecting. I am not sure if this is causing other issues though..
One other thing, when using the ReturnToIonic function that you defined, do you know how to return to Ionic without prompting a pop-up with defined/undefined message on the Ionic side that you have to click OK to continue?
I am still trying to write a functioning script to change the anchors as well..
private StateManager stateManager;
PositionalDeviceTracker positionalDeviceTracker;
ContentPositioningBehaviour contentPositioningBehaviour;
[SerializeField] PlaneFinderBehaviour planeFinder = null;
AnchorBehaviour planeAnchor;
[Header("Placement Anchors")]
[SerializeField] public GameObject Anchor1 = null;
[SerializeField] public GameObject Anchor2 = null;
void OnVuforiaStarted()
{
Debug.Log("OnVuforiaStarted() called.");
stateManager = TrackerManager.Instance.GetStateManager();
}
public void SwitchAnchor( string message )
{
// Reset trackers
this.positionalDeviceTracker = TrackerManager.Instance.GetTracker<PositionalDeviceTracker>();
this.positionalDeviceTracker.Reset();
// Define positional behaviour
this.contentPositioningBehaviour = this.planeFinder.GetComponent<ContentPositioningBehaviour>();
// Interpret message to set anchor
if( message == "anchor1" )
{
this.contentPositioningBehaviour.AnchorStage = this.Anchor1.GetComponentInParent<AnchorBehaviour>();
}
if( message == "anchor2" )
{
this.contentPositioningBehaviour.AnchorStage = this.Anchor2.GetComponentInParent<AnchorBehaviour>();
}
}
public void HandleInteractiveHitTest(HitTestResult result)
{
planeFinder.HitTestMode = HitTestMode.AUTOMATIC;
if (result == null)
{
Debug.LogError("Invalid hit test result!");
return;
}
else
{
Debug.Log("HandleInteractiveHitTest() called.");
this.contentPositioningBehaviour.DuplicateStage = false;
this.contentPositioningBehaviour.PositionContentAtPlaneAnchor(result);
}
}
This is what I added my IonicComms.cs. I then attached IonicComms.cs to the Plane FInder and removed the Content Positioning Behavior script, attached the planefinder and anchors objects in the inspector, and replaced the "On Interactive Hit Test" with the IonicComms.HandleInteractiveHitTest script. When clicking on a link from ionic, I wanted this to execute SwitchAnchor with the message "anchor1" or "anchor2", changing the content positioning behavior anchor stage. Then when performing an InteractiveHitTest, I wanted it to then position the content at the plane anchor without duplicating the stage. Its still not working properly though.. can't quite figure it out. Any advice..?
The pop up might be triggered by an alert
function in the Ionic code, the plugin itself isn't supposed to show any dialogs.
When are you calling the SwitchAnchor function? I think the most ideal place for it would be inside the IonicComms.OnMessageReceivedFromIonic function. You can simply call SwitchAnchor(message);
there. Then, in your Ionic code, you can start Unity-side like this: unityARCaller.launchAR( "anchor1", this.uReturnedFromUnity, this.uMessageReceivedFromUnity );
I'll look into the alert function.. Something is triggering an alert on ionic when Unity is completed. Also, do we have to click "OK" every time we enter unity as well after it prompts something about the camera usage? I think that was happening the other day.
As for my program, maybe I should just attempt a simpler way of doing this. Is it possible to use a on click from ionic to open a particular scene in unity? If that works I can just save each scene on its own with the desired anchors and then call them from ionic.
ionic > click link 1 > load scene 1 ionic > click link 2 > load scene 2 etc.
Any ideas on if this is possible? Thanks again for everything
- I don't think it will ask camera permission more than once
- You can launch Unity like this:
unityARCaller.launchAR( "name of the scene", this.uReturnedFromUnity, this.uMessageReceivedFromUnity );
- Then, you can call
UnityEngine.SceneManagement.SceneManager.LoadScene(message)
insideIonicComms.OnMessageReceivedFromIonic
- Then, you can call
We should discuss further issues via email because it is getting off-topic now.
Currently i'm working on Mapbox+Unity+Ionic app integration with this plugin on iOS12.2 - Fixed this arm64 issue by adding ARkit Framework under "Linked Frameworks and Libraries"