XCTest Error: The bundle couldn’t be loaded. Try reinstalling the bundle
Asked Answered
G

7

16

After I run ProjectNameTests.m (empty test file) by doint Product -> Test the project builds successfully, but it throws and gives me the following error:

2016-01-10 11:25:32.677 xctest[66104:5611958] The bundle “ProjectNameTests” couldn’t be loaded. Try reinstalling the bundle.
2016-01-10 11:25:32.677 xctest[66104:5611958] (dlopen(/Users/XYZ/Library/Developer/Xcode/DerivedData/ProjectName-dnwnjlzdzxbcyydkxsumlvokmhvk/Build/Products/Debug-iphonesimulator/ProjectNameTests.xctest/ProjectNameTests, 265): Symbol not found: _FBSDKErrorArgumentCollectionKey
  Referenced from: /Users/XYZ/Library/Developer/Xcode/DerivedData/ProjectName-dnwnjlzdzxbcyydkxsumlvokmhvk/Build/Products/Debug-iphonesimulator/ProjectNameTests.xctest/ProjectNameTests
  Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Agents/xctest
 in /Users/XYZ/Library/Developer/Xcode/DerivedData/ProjectName-dnwnjlzdzxbcyydkxsumlvokmhvk/Build/Products/Debug-iphonesimulator/ProjectNameTests.xctest/ProjectNameTests)
Program ended with exit code: 83

I've tried removing UIKit from Tests, changing Match-O type, switching simulator to iPhone 5 and other things suggested in similar answers, without any luck. Any ideas?

Gillies answered 10/1, 2016 at 10:30 Comment(1)
Does any one found any solution for this? I am still facing this issue for UI tests, after setting bundle loader.Parsimonious
E
4

Answering this years later (Xcode 13.4) but hopefully this will help someone!

My issue was related to Code Signing.

Go to your test target's Build Settings and:

  • Change Code Signing Identity > Debug to Apple Development
  • Change Code Signing Identity > Release to Apple Distribution.

You may have to create an Apple Distribution certificate if one does not already exist.

Here are the steps to create it:

  • Go to Xcode > Preferences > Accounts. Click on the account that you are using for your app.
  • Click on Manage Certificates
  • Click on the + icon in the bottom left and select Apple Distribution.
Elevation answered 28/5, 2022 at 0:37 Comment(0)
D
2

I just had a similar issue and it turned out that the Xcode project was set to a deployment target of 7.2, but expecta and septa required 8.0 or greater.

Decerebrate answered 18/3, 2016 at 4:41 Comment(0)
E
2

I have an error with exit code 83 not being able to recognize a symbol from an external library added to project.

In my case, it was resolved by setting "Host application" to app in the tests target General configuration. I also have checked "Allow testing host Application APIs"

Etherify answered 31/8, 2016 at 8:3 Comment(1)
I don't have the app showing in the list, it is only showing none, any idea why?Larainelarboard
L
2

Even I got the same error where I have solved it following the below step

Set the Test Host in Build settings of the test target to $(BUNDLE_LOADER)

Actually I was trying to add unit tests to already exists project where I should follow the procedure in the method given in the link Adding Unit Tests to an existing iOS project with Xcode 4 where I have missed that step

Larainelarboard answered 10/11, 2016 at 5:42 Comment(3)
I was getting the "bundle could not be loaded" error and after trying all other ideas from StackOverflow, this change helped me as follows:Lyssa
I was getting the "bundle could not be loaded" error and after trying all other ideas from StackOverflow, this change helped me as follows: The next time I ran the test, the message was that "Testing should be run in the simulator, not in the device". After trying in the Simulator, the tests are running fine....Lyssa
Adding unit tests to an existing project is a nightmare beyond wordsGrandmamma
B
1

I think I am late, But what worked for me is.

When creating Unit Testing Bundle for existing project check following points.

  • Testing Bundle should be on the Same Team, Development Team should be same.
  • Organisation Identifiers Should be same.

If you're using Firebase Pods

  • Copy All Firebase Pods in Test Target and Install Pods

Restart the Xcode. And you're good to go.

Bakst answered 25/7, 2023 at 11:56 Comment(1)
This saved my bacon today, thanks!Madeline
C
0

Sometimes, this error can also happen for a dumb reason : zero tests in target.

Double check your configuration.

Columbuscolumbyne answered 29/1 at 9:53 Comment(0)
M
-1

Removing and re-adding the scheme worked for me.

Monometallic answered 27/6, 2022 at 8:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.