Xcode Unit Tests Crash, could not load inserted library IDEBundleInjection - ios

I've got an annoying issue with UnitTests in Xcode 8.1.
Trying to run a basic test on my iPad iOS 10.1.1 causes a crash due to the following error:
dyld: could not load inserted library '__PLATFORMS__/iPhoneOS.platform/Developer/Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection' because image not found
I have yet to find a solution anywhere though some posts have suggested it could be related to the Code Signing for the unit test target. The code signing looks correct, the tests clean build, I deleted derived data, still seeing this error.

No amount of restarting or signing fixed this for me. Only thing that works seems to be turning off debugging.
Do this for each scheme on iOS targets. The implication is that you won't be able to step into your unit tests on devices with the debugger.
Hence, this is really a work-around, not a solution, but I'm posting it anyway as the checkbox is sufficiently obscure that it took me a while to try this and find my test would now run on the device.
I have Xcode bots running for continuous integration, and a real device plugged into my CI machine, so I need this to work.
I'm not sure if its an Xcode bug: if folks think it is then I'll make a report.

Related

How do I debug why xcode won't run my unit tests?

I recently started working on an old ios app which doesn't have unit tests. I am not an ios developer myself. Due to circumstances I feel compelled to start writing unit tests.
App has multiple dependencies added using cocoapods. One of them is a framework which we maintain ourselves.
I am trying to run the dummy testExample that is auto-generated while creating a project. It doesn't have any code.
When I run the test xcode builds & installs the app. App shows the splash screen. But after that nothing happens.
I also tried running the test from command line in case it would print any errors. But it shows
Testing started for configuration 'Configuration 1'
and stops.
I have tried all the remedies I could find on stackoverflow and apple's forum. Typical ios project troubleshooting like deleting folders, etc. have also been tried. I am completely stuck without any error message.
I tried running the dummy test in a newly created project on the same xcode & device and it ran.
How can I debug this issue? Is something in the app code stopping the unit tests from running. How can I make sure that all the right checkboxes are checked and the build configs all correct? Is there a comprehensive list somewhere of steps required to set up unit testing?
Xcode version - 13.4.1 Test device - iphone 11, ios version 15.6

Is there any way to run unit tests in Xcode without building and launching the simulator?

I'm in a very early stage of developing an iOS application, and right now, I just want to test the logic of my Swift code. I don't care about the actual app yet. I've written some unit tests in my tests file, but whenever I run the test suite, it launches the simulator with an iPod Touch as the target device, even though it has nothing to do with my tests for now. Is there a way to disable that?
I've tried going to Project > General and setting the Host Application to 'None' for tests, but it doesn't seem to be doing anything. And I don't know if this is relevant but I also turned off AuthenticationUITests under Product > Scheme > Edit Scheme.
This was the most relevant post I could come across regarding this topic, but it seems to be outdated because I can't find Bundle Loader and Test Host in that place anymore.
I also tried using xctool as per this post, but when I try brew install xctool, it says:
Warning: xctool has been deprecated because it has an archived upstream repository!
Error: xctool: no bottle available!

Tests on CI server are failing (Xcode 9) iOS

Trying to setup continuous integration for my iOS app. Wrote bunch of unit tests that run fine locally for both phone and simulator.
However, when I run my CI bots the tests are failing with this error:
" Test target X encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted) "
There is no more explanation to be found in the logs or anything like that. The bot is set up to use only iPhone 7 iOS 11.2 simulator.
Any kind of help is highly appreciated.
EDIT: I partially fixed this issue by changing Runpath Search Paths on my Test target in Build Settings to $(FRAMEWORK_SEARCH_PATHS).
However, I still get this error if I use more than one simulator on the bot :( So if I use only one simulator everything works fine, but if I use more than one it would fail for all of them or at least for one of them with this same error...

EXC_BAD_ACCESS when trying to run Unity game on iOS simulator

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.

Xcode 4.4 No such file found launching executable

Before anyone just assumes what I am saying here, please read what I have to say.
I have read the hundreds of posts on this topic and have tried pretty much all the suggested resolutions, in no particular order:
Quitting Xcode
Deleting the derived data folder
Cleaning the project
Hard resetting iPhone
Resetting Mac
Tried a second iPhone
Different USB port
All these in 'special' order
Checked code signing attributes
"Validate Settings" returns no problems
Validation returns no problems
I am stumped when it comes to this. The only thing I can think of is actually resetting my phone, but don't see how this could help when it doesn't work on the second phone either.
Are there any other suggestions, tips, ideas on what could be causing this rather annoying bug?
UPDATE: The exact error:
Error launching remote program: No such file or directory (/Users/Username/Library/Developer/Xcode/DerivedData/ProjectName-dnfacjtdklqktcazrpfyupofdryp/Build/Products/Debug-iphoneos/ProjectName.app/ProjectName).
To get the error, I do any combination of the listed steps above, then click Run on "My Device" (an iPhone 4). Application never installs to the phone and Xcode reports the application has finished running then shows the above error.
My problem was cause by me accidently changing the "Deployment Target" (ios version) to a version higher than what was on the phone I tried to run the code on.
Change the deployment target to below or equal to the ios software version on your phone.
(this answer wasn't on your list) :)

Resources