Embedding a custom video in a XCUITest - ios

I'm writing a test that is supposed to test uploading a video file, using XCUITest in XCode 12. The test is supposed to be self-contained so I'm not certain how to exactly do this.
Typically I want the flow to work like this:
App builds
File is copied from the code folder (I've moved the video to be in the code) into the simulator
Tests run
However step 2 is giving me a ton of problems. I'm trying using this in a build phase:
xcrun simctl addmedia booted ~/code/resources/Video.mov
Bur it's currently giving a completely unspecified error. I'm not sure if this is because I'm trying to do it before the simulator is "booted" or if something else is going on. Does anyone have a solution?

I figured it out. The correct way to do this was to just use a . instead of ~ and then realize that:
. puts you at the project level (.xcproj)

Related

Xcode export localization throws error "Argument list too long"

I've got a very curious error to share regarding Xcode localization process. I will try to share as much detail as legally possible.
From Xcode, I am trying to export an XLIFF file to send to our translators, via "Editor > Export for Localizations". However, this immediately throws error with the message:
The operation couldn't be completed. Argument list too long
This is indeed confusing, as I cannot find a more verbose log anywhere (I have already tried checking my Console.app). So, I spent quite a few time googling – to no avail. I couldn't find similar case like this. The error itself happens only when I am trying to export for localization. I can build and run the app just fine.
Facts
~ $ xcodebuild -version
Xcode 8.2
Build version 8C38
~ $ xcode-select -version
xcode-select version 2347.
~ $ echo $PATH
/Users/david.christiandy/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/david.christiandy/arctools/arcanist/bin:/usr/local/go/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
I am using Xcode 8.2 on macOS Sierra 10.12.5.
The error happens only when I try exporting from localization. This is also true when I run the localization process via xcodebuild -exportLocalizations.
I can build and run the app just fine. (I believe) there's no problem with my header search paths.
Attempts
Thought there was something wrong in the code, so I tried to run the export process (via xcodebuild command) in a CI. Somehow, it's working. For the record, I am using Bitrise CI with the same stack as my system (Xcode 8.2.x, macOS 10.12)
Asked colleagues to run export process on their machines, and they have the same error.
This leads me to think that there must be something wrong with the configuration. So I made a standalone project to confirm that the export process fails consistently. Turns out, it works just fine!
So, the hypothesis I got currently is:
There's probably something wrong in the code, and
There might be tools/software (that most of our iOS engineers installed) that might contribute to the error (since the CI completes just fine).
I don't know why the CI can run the export process just fine, and I don't know when it might suddenly stop functioning (just like our local machines).
Appreciate any help on this matter. Thank you!
I also asked this question on Apple developer forums, here is the link: https://forums.developer.apple.com/thread/86762
“Argument list too long” sounds like E2BIG, which you get when you try to run a child process with a huge argument list (I believe the current limit is 256 KiB). I suspect that Export for Localizations is running some sort of command line tool to do that work (probably the extractLocStrings tool, which you’ll find lurking within Xcode’s app bundle) and passing it full paths to each of the files in your project. Depending on how many files you have and how long those paths are, it’s easy to run into problems like this.
One of the ‘fun’ things about bugs like this is that they are dependent on where you place your project. Things might work if the project is at the top of your home directory but fail if it’s nested deep inside a subdirectory.
That also suggests a potential workaround, namely, to move your project further up in the directory hierarchy.
Finally, you should definitely file a bug about this. I believe we’ve seen this before (r. 30703294) but your report will help reinforce that this is causing problems for developers in the field. Please post your bug number, just for the record.
Several days ago before I read this answer, I managed to get the export working by deleting some folders via Xcode (remove references only). Initially I suspected that there's an invalid format within the folders that I deleted, but when I tried deleting other folders, the export process works just fine.
I also tried exporting strings using Xcode 9, and I didn't encounter the problem. So hopefully this bug is only for Xcode 8.3.3 and below.

Cannot run program in Xcode

I've recently made an app and could successfully run and test it until this suddenly happened,
fail to run program
It doesn't looks like an issue, but the "run" button is unavailable. Usually it should look something like,
successfully run a program
As in the image, first there are two buttons, run and stop, after that there is the name of the program/app and its icon (fun facts) and then the iphone simulator it will run on (iphone 6). On the image on top, the failed to run program attempt, it is totally different, first the run button is disabled, second, the icon is a gear and not the app icon, and third, there is no simulator, it appears "my mac".
I don't know why this happened but this cannot let me run the app. I searched in the apple documentation and didn't found anything. If someone knows how to solve this please tell me.
The simplest solution is to rebuild your project from scratch. This is not difficult because you still have all your code. So, start with a new project from the iOS template. Copy your code from the old project into the new project.
And try to avoid renaming your project from now on, because there is a bug in some versions of Xcode where it crashes and destroys the project in just the way you describe in your question.
And update to the latest version of Xcode, because it is less likely to cause this problem (though in fact I have not found it reliable for renaming projects even now).

Appium : When I copy past the code generated by Appium in eclipse And try to run it - Nothing happens

Appium : When I copy past the code generated by Appium in eclipse And try to run it - Nothing happens
Hi All,
I am new to Appium and trying it out.I have got it setup and every thing is fine.When i record a code in generated.
So, what i did i copy past that code in eclipse and then try to run as testng.But nothing happens
What should I run it as (testng/junit or what)
I have just pasted the code so No testng in picture.I read some where to run it as testng so i did
My problem is that I want to launch the emulator and run my recorded script on it.
Please help me I have a demo for appium after 2 days.
Can you post your code here.
Also , you can check my post on iOS Appium here on my site.
If you are not using testng -> just run it as normal Java Application.
Try these steps. it worked for. From your question, I see you are using Java webdriver.
Make sure "Pre Launch" is not selected in your appium settings. Provider the .ipa/.app file. And Launch Appium. Make sure it starts without error.
Open your code using eclipse and run, it should launch the simulator (you can specify the device and simulator type in your code).
If code is not compiling, provide required libraries i.e. selenium-server (http://docs.seleniumhq.org/download/). It will work for sure.
-Vinay

Run iOS app without using Xcode

I am trying to find a way to automatize the running of some tests on iOS.
Is there any way I can start an app on the device without the use of Xcode (by using a script, for example)?
I found the tool below which does exactely what I need:
https://github.com/ghughes/fruitstrap
This answer does not solve your problem right away: But you might want to look at how RubyMotion solves this problem. It compiles files from the command line, installs them in the simulator, and also installs apps on the device.
I couldn't figure how it works, but maybe you can.
Take a look on my blog...
fruitstrap is based on gdb-arm-apple-darwin (not used anymore on xcode 5).
Install:
xcode 5 use debugserver so you need to use: ideviceinstaller.
Run app: idevice-app-runner

Resetting iOS simulator between tests

I have a set of automated test cases set up in instruments using tuneup.js to test an app. I decided to use tuneup.js as it allowed me to separate my tests into individual test cases and run the whole set from one individual script, this works fine if all the tests run ok, however if one fails, all the tests fail as the simulator is left in an unknown state (I have written my tests so they all start and end on the same login screen) Is there a way to reset the simulator, or restart the app between test cases?
Try to launch tests from the command line. UI Automation allows to execute only one test in one run. After the test will be completed (does not matter if it was failed or passed) - application will be kicked by the system (UIAutomation). At least it works with real devices.
Your command line launch script will work in the following manner:
1. Reads configuration file (can be any file txt or xml) with path to your tests. At this point you will have an array with path to your tests and total tests count.
2. Then using simple 'for' loop (from 1 to 'testcount') it will launch UIAutomation with required parameters. One of the parameters will be the path to your test script that was read from the configuration file.
You can also put the path to the 'configuration file' as a parameter for your command line launch script. This will allow you to run any test set simply calling the launch script with required configuration file.
I wrote a script that will reset the contents & settings of all versions and devices for the iOS Simulator. It grabs the device names and version numbers from the menu, so it will include any new devices or iOS versions that Apple releases simulators for.
It's easy to run manually or use in a build-script. I would suggest adding it as a Pre-Action Run Script before the build.
https://github.com/michaelpatzer/ResetAllSimulators
Having failed tests leave your app in an unknown state is one of the main problems with using Apple's instruments tool as-is. We solved this in a framework called Illuminator (on GitHub, and inspired by tuneup.js) in two ways.
First, we wrote an automation bridge -- a channel for RPC with the app being tested, which allows us to reset our app before each test.
In cases where that's not sufficient, the Illuminator test runner has an option to re-run each failed test in its own pristine launch of the simulator (e.g. with --retest 1x,solo).

Resources