UIAutomation script not running on device - ios

For some reason, UIAutomation doesn't want to run on my physical device. I've gotten to run once, but otherwise when I kick it off, it simply sits there reporting "Script has stopped".
I've checked the following:
Using a developer profile to code sign
Several different cables, including a first party Apple one
Restarting my Mac and the iPad
Cleaning and rebuilding
Other instruments work just fine, I can run allocations and leaks without any issue, automation just refuses to run.

I had the same problem and then (eventually) figured it out.
Turns out the build has to be a DEBUG build so that instruments can attach to it. I edited the scheme build settings for "build for profiling" so that it would build a DEBUG build rather than a RELEASE build and things started working.

Related

Xcode debug build vs release build

I am currently building a react native app using expo.
However, I needed to use cocoapods, which is why I am now using Xcode.
Since I have switched to Xcode, there has been a difference between my local debugging builds (that I run to a USB connected iPhone) vs the builds that get pushed to TestFlight.
After doing some digging I have found that it may be due to the debug vs release schemes in Xcode.
From what I've see it seems that the difference should really just be in performance, file sizes, and some other aspects, but not what the app actually does and displays like in my case.
To test, I made a change on my app's homepage to simply have the text, UPDATED.
As expected, when ran with the debug scheme, the UPDATED text shows up, but when ran with the release scheme, it does not.
How do I get these to sync up and have the release build recognize the changes I make as I am certain I do not want to push a debug build to the app store?
Things I have tried:
Removing/cleaning Build folder and rebuilding
Updating Xcode
Running on another device
Building/running with expo (this did something, but it just causes the app to crash, assuming it is because of the cocoapods)
Versions:
react-native: 0.61.5
Xcode: 11.4.1
macOS: 10.15.3
Thank you
I have fixed the issue.
I found that by running expo publish in the terminal and then building with the release archive scheme in Xcode, it notices the changes.
Now why that is required (maybe it isn't), I am unsure of.
If anyone has an any additional insight, it would be greatly appreciated.
EDIT: So it looks like when I run expo publish it updates the app.bundle and app.manifest. This must be what the release scheme looks at when building.

Xcode 9: Could not attach to pid

I've been facing an issue (frequently) with the recent major release of the iOS application development tool - Xcode 9-beta.
It's showing me the following error frequently while running/debugging app in Simulator (iOS 11).
Could not attach to pid : “2370”
Ensure <project title> is not already running, and <system username> has permission to debug it.
Here is a snapshot for the same issue:
What would be permanent solution of this issue, as it's disturbing frequently?
If issue is on OS Mojave and you are trying, like me to run tests on older Xcode version (lower than 10.0), make sure that in your scheme, when you select Test, Debug executable is disabled
You won't be able to debug tests from this point
Still not a permanent solution, but I had to quit and restart Xcode as the other solutions did not work for me.
This worked for me:
Edit Scheme -> Info -> Executable -> Ask on launch
Credits to #nastya-gorban's answer here
Update
After spending a considerable time with examples on Apple bug report, they basically disregarded the issue as using manual certificates is not "expected".
Long story short, if you don't have a business account and hence multiple developers on the same account, you should be fine with using the automatic signing and should not see the issue.
If you do have a business account with multiple users (which I found it breaks automatic signing), this is their suggestion:
We suggest that you use automatic signing for your debug builds and
manual signing for your distribution builds.
Killing my simulator and then running it again from Xcode.
I had this issue too. There seems to be an issue with having two Xcode version installed at the same time. (9.4.1 and 10.0 Beta)
It works with the beta, but not with the stable version. Everything is set to the tools of the Xcode 9.4.1 stable version. I can only run my unit tests with the beta.
After removing the beta, it worked with the stable version.
delete derived data and clean the project, wait until processing is complete, this may take some time. The idea is to give some processing time. Works fine after that
I have been dealing with this issue for days. I have been able to build but not launch on Simulator, and I get the same "pid:.." error message.
I am using:
- Xcode v9.2
- Swift 3.2
- Building for iOS
The things that I tried that DID NOT WORK were:
restarting the computer; deleting content and settings (of Simulator, I do not have "reset"); uninstalling and reinstalling Xcode; changing "Deployment Target"; changing the device in the simulator's Hardware->Manage Device; deleting Derived Data, Cleaning and Building, or just waiting...forever.
What WORKED was as #Rajasekhar mentioned:
checked out the Keychain certificates.
deleted the exiting ones by right clicking (they'd passed expiration)
and unchecked "automatically manage signing" in Targets->General
After that it successfully launched in Simulator. I don't know if the issue will come back but hopefully this works.
Even on Xcode 11.1/2/3
It is an Authorization issue with Simulator,
When Simulator does not have the necessary access. It raises the issue.
Try following in Terminal
sudo DevToolsSecurity -enable
or
sudo /usr/sbin/DevToolsSecurity -enable
Details can be found here
I hate to add more noise to this, but for me, the answer is to, nonsensically, use sudo.
Run normally, Xcode 9.4.1 (9F2000) and Xcode 10.0 beta 4 (10L213o) both failed to attach to my app after multiple tries, giving the error quoted in the original post.
What worked was to run Xcode (9.4) with sudo,
sudo /Applications/Xcode.app/Contents/MacOS/Xcode
I don't see why sudo is necessary. The Cocoa app to which I am attaching is a Debug build that I just built in Xcode 9.4.1 and dragged into /Applications. It is not codesigned. Posix permissions on the .app, its Contents, its MacOS, and the executable are all octal 755. Owner is me. It works fine if I leave it in the Build folder, build and debug in the normal way.
The problem is apparently with lldb. I also tried using lldb (lldb-902.0.79.7) from the command line. I got the same result. It works only with sudo. Without sudo,
error: attach failed: unable to attach
I had same issue. Check screenshot.
Below are few solutions that should work:
Rerun project
Clean (Shortcut: cmd + shift + K) and Rerun project
Quit Xcode and Simulator. Open project and run again
Reset content of Simulator (Select Simulator -> Goto Hardware tab -> Erase All Content and Settings…) and rerun project.
Solution 4 worked for me.
This seems to be a temporary issue when you are trying to build too fast after a build has started. Try stopping and running the project again.
(most likely solution) 1. Simulator-> Hardware-> Erase all contents and Settings
(less likely solution) 2. keychain-> upper right lock-> unlock and lock again (or the other way around)
I was seeing this in Xcode 10.2 and the cause for me was that lldb-rpc-server was crashing. I worked around it by ensuring either Address Sanitizer or Thread Sanitizer is enabled in the debug options. I also filed a bug report viewable on Open Radar.
I tried all the answers above. The only thing worked to me is changing the build number.
In my case (Xcode 10.1), this was the error in the console:
kernel macOSTaskPolicy: (com.apple.debugserver) may not get the taskport of (bin) (pid: 10132): (bin) is hardened, (bin) doesn't have get-task-allow, (com.apple.debugserver) is a declared debugger
So the solution was to disable the Hardened Runtime, clean the build folder and run again.
This is the issue with the untrusted certificates in key-chain access, please remove such a type of certificates and re-build again.
This happens on my machine, when I set the 'new build system'
Go to menu file=>workspace settings and set Build System to "Standard".
I realise this is not a problem with a single solution, from all the other answers. So, here's what worked for me:
1) Reboot the machine
2) The first run always works for me. The only thing that helps me avoid this error after this first run, is to stop the application from XCode, instead of just clicking the Run button to re-run the application.
Another thing, when I lock my computer the issue re-appears sometimes (probably when I forget to stop the application). So I have to reboot my machine again.
After doing some digging, this worked for me on Xcode 10.3.
sudo /usr/sbin/DevToolsSecurity -enable
In my case the only thing that worked was switching back from the "New Build System" to the "Legacy Build System" in the Workspace Settings. Bummer.
It's an issue with authorization. Try this in the Terminal:
sudo DevToolsSecurity -enable
First, close app completely via sim (not sleep - close app totally)
If not working yet: reboot whole PC, ensure only 1 simulator is active upon reboot.
More than 1 sim can confuse it if it's bugging.

Calabash-ios: Run test physical device installed ipa without xcodeproj

I am new with calabash-ios and have a dummy question is:
How possibly could I run a calabash test with real device which have installed ipa file (included calabash framework) and without xcodeproj?
Problem is I am doing QA and Dev only gives me ipa file to test without source code.
UPDATE:
I am able to run the ipa file in console and cucumber by adding BUNDLE_ID. And make sure the CFNetwork.framework is including in app framework to establish the connection.
But I got another problem to run the scenario:
1. When I run the command below:
DEVICE_ENDPOINT=http://192.168.1.9:37265 NO_LAUNCH=1 BUNDLE_ID=com.example.appname DEVICE_TARGET=UDID cucumber
Then I got this error:
A JSON text must at least contain two octets! (JSON::ParserError)
features/my_first.feature:8:in `Then I touch "LOG-IN/ CREATE ACCOUNT"'
all other steps was skipped
Then I run the console code
DEVICE_ENDPOINT=http://192.168.1.9:37265 NO_LAUNCH=1 BUNDLE_ID=com.example.appname DEVICE_TARGET=UDID calabash-ios console
Then I run server_version
I got reply back that said connection SUCCEED
But when I run start_test_server_in_background
It took me too long to wait and I see the app my physical device kept crashed and launch again and again until it stop as:
Unable to start. Make sure you've set APP_BUNDLE_PATH to a build supported by this simulator version
Calabash::Cucumber::Launcher::StartError: Calabash::Cucumber::Launcher::StartError:
"Timed out waiting for UIAutomation run-loop Error while writing to fifo. RunLoop::Fifo::NoReaderConfiguredError.
2015-10-01 10:49:41.634 instruments[15640:10558880] WebKit Threading Violation - initial use of WebKit from a secondary thread.
2015-10-01 10:49:42.574 instruments[15640:10558978] Attempting to change event horizon while disengage
2015-10-01 10:49:42.577 instruments[15640:10558877] Attempting to change event horizon while disengage
Instruments Trace Error : Target failed to run: Permission to debug app
Anyone can help please! I tried to search some solution but they almost issue on simulator and they contain xcodeproj. As a QA, I dont have the source code, only .ipa file. :(
Thanks
You should set 3 variables:
$ DEVICE_TARGET=<UDID> \
DEVICE_ENDPOINT=http://<ip>:37265 \
BUNDLE_ID=com.example.YourApp cucumber
The device and the host computer should be on the same network.
The .ipa must be installed on your device.
You can do this in Xcode by dragging-and-dropping in the Device Manager window or with a third-party tool like ideviceinstaller (available with homebrew).
You should never set NO_LAUNCH.
http://calabashapi.xamarin.com/ios/file.ENVIRONMENT_VARIABLES.html#label-NO_LAUNCH
You also need to enable you device for develop and turn on UIAutomation in the Settings.app > Developer.
Enabling device for development
RunLoop::Fifo::NoReaderConfiguredError
UPDATE In response to this question, I rewrote the Testing on Physical Devices Calabash iOS wiki page. Wow, that content was ancient!
As long as the file is build with calabash then that is not a problem. You just call cucumber with APP_BUNDLE_PATH to where ever your .ipa file is and should be all set.
But you should be aware that .ipa needs to be build to match the target you run the tests on.

Instrument crash at startup appium

Am trying to run appium tool for testing apps. While starting appium server i finished all setting right way. When appium running the app will start at time but suddently it get crash.
Yes.Am using Xcode 6.0 and Appium 1.3.4
Make sure the .app file you are using is build for simulator if you are running appium for simulator and a different build i.e the build for device if you want to run it into real device....This is one of the cause which causes the instruments to crash at start up.
When I create an new project with XCode then generate the app file, it is working fine - I can open the inspector.
But I have a problem when I use an already developed application and the build is coming from a developer profile : I can't open the inspector and instruments crash on startup.
While running the script please start xcode and go in the settings of the mobile device and find developer options. Make sure UIAutomation is enabled there. If it is not then enable it and after it try to run the script again. Surely it will work.

debugging xcode 4: says it's running application on device, but nothing actually happens

I can't debug my application on my device with xcode 4. The application builds, links and signs and installs on the device but when xcode 4 says "running on Dev iPad 2" nothing happens on the device.
I've quit and restarted xcode, and restarted the Mac. No difference.
The only warning it gives me is "warning: no debug symbols in executable (-arch armv7)". I'm not sure if that's related to my problem.
If I start the application manually on the device, it works.
I created a small test app. It compiled and ran on the device with no problem.
What could be causing this in my application?
I found this could be fixed by deleting the app from the device, and also deleting the provisioning profile from the device as well.
Check the name of your executable in Build Settings - specifically, make sure that Debug and Release versions have the same name. It may be trying to run an executable that isn't there.
Check the Build settings: Strip Linked Product. In my case I had to set this setting to No. After that the warning was gone.

Resources