Setting Version of iOS simulator from Command line - ios-simulator

Context: Running automated scripts using Xcode's UIAutomation with simulators 6.1 and 5.1
Xcode version is 4.6.1
Problem: When running a shell script from the Terminal, UIAutomation ALWAYS opens up 6.1, even though i've set the app path to 5.1.
I've tried building and running on 5.1, also if i run the test from Instruments, I'm able to choose the target for 5.1 and it works fine. The problem is only when i run it from the command line.
I checked the iphonesimulator.plist and the currentSDKRoot points to the 5.1 path, but as soon as the shell script runs, it changes to 6.1. Is there anyway I can force it to use 5.1?
After hours of searching (including the most apt one - Launch a specific Hardware version of iOS simulator using instruments command line utility) , there seems to be no solution to this.
There is a way to set the device using defaults write com.apple.iphonesimulator \ "SimulateDevice" '"iPad"'
I need something like defaults write com.apple.iphonesimulator \ "Version" '"5.1"'
though obviously that doesn't work.
Any pointers will be much appreciated. Thank You!
EDIT: I was hoping this would be resolved with XCode 5, but I still have the same issue and iOS7 simulator ALWAYS opens up! Btw,is there a way to circumvent this issue - I'm sure there are many out there running multiple simulator versions.

This isn't elegant, but it is a work around that we have been able to get to work on our automation setup:
Install Xcode 5 from the App Store
Install Xcode 4.6.3 or from the developer portal's "Old Versions of Xcode page"
Repeat with older versions of Xcode where the max sim version == the one you want to run
Use "sudo xcode-select -switch /path/to/Xcode.app" to pick the version of Xcode
Hope that helps!

I also ran into this issue while running my automation tests on my Jenkins box and I did the following to test my app with ver 6.1 simulator and not 7.0 simulator:
Using Jenkins:
STEP 1 = I create one job that builds my ios app with the 6.1 sdk version.
===========================================
STEP 2 = I create a 2nd job using a bash script that downstreams from the 1st job which does the following:
[Go inside the Xcode app location to get to the iphone simulator sdk directory]
cd '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/'
[Move the 'iPhoneSimulator7.0.sdk' directory to another location (I chose the desktop)]
echo [ENTER ADMIN PASSWORD HERE] | sudo -S mv iPhoneSimulator7.0.sdk/ ${HOME}/Desktop
[Rename the 'iPhoneSimulator6.1.sdk' to 'iPhoneSimulator7.0.sdk']
echo [ENTER ADMIN PASSWORD HERE] | sudo -S mv iPhoneSimulator6.1.sdk/ iPhoneSimulator7.0.sdk/
===========================================
STEP 3 = I create 3rd job that executes my tests. The 3rd job downstreams from my 2nd job.
===========================================
STEP 4 = I create a 4th job that downstreams from the 3rd job. The 4th job uses a bash script which does the following:
[Go inside the Xcode app location to get to the iphone simulator sdk directory]
cd '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/'
[Rename the 'iPhoneSimulator7.0.sdk' back to 'iPhoneSimulator6.1.sdk']
echo [ENTER ADMIN PASSWORD HERE] | sudo -S mv iPhoneSimulator7.0.sdk/ iPhoneSimulator6.1.sdk/
[Go to directory where you moved the 'iPhoneSimulator7.0.sdk' (in my case I moved the 'iPhoneSimulator7.0.sdk' to the desktop)]
cd ${HOME}/Desktop
[Move the 'iPhoneSimulator7.0.sdk' directory back to the Xcode app sdk directory]
echo [ENTER ADMIN PASSWORD HERE] | sudo -S mv iPhoneSimulator7.0.sdk/ '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/'
[I kill any lingering processes related to the automation]
ps ax|grep [b]ash|awk '{print $1}'|xargs kill -9
ps ax|grep [i]nstruments|awk '{print $1}'|xargs kill -9
===========================================
I probably need to make this process more foolproof however I think its better than having multiple instances of xcode on the automation machine.

Related

how can I check if Leiningen is successfully installed and working at full capacity?

Java JDK is installed, everything works great, also maven works great.
I followed the instructions from the site, downloaded the bat file, set the path and at the command prompt started the installation with the command lein self-install.
what i got in response is downloading leiningen now ....
after a while, C: \ windows \ system32> appeared below that line and it stays that way for several hours.
What more should I do?
The command line normally uses a prompt like > or similar to indicate it is waiting for a command. Then you type something followed by the <return> key:
> lein --version
Leiningen 2.9.8 on Java 1.8.0_322 OpenJDK 64-Bit Server VM
>
Here I typed lein --version, then <ret>, and the computer responded with a 1-liner about the version of Leiningen and Java that are installed. Then it displayed the prompt again, waiting for the next command.
You can use the cd (change directory) command to move around. With no prompt it will send you back to your "home" directory. See docs for the BASH or ZSH shell.
For Windows, I highly recommend installing the BASH Shell and git from this site:
https://gitforwindows.org/
IMHO the bash shell is greatly superior to the built-in Windows shell from CMD.EXE

Logging console output using Qt Installer Framework scripting

I added some console.log("xxxxxx") via component / controller scripting to my installer.
ie.
function Controller()
{
console.log("OS: " + systemInfo.productType);
}
How can I view the console log during the running of the installer?
Not sure if you can see a log during installation. But after a "successful" installation the TargetDir will contain a file named InstallationLog.txt that contains all the console.log lines from the installation process.
Edit: To see it live, do like #CherryDT points out in his comment: Run your installer from the command line and provide the -v parameter (fx my_installer.exe -v).
Edit: The previous Edit is slightly wrong, check #KcFnMi answer.
To see console.log information at runtime (the time you're running the installer, not the time you are building the installer) do:
installer.exe -d
or
installer --version
-d, --verbose Verbose mode. Prints out more information.
https://doc.qt.io/qtinstallerframework/ifw-cli.html
Note: It's not -v:
-v, --version Displays version information.

Docker containers do not work when run from command line

I have been working on an ASP.NET application using Docker, and when I launch it through Visual Studio it works great! However, if I try to run anything from the command line (or powershell, or VS's CLI/Powershell) it will run, but the container it generates refuses all connections.
I am on Windows 10 NT with Docker Desktop installed trying to run an ubuntu:18.04 image (i've tried Alpine, ubuntu:16.04 as well).
Steps to reproduce:
-Create a default ASP.NET application in Visual Studio
-Add Docker Support
-Run with 'Docker' selected
-Open browser, navigate to localhost:[YourPort]
-Success! Works as intended.
Then, either using the same image or a downloaded one (I tried dockersamples/static-site to confirm it wasn't a problem with the specific project):
-Open CMD
-Run docker run -p [HostPort]:[ContainerPort] [SameImageVSUses:tag] on a different port
-See that docker ps shows both containers running next to each other
-Open browser (Firefox), get error
The connection was reset
Update
I changed the ASP.NET app's program class to use 0.0.0.0 instead of localhost, I believe this was necessary but now I see
Secure Connection Failed
PR_END_OF_FILE_ERROR_
If I curl localhost:[MyPort], I get (52) empty reply from server
/Update
Well, maybe Visual Studio does more that I'm not aware of.
A little bit of digging shows yes, it throws in a ton of extra arguments! Using the copy/pasted command Visual Studio does gives me... the exact same error.
To clarify, the containers still run from the command line, I can ssh in or docker inspect them (in fact, the VS-started and CMD-started containers' docker inspect is identical other than network addresses it's bound to). I get no error messages at all from the process of building and starting the container, so if some part of it is failing it is doing so silently.
I'm relatively new to Docker but I can't seem to find a fix for this, or even a reason behind it. What is Visual Studio doing that I'm not? I've tried everything I'm aware of, I even had to wipe my machine (unrelated) and the exact same thing happened when I got everything reinstalled. My gut tells me it's something on my machine, but then the VS-launched one should fail too, right?
I can't find anything that tells me to flip a magic switch if I'm running CLI stuff, and nothing I do to the dockerfile or command arguments seems to work. I've never used VirtualBox or Docker Toolbox, this shouldn't be a wonky configuration screwed up by an old program because It works fine when launched from Visual Studio! Agh!
I hope that this is indeed a magic switch I haven't flipped, otherwise there is something very basic that I don't understand about what I'm working with.
If you are trying to run recent VS template you just need to follow this instruction:
Go to the Api project directory:
cd ./src/YourApiDirectory
Build Command:
docker build -f ./Dockerfile --force-rm -t yourapiimage:dev ..
Run Command:
docker run -it --rm -e "ASPNETCORE_ENVIRONMENT=Development" -p 58817:80 --name yourapiname yourapiimage:dev
please note that "-it" flag in last command will run your image in "interactive" mode. Also please note I am using only http connection via port 58817.
Thank you for the suggestions, it ended up being something rather frustrating. I think that it was a combination of two problems:
This stuff could be causing problems for others but I was mistaken, this did not work for me
First and foremost, no amount of docker configuration tells your website to listen for anything inside the container. I believe the website wasn't listening for anything when I initially tried most fixes.
The real problem was that the launchSettings.json in the .csproj Properties folder apparently overrides arguments from the command line!
Remember how I said '...run it alongside the first...'? That means I was never running the website on the correct set of ports. Apparently, -p 8001:443 -e ASPNETCORE_HTTPS_PORT=443 is not enough to make the site listen on 443. You must also set the sslPort in the launchSettings.json. Such is life, I suppose.
This is what finally worked
I ran docker-compose up in the solution directory. That's it. I didn't see a docker-compose.yml when I was looking in VS so I didn't think about it, but that's only because VS doesn't show solution-level items. I guess the thing that VS was doing that I wasn't was running docker-compose instead of individual commands.
When directly launch with Docker profile which is done via docker-compose file in Visual Studio, visual studio behind the screen merges different override files and does different tasks and one of them is attaching remote debugger in the container etc.
To help you I've created a sample asp.net core api via Visual Studio 2019 selecting .Net Core 3.0.
The following is the docker-compose that VS2019 generated on my machine when I launched my API via VS2019.
docker-compose -f "C:\Users\myuser\source\repos\testwebcore\docker-compose.yml" -f "C:\Users\myuser\source\repos\testwebcore\docker-compose.override.yml" -f "C:\Users\myuser\source\repos\testwebcore\obj\Docker\docker-compose.vs.debug.g.yml" -p dockercompose14364360289538262671 --no-ansi up -d --build --force-recreate --remove-orphans
I can get it work directly on powershell by running the following command, here I am using the same settings used in the override file by default created by VS2019. You have to run this command from parent folder outside the project folder.
docker-compose -f "C:\Users\myuser\source\repos\testwebcore\docker-compose.yml" -f "C:\Users\myuser\source\repos\testwebcore\docker-compose.override.yml" up
If you have directly build and run with the docker file instead of docker-compose
You can build with the following command and like before should run from outside folder of the project file.
docker build -f testwebcore/Dockerfile -t testcore
After building the image, you can run it with the below command but before that you need to create a certificate and pass couple of environment variables to the run command. The details of this is mentioned in the following page.. Especially the section Windows subsystem for Linux. I am running Linux containers on my Windows 10 laptop.
So you have to run the following command to generate certificate
dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p testpassword
So the complete run command with environment variables and certificate generated above the command is as follows.
docker run --rm -it -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_Kestrel__Certificates__Default__Password="testpassword" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v c:\users\myuser\.aspnet\https:/https/ testcore:latest

PHPUnit Ansicon is not showing colors

Operating System: Windows 8.1 (64 bit)
Terminal: Git Bash
Purpose: Show colors in PHPUnit command results
Process followed:
Downloaded https://github.com/downloads/adoxa/ansicon/ansi160.zip
Extracted the file into C:\ansicon
Added C:\ansicon\x64 in "Path" user variables.
Opened Git Bash as administrator
Moved into C:\ansicon\x64 and executed ansicon -i without any errors.
Restarted Git Bash and moved into My test project.
Executed phpunit --colors TestFile.php
Problem: The result is showing but without any colors.
Question: What have I done wrong? How to solve it?

How to use XULRunner to run SQLite Manager outside of Firefox in Mac OS X Lion?

I have installed XULRunner 11.0 (xr) from here:
Downloads - sqlite-manager - Extension for Firefox and other apps to manage any sqlite database - Google Project Hosting
I have followed the steps listed here:
kiveo - Mac SQLite Manager Standalone App
I have read and tried the suggestions here (though they're for version 6.0):
stackoverflow: How to Install and run a XulRunner Application on Mac OS X?
I am able to get the help listing with this command:
/Library/Frameworks/XUL.framework/xulrunner-bin -h
I am able to run the app from Firefox using this command (after changing the max version in sqlitemanager-xr-0/application.ini to 11.0 from 11.0a1):
/Applications/Firefox.app/Contents/MacOS/firefox --app ~/Downloads/sqlitemanager-xr-0/application.ini
Here are the contents of the application.ini file:
[App]
Name=sqlite-manager
ID=SQLiteManager#mrinalkant.blogspot.com
Version=0.7.7
BuildID=201111132204
Vendor=lazierthanthou
Copyright=Copyright (c) 2008 - 2011 lazierthanthou
[Gecko]
MinVersion=2.0
MaxVersion=11.0
[XRE]
EnableExtensionManager=1
When I run the following command in Terminal, with or without sudo, it just immediately returns to the command prompt. There are no error messages. No application appears under Applications. Nothing seems to happen at all. (And, despite the stackoverflow page above noting that --install-app may not really be supported, it is in the XULRunner help listing - which I guess doesn't necessarily mean it'll work ;)
/Library/Frameworks/XUL.framework/xulrunner-bin --install-app Downloads/sqlitemanager-xr-0/ /Applications
Following a suggestion below, I checked for an exit code. The line above is returning 2.
Help?
Just like you did with Firefox, this command should run your app:
/Library/Frameworks/XUL.framework/xulrunner-bin --app ~/Downloads/sqlitemanager-xr-0/application.ini
Also, the --app switch is optional within XULRunner.
Here's how you can make a self-contained application you can run from the Dock.
Use the xulrunner --install-app command to create the application and then copy all contents of XUL.framework/Versions/Current into the generated application at /Applications/sqlite-manager.app/Contents/MacOS.
You can then create a wrapper script that runs the xulrunner within the generated app with the application.ini file as described here.
For example, put the following into sqlite-manager.app/Contents/MacOS/sqlite-manager and make it executable.
#!/usr/bin/env bash
APP_PATH="/Applications/sqlite-manager.app"
"$APP_PATH/Contents/MacOS/xulrunner" --app "$APP_PATH/Contents/Resources/application.ini"
Now you have to tell OS X to run sqlite-manager instead of xulrunner. You can do that by editing sqlite-manager.app/Contents/info.plist and setting CFBundleExecutable to sqlite-manager like this:
<key>CFBundleExecutable</key>
<string>sqlite-manager</string>
The only limitation of this approach is that it breaks when you move the application or rename it. I'd love suggestions on how to get rid of the absolute path within the sqlite-manager script.
try this:
firefox -chrome chrome://sqlitemanager/content/sqlitemanager.xul
or on OS X
/Applications/Firefox.app/Contents/MacOS/firefox -chrome chrome://sqlitemanager/content/sqlitemanager.xul
(found on http://www.egeek.me/2013/09/07/how-to-run-sqlite-manager-with-a-single-command/)
works fine for me on UBUNTU 12.04 to start sqlite manager without starting firefox first
If the install was successful, I think the app should be available in some usual place for your system (which wasn't mentioned, but I'm guessing OSX :). Have you looked under /Applications?
To see whether the command failed quietly, you could check its return value. Is there a verbose switch?
$ cd narnia
bash: cd: narnia: No such file or directory
$ echo $?
1
$ cd .
$ echo $?
0
$ cd narnia && echo "success"
bash: cd: narnia: No such file or directory
$ cd . && echo "success"
success

Resources