EarlGrey launches APP with black screen - ios

After successfully adding EarlGrey to existing project (using CocoaPods) project is successfully built (both "for running" and "for testing"). The problem is that if I run the app from XCode it runs as expected. If I run it as a test only splash screen appears and then whole screen turns black. Have anyone encountered such issue? What might be a problem here?
There is somewhat similar question Black screen with EarlGrey but author did not share his solution.
Additional info:
XCode 8
CocoaPods 1.2.1
EarlGrey 1.9.3

I followed #khandpur advice and tried debugging my app first. So I found out, that in main.m file we're checking if current run is a test run, by
BOOL areWeRunningTests = NSClassFromString(#"XCTestCase") != nil;
Based on that we are running app differently.
To everyone in similar situation: I've added a check
BOOL areWeRunningUITests = NSClassFromString(#"EarlGreyImpl") != nil;
and if that's true app is starting normally.
Final comments - you have to know your app a little to be able to use EarlGrey easily... :)

Related

Xcode 11 XCUITest Failed to get matching snapshots: Error getting main window kAXErrorServerNotFound

After building my app in Xcode 11 and running my suite of XCUITests I am getting many random failures with the following.
Failed to get matching snapshots: Error getting main window kAXErrorServerNotFound
No matter how long I increase timeouts the issues pop up intermittently. It seems to be having issues Snapshotting the UI hierarchy. Our tests pass consistently in Xcode 10.
I have reinstalled Xcode. Deleted all simulators. Cleared derived data. Modified timeouts. Upgraded from Xcode 11.1 to Xcode 11.2.1.
Thanks!
 
I had the problem with matching while I was running the simple UITest in Xcode 11.3. To make it work I had to paste at first: XCUIApplication().activate() or XCUIApplication().launch().
I have experienced the same issue with Xcode 11 and realized that the test runner was not getting killed when stopping the tests (or if the test crashed for some reason). Running the tests a second time would spawn a new test runner and at that point I had two runners trying to interact with the same application, leading to this very strange error.
To prove that I did the following:
Created a UI test that types a long text in a text view
Ran the test, and manually stopped it when there were a few sentences in the text view
Manually opened the app in the simulator (not by running the test)
Observed that random characters were appearing in the text view, even though no tests were running.
The workaround was to quit and reopen the simulator to make sure all processes were getting killed.
Hope this solves your issues
I meet the issue from time to time in Xcode 11.1. I observed that the issue happen when waiting for UI elements especially there are web view being shown during the test. When the issue happened I was using XCUIElement.waitForExistence(timeout:) or expectation with NSPredicate(format: "exists == true"). When I changed to use expectation with NSPredicate(format: "hittable == true") the issue seems to be gone but I don't know why. The difference between the 2 attributes is that hittable only detect onscreen elements while exists detect off-screen elements such as off-screen cells of a table view.
expectation(for: NSPredicate(format: "hittable == true"), evaluateWith: element, handler: nil)
waitForExpectations(timeout: 60, handler: nil)
I use different machines. My older Macs experience this error far more often. My guess is older macs do not have the memory required to run certain XCUITests correctly.
I had a similar issue on Xcode 11.
It turned out that before it was allowed to have the same accessibility identifier in many page.
But now using the new modal presentation style, you should use different identifiers within your pages to avoid conflicts.
If you are using fastlane it can be solve easily with the following lane:
# Unit tests
lane :tests do
clear_derived_data
scan(
workspace: "AppTest.xcworkspace",
devices: ["iPhone 8"], # it can be with the iPhone that has your VM
force_quit_simulator: true,
reset_simulator: true,
reinstall_app: true,
scheme: "AppTest"
)
end
In theory, you must reset your simulator and reinstall your app.
Happy coding

IOS 11 breaks (ionic) app

I recently updated my IOS to 11 beta 3, to make sure my ionic app would still work.
However it crashes almost right away with a black screen when I launch it.
I try to debug it with Xcode, however when I build to run it on my iPhone and catch the error, the "running on device" gets stuck on the following :
What can I do with this? I'm stuck with an app doomed to die once ios11 gets released, anyone could help?
The problem is normally caused due to wk web view plugin. Try removing the plugin and run again

Apple Watch screen stays blank telerik

I use Telerik-AppleWatch plugin for cordova.
i followed the instructions and i copied the simplified example from the project.
when i run the project the Built successfully but on the iwatch i see just the name of the app and blank screen.
I didn't receive error on the console.
i use xcode. target is- 8.2
There is not much information on the internet about it
function initAppleWatch() {
applewatch.init(function () {
alert("init");
onAppRequestsUpdate();
onGlanceRequestsUpdate();
});
applewatch.callback.onLoadAppMainRequest = onAppRequestsUpdate;
applewatch.callback.onLoadGlanceRequest = onGlanceRequestsUpdate;
}
can anybody know what can i do?
I work on it all week without success
thanks!:)

App crashes before debugger can connect

I've got an app that crashes even before the debugger can connect.
I placed a break point on the first line of main(). (I added an NSLog statement as very first statement in main() and set the break point there.
The app seems to start. The main screen with some ui elements becomes visible on the screen. Then it disappears.
There is no crash log found on the devices.
Xcode message:
Could not launch "appname"
process launch failed: failed to get the task for process xyz
Debugging is enabled of course.
The same for the profiler Instruments.
Code signing works fine so that the app can be deployed to the devices.
(Same for enterprise distribution. And the app validates for store submission.)
It does work on the simulator though.
The app used to work fine. I was just about to build it for the store. For final tests on iOS 8.1 I upgraded to Xcode 6.1 with SDK 8.1. But the problem did not occur directly after the upgrade. It worked just fine.
Then it crashed when building for release for enterprise distribution.
The AppStore build crashed in the same manner (according to Apple, the app was rejected of course.)
But it ran nicely in debug modes.
Now I was trying whether compiler options for optimization may make all the difference and I was trying to build in release mode with debugging enabled etc and end up with a debug build crashing as well. (No optimization in debug).
So it may well be that the migration to Xcode 6.1 did cause it but the problem may have come effective only after Xcode cleaned and rebuild the project in response to changes to compiler settings for code optimization.
Sorry for the long text. I tried to put everything in that may be of importance.
Reason is most likely some incompatibility of Crackify and iOS 8.1.
Therefore it may be of interest for others, altough my problem along with these symptoms may be very special.
Very early within AppDelegate didFinishLaunchingWithOptions we have had the following statement.
if ([Crackify isCracked] || [self isCertificateUnvalid])
exit(173);
That, as such, is not really well designed. The app is just terminated rather than any error message displayed to the user. Thus, it appears as if the app has crashed. But it has not crashed and therefore no crashlog is provided.
For reasons which I don't yet understand and which may not be related to this error, my debugger did not manage to hook up into the executed app. Once that was overcome (suddenly the debugger worked without any changes made to any of the debugging related settings) the error was found rather quickly.
This is Crackify: https://github.com/itruf/crackify
Within Crackify it was this code sniplet that caused the problem:
static NSString *str2 = #"ResourceRules.plist";
BOOL fileExists3 = [manager fileExistsAtPath:([NSString stringWithFormat:#"%#/%#", bundlePath, str2])];
if (!fileExists3) {
return YES;
}
For reasons that I did not further investigate, the file, that is tested here, apparently does not exist in iOS 8.1 any more.

Phonegap 1.2 + xcode 4 = EXC_BAD_ACCESS on keyboard input?

Im not a "high level" programmer. I do not understand all this stuff really which is why I'm using phonegap instead of native programming. I'm doing nothing special. The "page" loads, there is an input box, you click it, keyboard pops up. Letters seem to work OK but as soon as you push a # or back space the whole app crashes with EXC_BAD_ACCESS.
This is in a 4.3 emulator. I do not have a device handy to try.
All the searching I've done are people talking about memory management and what not. I'm not doing any of that, nor would I have idea on how to.
Anyone know why this is happening?
Here is the offending line:
int retVal = UIApplicationMain(argc, argv, nil, #"AppDelegate");
Which is located insde Supporting Files > main.m > main()
^^-- I did not create that file. I'm not sure if phonegap created it or if it was created by xcode.
It turns out the problem WAS the fact that I was testing my code on a 4.3 SIMULATOR on an OSX LION virutal machine running on a win7 host.
I brought my code in to work the next day, hopped on one of the macs, installed xcode and ran the identical code on the simulator AND my coworkers iphone and the problem did not show up, at all!

Resources