Fabric Twitter Unity iOS image not found/error



Hi all,

I’m having a problem relating to Fabric Twitter in Unity for iOS in regards to posting an App Card. I’m not having this issue under Android however.

I’ve pasted the relevant code below:

        Uri myUri = new Uri (imageUri);

        card = new AppCardBuilder ()
                .IPhoneId ("myid")
                .IPadId ("myid");

This code runs successfully for Android but under iOS I will consistently get the error from xcode output:

NullReferenceException: A null value was found where an object instance was required.
  at Fabric.Twitter.Card.get_imageUri () [0x00000] in <filename unknown>:0 
  at TwitterCalls.LoginComplete (Fabric.Twitter.TwitterSession session) [0x00000] in <filename unknown>:0 
  at UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) [0x00000] in <filename unknown>:0 
  at UnityEngine.EventSystems.TouchInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, Boolean pressed, Boolean released) [0x00000] in <filename unknown>:0 
  at UnityEngine.EventSystems.TouchInputModule.ProcessTouchEvents () [0x00000] in <filename unknown>:0 
UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
UnityEngine.EventSystems.TouchInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)

To me this error suggests that it is having trouble finding the correct file? I have tried using both the normal filepath and the uri formatted filepath with the same result each time.

Does anyone know the issue here?



Hey @RichardGillen,

It definitely could be a pathing issue - if you log out the path of the URI, does it come through as a valid URI?



Hi Mike,

Thanks for the quick reply. I ran again with some extra debug statements to try and give you more info.

Normal filepath: /var/mobile/Containers/Data/Application/D120386B-117C-45EB-AFB3-8B46195579BF/Documents/AppCardImage.png

URI filepath: file:///var/mobile/Containers/Data/Application/D120386B-117C-45EB-AFB3-8B46195579BF/Documents/AppCardImage.png

It’s worth noting that this is fine on Android using the URI for some reason.

Additionally, I updated to the most recent version of Twitter Kit (v2.0.0). Before this I could get my tweet dialogue to show up correctly however the tweet would never post and would also throw no errors. I’m only saying as this might provide more clues but I guess it might be irrelevant now that I’ve updated.



Thanks @RichardGillen, that is interesting. Is it possible that the file is moving often or that there might be a race condition before the URI is available? I’m not sure when you’re getting that file to make it available to tweet with.


Hi Mike,

Sorry for how vague this is, I’ve exhausted all options I can think of and I can’t find any cause for this.

I checked to see if the file was being created too late and I even added in a delay before the App Card composer to make sure the image was being created in time. I still get the same error regardless of my efforts however.

Could there have been something in the update that changed or causes this? It seemed to be in a more functional state before I upgraded (Getting to the tweet prompt).)



Thanks @RichardGillen, I’m going to do some more testing and get another set of eyes to take a look in case I’m missing something. I assume you’re on 2.0.0 of Twitter for Unity?


Hey @RichardGillen,

I think I may have tracked this down. There is an issue in the Unity wrapper which requires that different paths be passed in for Android vs. iOS. I believe that iOS requires the url to be in the form /var/mobile/... (without the file://) whereas Android requires the path to be in the format file:///var/mobile/...

Try that out and let me know how it goes!



Hi Mike,

Thanks for the advice, I’ve tried both the /var/mobile (without file://) and the format with file:// and both produce the same result.

This didn’t seem to be a problem before I upgraded to 2.0.0 though, I could get the tweet prompt to show up on whatever old version I was on.



I decided to try my code and twitter kit on a completely new Unity application and I am facing the same error on iOS.
It’s quite possible that there is something I am doing wrong in regards to iOS. However I’ve gone over the code so much and I can’t see anything that could be wrong!

The issue I can see that my code might be causing is to do with the correct path being passed in. Although I have looked over my code many times to make sure it isn’t on my side. I am passing in the correct format (Without file:///) and I am using the Application.PersistentDataPath variable that Unity provides to get the correct file location on device.

Just thought I’d let you know about my trying it on another application. I had the idea that upgrading versions of the twitter kit might not have completed properly but alas.

On another note. The android version seems to use my twitter app to do all the related tweeting, so if I’m logged already logged in I won’t need to log in again (I’m not sure if this is the case but it appears like this). Whereas on iOS it seems that even if I have the twitter app installed and logged in it will not use this like it would on android.
I was just wondering if this is the case and if so will it be implemented at some point?



I’m seeing the same error when trying to post on iOS, and it works correctly on Android.
(I’m using Unity 5.5.1p2 and Twitter Kit 2.0.2.)

After changing from “file://” to without “file://” on iOS I’m able to get the Twitter post dialog to show.
(I’m still unable to post, but I think it’s because I’m not approved for App Cards yet)

It would be great if this can be fixed though so platform specific code doesn’t need to be written to change the path.


Same issue here. Any news on the fix?