EXC_BAD_ACCESS when trying to run Unity game on iOS simulator - ios

I'm usually not a Mac/Xcode user, please forgive me for incorrect terms or understandings.
I have a 2D Unity game which I can successfully build and run on Android and Windows Phone devices/emulators. When building for iOS, I can successfully create the Xcode project, open it and build the app in there. The only change in the iOS-specific player settings I made was to set SDK Version to Simulator SDK.
However, when trying to run it inside the simulator, the splash screen appears, then Xcode pauses on something that looks like an assemby file with an error message: Thread 1: EXC_BAD_ACCESS (code=1, address=0x4).
As I had no idea on what to do, I started stripping down my project (in Unity) until I had no more gameObjects but the camera left on the start scene. Also, I removed all other scenes from the build. The only thing that changed was that above error message now seems to appear on another assembly file.
What could be the issue here? How should I investigate further?
Update
This is the stacktrace:
Update 2
I've created a new blank Unity project, and I get the exactly same error there. The problem seems to be related to Unity or my machine, not the app itself.
Workaround
After days of researching, I still couldn't resolve the issue and finally built for a real devices instead of the simulator. Since I don't own one, I "blindly" submitted the result to the app store, and it got accepted.
For me, that's the proof that the issue is solely related to the combination of Unity and the iOS simulator, i.e. that those two don't work together reliably.
On the other hand, it seems relatively safe to assume that an app will work on iOS if it's been successfully tested on Android, Windows Phone and the default player. Of course, unless iOS-specific features are implemented.

I only know one reason, that leads to this behaviour (device builds work, but simulator builds won't).
=> This could happen, when using native iOS code / plugins
To fix that, you'll have to modify the <path-to-xcode-project>/Libraries/RegisterMonoModules.cpp file, cause somehow Unity does not register those classes/methods for the simulator.
Just look for #if !(TARGET_IPHONE_SIMULATOR) defines and shift them to have all your plugins included, also in the simulator. There will be some move mono_dl_register_symbol() that you'll need.

Related

iOS Swift game crashing on everyones iPhone, except mine

I've been developing a small "Cookie Clicker" style game for a while now and all of the sudden, the app will instantly crash upon opening. It doesn't crash on my own phone that I've been running the tests on, however, anyone that downloads it from TestFlight cannot even open it. It runs perfectly on the Xcode simulator as well.
Out of desperation, I completely backtracked the update that started the crashes (deleted all the new code for the menu I was working on) but it STILL CRASHES.
I don't want to copy/paste the code here because it is 16,000+ lines and I don't even know which aspect could be affecting it. I am using Xcode 11 and Swift.
If anyone has encountered this problem before and knows even where to start looking for the problem, any help is appreciated.
You need to download the crashlogs from Testflight, re-sybolicate them, and see where it's crashing. Download them from https://appstoreconnect.apple.com/ where you manage TestFlight. Here's an example:
Inside the download is generally two files:
crashlog.crash -- this is the actual crash
feedback.json -- any input provided by the user when it crashed
The .crash file can be re-symbolicated in Xcode as needed and you can see exactly which line caused the crash.

Unity iOS app's screen goes black on startup, but still appears to be running

I'm using Unity Pro 4.5.3f3 + iOS Pro 4.x, Xcode 5.1.1, and tested with an iPhone 4S and 5 running iOS 7.1.2.
I recently took over development of an iOS app from a departing coworker at my game studio, and I'm attempting to compile the app in Xcode on my own machine for the first time. I have followed his instructions for which extra Obj-C code to add manually. The app works perfectly in Unity. Everything builds in Xcode without errors.
When the app runs, I see the custom splash screen loading as intended, but then the screen goes completely black. The app appears to be running fine...I can hear its sounds playing and it even responds when I tap the screen in areas where I know the buttons are supposed to be. There are no errors thrown to the log. But it doesn't display any graphics at all!
I suspect the Prime[31] plugin has something to do with it, as I get a strange log output saying Prime[31] didn't recognize several other plugins. And I can't delete it to test my theory, because way too many scripts depend on it.
Does anyone know how to fix this? I have lots of tasks to do for this app and I can't let something like this slow me down.
I encountered this issue last night when trying to configure my app to be compatible with Facebook Canvas.
Below is the line of code that was breaking:
FB.Canvas.SetAspectRatio(9,16, FBScreen.CenterHorizontal(), FBScreen.CenterVertical());
To fix my issue I surrounded the line with the UNITY_WEBPLAYER preprocessor directive like so:
#if UNITY_WEBPLAYER
FB.Canvas.SetAspectRatio(9,16, FBScreen.CenterHorizontal(), FBScreen.CenterVertical());
#endif
Doing this causes that line of code to only be compiled and run in the web player, and not on the mobile device. Hope that helps!

Launching app on iOS Simulator (waxsim no longer works)

I've had a workflow for a while that ran automated tests by building an app for the simulator, then launching it using waxsim. On every new sdk release there were some small tweaks to keep it working. However, XCode 5.1 removed the iPhoneSimulatorRemoteClient framework, so waxsim no longer works.
I tried using the ios simulator from the command line directly, as in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication /mydir/myapp.app/myapp
However myapp does not run, I just get the simulator loading the home screen. I can't figure out what might be going wrong, since I can't find a way to get any verbose output - the simulator does not complain about anything, it just doesn't load my app.
Any ideas, thoughts? Perhaps an alternative to waxsim that works on Xcode 5.1?
ios-sim was recently updated to support the new private framework DVTiPhoneSimulatorRemoteClient that is present in the current Xcode/SDK. I tried it and it seems to work fine, so I pretty much answered my main question.
Still, if someone has an idea why -SimulateApplication does not work (when the same app launches fine with ios-sim), I'd be curious to find out.

Xcode not transferring app to iPhone (Successfully)

I've built a starter app for myself and wanted to transfer it to my iPhone 4 but unfortunately when it's transferred from Xcode to my iPhone, Xcode throws an error which terminates the app (of sorts) and I get nothing on the screen except the app logo. All of which is beyond my understanding.
The debugger shows an error in the main.m file highlighting the following line:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
whilst labelling the above line with the following words:
Thread 1: signal SIGABRT
I would like to point out that my device is jailbroken also. Please let me know what I need to do to get my app running on my device successfully.
The correct way to fix this depends on which way you're expecting to upload and run your code - i.e. do you upload your code via ssh in a user-specified script, or do you use the apple-provided way with provisioning profiles? Your question is currently lacking the information needed for answering this.
Since you're jailbroken, you should always be able to add a post-build hook which signs the binary using ldid -S, uploads the binary to the iPhone, and runs it.
(You won't be able to use the debugger integrated into XCode without major hackery if you use this way, and there's probably a simpler way of achieving this.)
Probably the device recognizes your Apple certificate isn't valid (if you even have one) or the software refuses to run the app on a device that isn't fully legit according to Apple's standards.
That is one reason but that's something I'm fully certain. I searched stackoverflow and found another possible explanation. This topic states that a new xcode project only runs on the newest OS. At the moment iOS 7 is still in beta so a startup project launches default in iOS 6.1.
To make it run on an older version you'll just need to adjust the deployment target to the version you prefer. Ofcourse working in an older OS will take effect in the language and "set you back". And here is how to change your deployment target. Hope this helped?

Cordova iOS: Alert-Popups and Device-Ready is not firing

I just set up a new PhoneGap project for android, which worked perfectly fine without any problems, there were almost no changes to the template project.
Then I wanted to move that exact project to iOS, and the woes began.
When I start the project, suddenly a bunch of alter dialogs pop up, with device information, network status. Each offer me "ok" and "cancel". When I press "ok" on any of them, execution is halted, and nothing happens further.
When I cancel them all, I get to the project screen, where it says "connecting to device". Obviously, deviceready is never fired on this.
Since this project is merely the template offered by Cordova themselves, I find it hard to believe it is not supposed to run. I suspect the console.log messages get popped up on screen rather than the XCode debug window.
I am completely new to XCode or any iOS programming (hence PhoneGap), and I would appreciate any help.
Using Cordova 2.8.1.
Reason was I mistakenly copies the cordova.js for android into the ios project, see here.

Resources