Occasional errors when running OCUnit application test suite on device - iphone

I'm having some problems with my OCUnit test suite, when running application tests (i.e. on the device). Occasionally, I get a tricky error that seems to be thrown from the OCUnit classes. I've been trying to look through the files added to the test suites, but can't get my head around it.
I've followed the Apple documentation and looked at other tutorials when setting up my test targets, resulting in the following targets (and indented dependencies):
LogicTests
MyApp
LogicTests
ApplicationTests
MyApp
MyAppTesting
ApplicationTests
The last (MyAppTesting) is the one I run on the device to start the test suite.
And as mentioned, the tests fail to start sometimes throwing me the following output in the console:
2010-11-17 12:02:48.537 VCCTesting[12018:307] *** Assertion failure in -[SenTestClassEnumerator init], /SourceCache/OCUnit/OCUnit-1685/SourceCode/SenTestingKit/SenTestClassEnumerator.m:137
2010-11-17 12:02:48.556 VCCTesting[12018:307] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'objc_getClassList returned more classes than it should have.'
*** Call stack at first throw:
(
0 CoreFoundation 0x30897ed3 __exceptionPreprocess + 114
1 libobjc.A.dylib 0x3002f811 objc_exception_throw + 24
2 CoreFoundation 0x30897d15 +[NSException raise:format:arguments:] + 68
3 Foundation 0x349f932f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 62
4 SenTestingKit 0x20107c29 -[SenTestClassEnumerator init] + 292
5 SenTestingKit 0x201079fd +[SenTestClassEnumerator classEnumerator] + 24
6 SenTestingKit 0x2010777d +[NSObject(SenTestRuntimeUtilities) senAllSubclasses] + 92
7 SenTestingKit 0x201067b5 +[SenTestSuite updateCache] + 28
8 SenTestingKit 0x20106753 +[SenTestSuite suiteForBundleCache] + 54
9 SenTestingKit 0x201065db +[SenTestSuite structuredTests] + 14
10 SenTestingKit 0x201065a1 +[SenTestSuite allTests] + 40
11 SenTestingKit 0x20106573 +[SenTestSuite defaultTestSuite] + 14
12 SenTestingKit 0x201057a3 +[SenTestProbe specifiedTestSuite] + 106
13 SenTestingKit 0x20105d83 +[SenTestProbe runTests:] + 94
14 Foundation 0x349c7e8d __NSFireDelayedPerform + 368
15 CoreFoundation 0x3084e7fb __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
16 CoreFoundation 0x3084e2ad __CFRunLoopDoTimer + 860
17 CoreFoundation 0x3081f7a5 __CFRunLoopRun + 1088
18 CoreFoundation 0x3081f277 CFRunLoopRunSpecific + 230
19 CoreFoundation 0x3081f17f CFRunLoopRunInMode + 58
20 GraphicsServices 0x31e445f3 GSEventRunModal + 114
21 GraphicsServices 0x31e4469f GSEventRun + 62
22 UIKit 0x31e51123 -[UIApplication _run] + 402
23 UIKit 0x31e4f12f UIApplicationMain + 670
24 VCCTesting 0x000234ff main + 70
25 VCCTesting 0x00002538 start + 40
)
terminate called after throwing an instance of 'NSException'
Does anyone know what could be wrong?
Thankful for any help,
Kristofer
P.S. I've posted this on the App dev forums, but haven't had any luck with it yet: https://devforums.apple.com/message/333890

Do you have NSZombieEnabled? I had this issue when I had NSZombieEnabled set to YES in my arguments for my unit test launch target. I've tried everything (cleaning/quitting XCode/restting simulator content).
The only solution so far was to disable zombie in my unit test launch

I think I've just figured out why I was getting this error as well -- perhaps the same thing is happening to you:
I have two products set up, one for internal beta testing (complete with a preference pane) and one for app store release. Both product targets were set up with the same Product Name (PRODUCT_NAME in build settings).
This worked fine in XCode 3.x, but XCode 4 was somehow trying to build the store product each time I built the beta product. I think this is due to the change in where XCode puts its derived files -- XCode 4 was storing the beta and store products at the same path, so when the beta product was built, the store output file changed and needed to be rebuilt...
Anyway... changing the beta Product Name has fixed temporarily fixed the issue... I've also changed the bundle identifier in the Info.plist so the two products have different identifiers. Now when I build one product, the other doesn't get built at the same time, but I still get the crash when the tests run :-(
My only idea now is to totally recreate the project from fresh, copying across the settings and the files to see if XCode 4 does something different. That and filing a support incident with Apple...
Cheers,
Adam

I am not 100% sure yet, but it seems this issue can be solved by creating different scheme for each test target.
I had this error a lot this afternoon but it hasn't happened for awhile after I created separate schemes for different test targets.

Just for anyone that might run into this issue like I have:
KIFTester loaded
Assertion failure in -[SenTestClassEnumerator init], /SourceCache/OCUnit/OCUnit-5315/SourceCode/SenTestingKit/SenTestClassEnumerator.m:136
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'objc_getClassList returned more classes than it should have.'
The problem turned out to be GoogleAnalytics 3.0
Updated to 3.0.3 but still the same problem with either of these libraries
libGoogleAnalytics_debug.a
libGoogleAnalyticsServices.a
To go around it I just don't include them for testing.

Related

cannot install iOS app: "A valid provisioning profile for this executable was not found."

I'm trying to build and install an iOS app to my iPhone after ejecting to bare workflow from an expo managed project.
I'm getting "A valid provisioning profile for this executable was not found."
I ran expo eject
I attached my iPhone 12 to the Mac mini M1 via USB and trusted it
I opened myproject.xcworkspace with Xcode 12.5
The signing certificate and provisioning profile were generated by expo
I cannot use "Automatically manage signing" because the account holder of the app is of type individual (not business), which means my apple developer account does not have access to certificates, identifiers and profiles (even though I am an Admin in the account holder's team).
So I downloaded the certificate and provisioning profile from expo and set it manually in Xcode
I also imported the private key of the signing cert to my keychain
Xcode is happy and builds, the error appears at the very end after copying the app to the phone
Then I also registered my device (iPhone) in the apple developer account of the account holder
Don't know what else I could do. Any help appreciated.
Error:
Unable to install "myproject"
Domain: com.apple.dt.MobileDeviceErrorDomain
Code: -402620395
--
A valid provisioning profile for this executable was not found.
Domain: com.apple.dt.MobileDeviceErrorDomain
Code: -402620395
User Info: {
DVTRadarComponentKey = 487925;
MobileDeviceErrorCode = "(0xE8008015)";
"com.apple.dtdevicekit.stacktrace" = (
0 DTDeviceKitBase 0x000000012c2b5e98 DTDKCreateNSErrorFromAMDErrorCode + 272
1 DTDeviceKitBase 0x000000012c2f1898 __90-[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]_block_invoke + 160
2 DVTFoundation 0x000000010067f644 DVTInvokeWithStrongOwnership + 76
3 DTDeviceKitBase 0x000000012c2f15e4 -[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1316
4 IDEiOSSupportCore 0x000000012c1b3d40 __118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]_block_invoke.294 + 2928
5 DVTFoundation 0x00000001007a8814 __DVT_CALLING_CLIENT_BLOCK__ + 16
6 DVTFoundation 0x00000001007aa238 __DVTDispatchAsync_block_invoke + 680
7 libdispatch.dylib 0x0000000196dc60f8 _dispatch_call_block_and_release + 32
8 libdispatch.dylib 0x0000000196dc7e90 _dispatch_client_callout + 20
9 libdispatch.dylib 0x0000000196dcf678 _dispatch_lane_serial_drain + 620
10 libdispatch.dylib 0x0000000196dd0274 _dispatch_lane_invoke + 404
11 libdispatch.dylib 0x0000000196ddab44 _dispatch_workloop_worker_thread + 764
12 libsystem_pthread.dylib 0x0000000196f72ff8 _pthread_wqthread + 276
13 libsystem_pthread.dylib 0x0000000196f71d30 start_wqthread + 8
);
}
--
System Information
macOS Version 11.3.1 (Build 20E241)
Xcode 12.5 (18205) (Build 12E262)
Timestamp: 2021-05-21T17:24:28+02:00

I can't open an iPhone simulator. The Android version works fine

The console looks like this:
Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
Running pod install... 29,8s
Running Xcode build...
Xcode build done. 330,1s
Configuring the default Firebase app...
6.33.0 - [Firebase/Core][I-COR000004] App with name __FIRAPP_DEFAULT does not exist.
6.33.0 - [Firebase/Core][I-COR000012] Could not locate configuration file: 'GoogleService-Info.plist'.
*** First throw call stack:
(
0 CoreFoundation 0x00007fff2041daf2 __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff20177e78 objc_exception_throw + 48
2 CoreFoundation 0x00007fff2041d9d0 -[NSException initWithCoder:] + 0
3 Runner 0x0000000103bf2c42 +[FIRApp configure] + 130
4 Runner 0x0000000103c4a603 -[FLTFirebaseAdMobPlugin init] + 259
5 Runner 0x0000000103c4a356 +[FLTFirebaseAdMobPlugin registerWithRegistrar:] + 70
6 Runner 0x0000000103bf2673 +[GeneratedPluginRegistrant registerWithRegistry:] + 115
7 Runner
Well, the error message specifically says that it can't locate the Google service json file.
Make sure you follow the instructions properly and just a tip for ios, drag and drop the Google service json file doesn't work like Android.
You should drag and drop the Google service json file through xcode and add it to ios application directory.

How to resolve unit test crash when code coverage is enabled on Xcode 11.4

We are getting a crash after excuting all unit tests when code coverage is enabled. Please find the stack trace below
Crashed Thread: 0 ReceiverMainThread Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: EXC_I386_GPFLT
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [41136]
Application Specific Information:
CoreSimulator 704.12 - Device: iPad Pro (12.9-inch) (3rd generation) (C0064E72-B310-4A5B-82BE-BCC12D3E4D46) - Runtime: iOS 13.4 (17E255) - DeviceType: iPad Pro (12.9-inch) (3rd generation)
Thread 0 Crashed:: ReceiverMainThread Dispatch queue: com.apple.main-thread
0 com.ios.Dev 0x000000010ea6f368 initializeValueProfRuntimeRecord + 56
1 com.ios.Dev 0x000000010ea733aa writeOneValueProfData + 170
2 com.ios.Dev 0x000000010ea7323b lprofWriteDataImpl + 683
3 com.ios.Dev 0x000000010ea72f7d lprofWriteData + 109
4 com.ios.Dev 0x000000010ea7151a writeFile + 714
5 com.ios.Dev 0x000000010ea7118f __llvm_profile_write_file + 1007
6 libsystem_c.dylib 0x00007fff51a65a38 __cxa_finalize_ranges + 326
7 libsystem_c.dylib 0x00007fff51a65d56 exit + 48
8 com.apple.dt.XCTest 0x00000001124ea721 _XCTestMain + 2709
9 libXCTestBundleInject.dylib 0x000000011138abfa __RunTests_block_invoke_2 + 13
10 com.apple.CoreFoundation 0x00007fff23da1a9c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
11 com.apple.CoreFoundation 0x00007fff23da1193 __CFRunLoopDoBlocks + 195
12 com.apple.CoreFoundation 0x00007fff23d9bf83 __CFRunLoopRun + 995
13 com.apple.CoreFoundation 0x00007fff23d9b884 CFRunLoopRunSpecific + 404
14 com.apple.GeoServices 0x00007fff38b5ac1a GSEventRunModal + 139
15 com.apple.UIKitCore 0x00007fff48c19220 UIApplicationMain + 1605
16 com.ios.Dev 0x000000010e7be223 main + 430 (main.m:125)
17 libdyld.dylib 0x00007fff519b910d start + 1
This crash is only happening on XCode 11.4, if code coverage is enabled. If code coverage is disabled it works fine, but we want the code coverage after executing unit tests. In Xcode 11.3 unit tests were executing fine with the code coverage enabled. Could any one please let us know the solution for this issue. Thanks in advance.
Edit:Resolution
For us changing the Macho-O-Type of one of the dependencies from Relocatable Object File to Static Library solved the issue. But not sure if this is the only cause for this issue as there might be multiple reasons.
I have exactly the same issue, and I'm still suffering in the Xcode 11.4.1.
I saw also you #Arjuna posting in the Apple developer forum:
https://forums.developer.apple.com/thread/131988
I didn't find any solution so far, but I think that this is related to the features introduced in the Xcode 11.4
https://developer.apple.com/documentation/xcode_release_notes/xcode_11_4_release_notes
Following the Releases Notes we have:
When building a scheme that has been converted to use test plans and whose active test plan has code coverage enabled, Xcode now includes code coverage instrumentation when building for the ‘Run’ action, in addition to the ‘Test’ action. This matches the behavior of building schemes which don’t use test plans and have code coverage enabled, and avoids unnecessary rebuilds when alternating between running and testing actions. (57367856)
I'm pretty sure that somehow is related to this, but I'm still no able to find a way to fix it.
try to disable code coverage. it helps in my case
Try with disabled main thread checker

iPhone App recently uploaded to App Store crashes on launch

I uploaded the new version of my iPhone App into the App Store. And it got released last day. The problem is App is crashing on the very launch. I got the crash log as follows. Any help will be really appreciable.
Here is my crash log,
Incident Identifier: 7868F4D2-C13E-4D97-995F-A69F85022F8C
CrashReporter Key: 113c3b5b073754be0c5c2b9758ca6b6d2afa09e6
Hardware Model: iPhone3,1
Process: Ph_PDF [623]
Path: /var/mobile/Applications/85E5F394-9006-431D-8F40-4780112F0343/Ph_PDF.app/Ph_PDF
Identifier: Ph_PDF
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2012-11-05 11:13:04.916 +0530
OS Version: iPhone OS 5.0 (9A334)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x96f6c04c
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x37ff9fbc objc_msgSend + 16
1 Ph_PDF 0x000178ae 0x1000 + 92334
2 UIKit 0x32e2c7e4 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1180
3 UIKit 0x32e263b6 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 390
4 UIKit 0x32df491a -[UIApplication handleEvent:withNewEvent:] + 1010
5 UIKit 0x32df43b8 -[UIApplication sendEvent:] + 48
6 UIKit 0x32df3d26 _UIApplicationHandleEvent + 5802
7 GraphicsServices 0x339dfe0c PurpleEventCallback + 876
8 CoreFoundation 0x30e2e54c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
9 CoreFoundation 0x30e2e4ee __CFRunLoopDoSource1 + 134
10 CoreFoundation 0x30e2d33c __CFRunLoopRun + 1364
11 CoreFoundation 0x30db04d6 CFRunLoopRunSpecific + 294
12 CoreFoundation 0x30db039e CFRunLoopRunInMode + 98
13 UIKit 0x32e25450 -[UIApplication _run] + 544
14 UIKit 0x32e2273c UIApplicationMain + 1084
15 Ph_PDF 0x0000250c 0x1000 + 5388
16 Ph_PDF 0x000024c0 0x1000 + 5312
this is objc_msgSend, you are calling method on object that doesn't respond to respective selector...
maybe deprecated method that is no longer included in SDK or specified iOS version, maybe you forgot to link against specific library for release version?
Have you tested your app against all iOS versions that your app claims to support?
Would you be using Core Data by any chance and modified your Core Data entity structure?
If you can provide some insight on what sort of technology your app uses and also what you changed since last working version on the app store, that would help.
The png crush may cause the app to crash in some situations. Thats because when the app is not able to get the image correctly for displaying, it will crash. I think in your case, the app is crashing on the startup. Please check your splash screen image first.
At last i found out the problem. As i was migrated to the new XCode i updated the Google Analytics Library to the new version which needs to support the armv7s architecture. It works fine in the new XCode. But i uploaded the binary from the old Mac which have XCode 3.2.5. When i am building it gives no error. But when the app is working in the device it crashes. I reverted the google analytics library to the older version and the problem got solved.
Thanks for your support guys..:)

Xcode 4.2 crashes in archive when "validate" or "submit" are pressed

i put together a program. It works and was tested.
for the last 24 hours i was googling/trying to get it up to be validated.
Someone please do a walkthrough the settings so i can set the right checkmarks and submit it.
I have xcode 4.2, iOS lion.
ERROR MESSAGE
Xcode encountered an internal logic error. Choose "Continue" to continue running Xcode in an inconsistent state. Choose "Crash" to halt Xcode and file a bug with Crash Reporter. Choosing "Crash" will result in the loss of all unsaved data.
ERROR DETAILS
UNCAUGHT EXCEPTION (NSInvalidArgumentException): -[ITunesSoftwareApplicationDescription applicationType]: unrecognized selector sent to instance 0x402818c00
UserInfo: (null)
Hints: None
Backtrace:
0 0x00007fff9134426a __exceptionPreprocess (in CoreFoundation)
1 0x00007fff89b73d5e objc_exception_throw (in libobjc.A.dylib)
2 0x00007fff913d04ce -[NSObject doesNotRecognizeSelector:] (in CoreFoundation)
3 0x00007fff91331133 __forwarding__ (in CoreFoundation)
4 0x00007fff91330f48 _CF_forwarding_prep_0 (in CoreFoundation)
5 0x000000011114ec9b __block_global_8 (in IDEArchivedApplicationsViewer)
6 0x00007fff9136ded2 __NSArrayChunkIterate (in CoreFoundation)
7 0x00007fff913c9491 ____NSArrayGetIndexesPassingTest_block_invoke_1 (in CoreFoundation)
8 0x00007fff92054467 _dispatch_apply_serial (in libdispatch.dylib)
9 0x00007fff920529d7 _dispatch_sync_f_invoke (in libdispatch.dylib)
10 0x00007fff92054347 dispatch_apply_f (in libdispatch.dylib)
11 0x00007fff92054697 _dispatch_apply_slow (in libdispatch.dylib)
12 0x00007fff9133f2d2 __NSArrayGetIndexesPassingTest (in CoreFoundation)
13 0x000000011114eaee __50-[AAVFetchApplicationListAssistant viewDidInstall]_block_invoke_0 (in IDEArchivedApplicationsViewer)
14 0x00007fff920508ba _dispatch_call_block_and_release (in libdispatch.dylib)
15 0x00007fff92051799 _dispatch_worker_thread2 (in libdispatch.dylib)
16 0x00007fff892183da _pthread_wqthread (in libsystem_c.dylib)
17 0x00007fff89219b85 start_wqthread (in libsystem_c.dylib)
It looks like it's your XCode, not your built app that is causing the crash.
My best advise would be checking for XCode upgrades, or maybe do a clean install. It's quickly pulled from the OSX AppStore.
To uninstall Xcode you can run the following command :
sudo /Developer/Library/uninstall-devtools –mode=all