- Home /
Unity 5 iPhone Builds. Bad Access
Hey all,
Basically I a trying to make our game run on the iPhone, works totally fine on Android, but each time the game runs I see the loading splash and then it crashes. I have been following this thread but their solutions don't seem to make a difference for me:
http://forum.unity3d.com/threads/black-screen-on-ios-device-beta14.282154/
This crashes on the line:
return [_displayConnection objectForKey:(UIScreen*)key];
In the file DisplayManger.mm, method objectForKeyedSubscript()
If I follow the stack trace for the thread is first gets called by the UnityAppController.mm on the line/method:
[[DisplayManager Instance] updateDisplayListInUnity];
Not going to lie I am completely stumped!
Any ideas or suggestions welcome. Oh I have tried a build with a blank project and just a spinning cube, works totally fine
P.S I have tried adding more tags such as Unity5 and iOs or iPhone but it refused to a crept any of them. If anyone could add some for me that would be awesome
Answer by asayman · Mar 09, 2015 at 12:00 PM
I "had" the same issue but looks like I solved it!
For me, to be able to build my app for Facebook, I had to disable the arc just like mentioned below: http://stackoverflow.com/questions/6646052/how-can-i-disable-arc-for-a-single-file-in-a-project/6658549#6658549
After that, my problem about build was gone and I was able to load it to my iPhone6. But after play, I had the same issue as you mentioned. When I debugged for _displayConnection object, reference pointer inside of the object was null. (Don't know Objective-C, just C++ so sorry about syntax!)
What did I do? Well:
First, I set ALL files' flags with -fno-objc-arc flag as mentioned on the link! Why all? Because it was easier! But as far as I can see, only one file; FBUnityInterface.mm needs to be corrected this way! When I remove compiler flag from rest, my app is working fine right now!!! So set compiler flag for FBUnityInterface.mm and leave rest!
I'm using Unity 5 Personel, Facebook SDK 6.2.1. Target device is iPhone 6 and I set iOS 8.1 on my platform settings for iOS and Unity.
Hope this helps you too!!!
The forums where being weird and never emailed me to say you answered :/ But that worked for me as well thanks. I had to still enable ARC for some of our add stuff (App Lovin and A$$anonymous$$ob) but only enabling the files that failed to compile fixed our issues as well :)
This is not an authentic solution. They guy under your answer gave a reasonable solution :-)
Answer by niniane · Mar 25, 2015 at 07:20 AM
For me, this only became fixed when I edited Classes/Unity/DisplayManager.mm, line 277, to say:
_displayConnection = [[NSMapTable
mapTableWithKeyOptions:NSPointerFunctionsStrongMemory | NSPointerFunctionsObjectPointerPersonality
valueOptions:NSPointerFunctionsStrongMemory | NSPointerFunctionsObjectPointerPersonality
] retain];
It seems strange that I need to make this change, but others do not. However, this allowed the app to continue running.
this line looks different in Unity 5.1, but it worked for me by just adding retain
Thank You So $$anonymous$$uch. You are life saver. I have been stuck on this problem for 4-5 hours. Your answer should be verified as a Right Solution I guess :-)
Answer by Karthik-Karunararan · Nov 23, 2016 at 07:32 AM
I had a similar issue. it was crashing on the below line.
- (BOOL)displayAvailable:(UIScreen*)targetScreen;
{
return self[targetScreen] != nil;
}
It was caused because I disabled Automatic reference counting (ARC) in the Xcode project settings. Re-enabling it fixed the issue. If you don't want to use ARC in your code add -fno-objc-arc flag to your Objective-C script.
Your answer
Follow this Question
Related Questions
Monodevelop freezes on saving Javascript OR C#. Critical headdesk! 1 Answer
Windows 7 64-bit | Startup Crash 0 Answers
Project's terrain disappeared 1 Answer
Game Crash When Changing Scene 1 Answer
App Store Rejection - Crashes 2 Answers