I'm using iOS SpriteKit and Socket.io to create a simple multiplayer game, what is a elegant way to build and test it on multiple simulator (or actual iOS devices) and be able to see logs?
I see some post like this one Xcode6: Run two instances of the simulator which you can run two simulator, but I will have to run it on one simulator, stop it and start the second one. In this way it's making testing complicated and I'm not able to see logs of the first simulator.
Is there a better solution?
The best methods to use would be to install it on a device (or multiple) and let them run without having to see the logs immediately. Then you could run the simulator or a device directly from Xcode.
If you want access to the logs afterwards, there are ways to get them from the devices. You could take a look at https://developer.apple.com/library/content/qa/qa1747/_index.html for more resources.
Another method would be to copy the repository onto either a virtual machine or another Mac and run that at the same time as your computer. Then you could access both logs. Of course, it's not quite that quick to set up a virtual machine and not that common to just have a second Mac lying around.
Xcode9 will support running multiple simulator at same time.
Related
I am aware of how to download an app container of a connected iOS device (not a simulator device) using the Xcode UI (via the Devices and Simulators view). I am curious if there is a way to download a container using one of the Xcode command line tools.
I did see a previous question with an answer that references a GitHub tool, ios-deploy, that may be able to perform this task , but I was looking for a native solution to use first.
Thanks a.masri for the suggestion. I ended up going with ios-deploy. It suited my needs and is actively maintained. It seems that mobile device is somewhat stale.
Does anyone have any idea how to access files in the mac from a device when the device is connected to the computer via USB?
This is the scenario so far.
We need to run some acceptance tests on device, and to save time, the tests are going to be run using mocktail. And since we have a couple thousand tail files, we can't bundle them and copy it out to the device (it's not practical, and probably bad practise anyways), so, we store the mocktail file in the project directory and not include them in the app.
This works great from simulator, given that the simulator is run on the mac, and it can access the files properly. However, when we tried to run the same tests in the device, it crapped out because it can not find the appropriate tail file (which makes sense). So far, I couldn't find anything to do this programmatically from Xcode.
Is there any way that one can access files in the computer from a device connected to it via USB programmatically in Objective-C?
Thank you very much in advance.
iOS devices do not have the proper drivers to pose as a USB host. You will have to bundle your files as resources in your app, or download them over the air.
AirDrop lets you share photos, documents, URLs, and other types of data with nearby devices. AirDrop takes advantage of peer-to-peer networking to find nearby devices and connect to them:
- Sending Files and Data to Another App.
- Receiving Files and Data Sent to Your App.
I downloaded the iOS SDK for the Linea Pro device from their website and have successfully implemented some of it in my App - but I noticed the device never seems to work while its connected to the Mac via the USB cable. I've verified this 100% because as soon as I disconnect the LineaPro sled from the USB cable and run their Apps, it finds the Scanner and works. Otherwise, nothing.
This of course makes debugging near impossible because if you're not connected to Xcode you obviously can't see any output the App may have in Xcode's Console. You can't NSLog anything to the console, you can't put Breakpoints, you can't step-through your code - you pretty much can't do any of the things you'd normally do when developing an App.
I've actually had to resort to creating UITextViews and outputting everything I can to them during runtime ( which of course clutters up the interface big time) but even with that, if the App crashes, you never get to see your TextViews: you're thrown out and back to the iOS home screen, staring at all your little icons.
I've got some other ideas regarding work-arounds - but that's just it: they're all work-arounds. Does anyone out there know if there's any way to use the Linea Pro while its still connected to Xcode?
I don't think this is possible. For some reason lightning devices and USB don't seem to work together well.
I would suggest a combination of https://github.com/fpillet/NSLogger for logging and https://github.com/Shopify/superdb for sending messages to your app. You won't get breakpoints but you will have a few more tools at your disposal.
If you are using a device running iOS11 and you are using XCode 9, you no longer need to connect via lightning cable to debug your runtime build. XCode 9 introduced wireless debugging via a network connection:
Wireless Device Pairing Apple Documentation
Facing the same problem. I've resorted to using UIAlertViews instead of UITextFields to log messages on screen, but still its a huge pain the the buttocks.
You can also fire up a local server and hit it via localhost:8001?logmessage=myLogMessageWhichCanBeVeryVeryLong
and just print these GET requests to the terminal. Not pretty at all but its a workaround that could be of use if you want to get real creative...
Usually if you have a bug or error in your code it's going to be YOUR code, not the actual scanner or scanner input. So what I do while the app is in testing mode, is to have a button or other UIcontrol wired up to run an action AS IF there was scanner input, and I'll provide a mock string of input in a string (different inputs by incrementing a counter if needed). That way I can test away in the debugger for as long as necessary. Once my code works for me & I'm satisfied, I paste the same code into the scanner function and make the switch to the actual scanner. A little pain but not a big deal.
Have any of you ever ran into issues where the changes you've made are only being reflected on the simulator and not on the device?
Example, if i want to set the selected background image view for a table cell, the selection state in the simulator will show the changes but not on the device during testing.
This inconsistency is starting to worry me because when it's time to deploy to production, how do i know that the apps in the app store will work correctly?
Thanks
Have any of you ever ran into issues where the changes you've made are only being reflected on the simulator and not on the device?
Yes, this has happened to me many times.
This inconsistency is starting to worry me because when it's time to deploy to production, how do i know that the apps in the app store will work correctly?
When I first started developing for iPhone, I once had to rewrite a significant portion of code because while it worked perfectly in the Simulator, it did not work properly on the iPhone. I realized then that the Simulator is not an Emulator, that is, it does not replicate an iPhone exactly.
You need to test on an iOS device frequently to ensure that your code is working properly. That is what the App Store reviewers will be using and what your users will be using, not the Simulator.
During your daily development, you can use the Simulator and also your fastest device, like the 5th gen iPod Touch and iPhone 5. Periodically and towards the end of your development, it is good to test on older, slower, more memory limited devices, especially the oldest available that will run the iOS version that you are targeting.
The best thing you can do when this happens is to uninstall the app your're developing, (extra measure) restart the device to clean any app caches, and finally do a clean build from XCode. Things like this tend to happen to me frequently and uninstalling my app followed by a clean build seems to do the trick all the time.
Inconsistencies happen, that's why you need to test on actual devices (and why it's a simulator, not an emulator). In this case, it's most likely being caused by XCode failing to properly update the program, in particular the nibs. Delete your app from the phone and reinstall it fresh. The app store and iTunes use a different method of installation, so you shouldn't have to worry about it in the store.
I've created a simple javascript for my iOS app that I'd like to run simultaneously on multiple iOSDevices connected via USB to one host Mac machine. Launching instruments connected to an iPhone from the command line works fine but if I attempt to launch a second instruments connected to an iPad, the first instruments session hangs.
Upon terminating the first instruments session, I get one of more of the following lines printed:
Stopped: Script stopped due to device being disconnected
After extensive research on the subject, with no results on the phrase, I've been trying to read into what is meant by Apple's Instruments Guide:
When you choose All Processes, Attach to Process, or Choose Target from the Target menu, Instruments sets the default target for all instruments to the program you choose. There are occasions, however, when you might want to set a different target for each instrument. You might want to sample two different programs at the same time, for example, using the Sampler instrument. If you have some instruments that are capable of tracing all processes, you might want them to do just that while single-process instruments sample just one process.
I'm wondering if the Automation.tracetemplate is a single-process only instrument and that if another process is started with the same Automation trace then the first is usurped.
Any advice would be grateful as this is a major block for running our time intensive automation tests over multiple iOSDevices.
Update 27 Mar 2012
The following is from an email received after submitting a bug to Apple on the matter (developer.apple.com/bugreporter):
I heard back from a UI Automation engineer. UI Automation is a single process Instrument. As such, you cannot use it simultaneously on multiple devices.
You could try installing OS X in a virtual machine, and having two instances of the virtual machine running simultaneously. I know that might not be what you are looking for, but it should work.
Try to connect all your devices to a Mac OS X server then try if that fails get the device to pass it to the other one and then pass to the mac
You cannot run UI Automation simultaneously on multiple devices. Interestingly, even Xcode 5 bots seem to have this same limitation. :-/