Connect iOS Device to Mac and Log App Errors - ios

Goal:
Connect iOS device (physical device) to macbook
Use Appium / IntelliJ / or any other software to capture app errors from the device
I run automation tests using simulated devices, however, it's proving to not be as affective as manual testing for I'm getting different results. What I want is to simply connect my device to my macbook, run something to log app errors as I interact with my test device.
My current set up to run automated tests:
Appium
IntelliJ - Using simulated devices (No longer wanting to do)

To view what's going on in the device, you'll need to use Xcode. The easiest way to obtain that is to use the Mac App Store application.
If you're able to build your app there is a lot more debugging you can do, but I'm assuming you're not able to do that based on what you've written and won't provide instruction on that.
Attach device
Launch Xcode
Click Window menu
Click Devices and Simulators
Unlock device
Click Open Console if you're looking to see live activity of the system (this is very noisy and unlikely to be of much use) or View Device Logs to see any crash reports.

Related

How do I run/test my Flutter app on a real device?

I want to run/test (not automated test) my Flutter app on a real iPhone and Android phone during development. However, Flutter docs seem to only document how to do it with the iOS simulator or Android emulators.
I think it's already a no-brainer for iOS/Android devs but I am neither and Flutter is my first foray into mobile development.
Is there any link to a beginner's guide somewhere on how to develop while running it on a real device (with all of Flutter's live-reload goodness)?
Additional context
I'm a web developer.
I use Android Studio and VS Code.
I work on a MacBook.
For Android, this is pretty easy:
Enable Developer options and USB debugging on your device. This varies slightly by Android version, but the short version is you tap on the Device Build Number 7 times. Then a "Developer Options" option comes up and you can click "enable USB Debugging." See the linked Android documentation for the most up-to-date instructions.
Then plug your phone into your computer with a USB cable. You'll probably see some popup on your phone asking if you want to allow USB debuggng with that computer. Say "yes".
Run Flutter just like you would if you had a simulator running.
Using the right cable can make a difference. If the device is charging but nothing happens, try using another cable, preferably the one that came with the device. A notification on the device (e.g. "connected as a media device") and on Windows (e.g. "Device connected and ready to go") are indications that the USB connection is working. You should then be able to see the device on the CLI with:
flutter devices
For iOS this is a little more complicated because you need an Apple ID or to sign up for a "Developer Account":
Open XCode, then open "Preferences>Accounts". Sign in with your ID.
"Manage Certificates" > click on the "+" sign and select "iOS Development".
Plug your device into your machine. Find your device in the drop down (Window > Organizer).
Below the Team pop-up menu, click Fix Issue.
In Xcode, click the Run button.
(in subsequent runs, you can deploy to the iOS device with Android Studio, VS Code, or any other IDE of choice, you just need to set up that certificate the first time with Xcode. Here's Apple's documentation on setting up Xcode to run a physical device.)
Also, you can use your android device wirelessly using scrcpy.
Visit this link and install scrcpy. https://github.com/Genymobile/scrcpy
After you install and path scrcpy on your PC/Laptop.
Make sure your phone is connected to your PC/Laptop.
Enable Developers Options and Connect your device to the WIFI.
Open CMD.
Input "adb tcpip 5555". The adb should be restarted
Next, input "adb connect ipaddressofyourdevice:5555"
Ex: adb connect 192.168.254.19:5555
Now, you can use your device wirelessly.
Attach your real device on your development PC. To check setup process, run flutter doctor command. If result success of all required criteria then hit
flutter run

The iOS Simulator is a Virtual Machine or a Emulator?

The iOS simulador that installs with Xcode is a VM or a emulator like Android does?
It's neither a Virtual Machine nor an Emulator. It's a simulator, in another words it's a standard mac application which mimic the behaviour of iOS devices. It mimics most of the features of an actual devices, but lacks some major features. So you need to use a real device for testing some of the real world scenarios.
You can read more about simulators here : About Simulator
I would like to quote some key information from the above linked page:
What is Simulator
Simulator allows you to rapidly prototype and test builds of your app
during the development process. Installed as part of the Xcode tools,
Simulator runs on your Mac and behaves like a standard Mac app while
simulating an iPhone, iPad, Apple Watch, or Apple TV environment.
Think of the simulator as a preliminary testing tool to use before
testing your app on an actual device.
Need of actual device for Testing
Simulator is a useful tool, but it should not be the only way you test
an app. Because the simulator is an app running on a Mac, it has
access to the computer’s resources, including the CPU, memory, and
network connection. All of these resources are likely to be faster
than those found on a mobile device. As a result, the simulator is not
an accurate test of an app’s performance, memory usage, and networking
speed. For this same reason, always test the performance of your app’s
user interface on a device. In Simulator, your app’s user interface
may appear to run both faster and smoother than on a device.
Also keep in mind that some user interface elements can be easier to
interact with in Simulator using a mouse than when trying to interact
with the app through touch on a device.
Finally, there are some hardware and API differences in Simulator.
These differences may affect your app when testing in Simulator.

How to transmit screen and control device via mac while running app in Xcode?

I'd like to test apps on device in the same way like on simulator - app runs on real device but I see screen on mac and I can interact with it using mouse. Im just tired of putting phone to my hand all the time. Developing on windows phone allows it, so It would be nice to have it here. Thank you
John Holdsworth on Remote Xcode plugin:
“Remote is a plugin for Xcode that allows you to control an iPhone
from a window on your Mac during development.”
I just found this. You can control device via mac.

Testing Apps on a Device

When using trigger.io toolkit, there's an option that says
"Build and immediately run your app, either locally, on a simulator or on a connected device."
How do you run the app on a Connected Device? I want to see the app on my iPhone and see how it behaves directly. Is this possible?
Thanks
Marc
I'm going to assume you're working on windows with an iPhone that's iOS8 because that's where you currently can't run your app directly on a connected device.
What we did to "fix" this is creating a Development Provisioning Profile with the UDID's of our test devices and added this to config -> tools in the trigger.io toolkit. In the forge you now select package -> iOS giving you a .ipa file. This .ipa can now be installed using iTunes on your test devices.
It's a bit longer than just clicking run on device like you can for Android but at least you don't have to send it to testflight and wait for apple's approval.
This is possible but it depends on your os.
If your on a Mac you can deploy to both ios and android devices from forge, just connect them via usb and build, grated you need to make sure iTunes sees your devices etc.. there are guides on the trigger site
If you are on Windows, you are unfortunate out of luck right now, this used to work but ios8 broke this so if your building on ios7 you could still do it on Windows, otherwise you would need to use testpiolet from apple

Specifying the device with lldb on ios

Let's imagine that I have 2 iPhones (or iPads) connected to my Mac and I have to automate a test calling the lldb and loading an app from the COMMAND LINE, not XCODE; so how can I specify which device it should use? Maybe some kind of extra param when calling platform select remote-ios?
lldb does not know how to load apps onto an iOS device, or to start up connections to the debug agent on an iOS device. That bit is done by Xcode, and then the connections are handed off to lldb. Xcode has a fair bit of support for automating test cases for iOS debugging. That's the only supported way to do this at present.

Resources