Why Quicklook server doesn't get the same output as qlmanage - quicklook

when I use qlmanage - p <file> I get the result I want.
But qlmanage -x -p <file> give me another result (the same as the finder display)
So is there any setting for quicklook server that will give me same result ?
Thanks.
PS: already try qlmanage -r or qlmanage -r cache, even reboot the mac...

Related

How to send a Return key in an already existing screen session on MacOS?

First, I create a session by typing screen -S test1, then I detach and type screen -S test1 -p 0 -X stuff "ls^M". This doesn't work, it just prints the characters "ls^M" in my session.
Without more details I don't know why it does not work for you but you can try other ways:
screen -S session -X -p 0 stuff "echo hello\r"
# OR
screen -S session -X -p 0 stuff $'echo world\r'
Another solution (from #pynexj) is to simply update the screen shipped with MacOS:
brew install screen
Then restart the terminal.

Indexing a Apple Help Book on BigSur

I'm trying to generate an Apple Help Book index file (Big Sur), I'm using the following scripts:
hiutil -I corespotlight -Cf Base.lproj.cshelpindex -a -vv .
hiutil -I lsm -Cf Base.lproj.helpindex -a -vv .
Files are generated, but when I validate them I get:
Index format no longer supported.
or
Unable to open Archive
I've generated the same files with Apple's "Help Indexer" GUI program, but the files too are apparently no-longer supported.
I've read that it apparently works on High-Sierra, but I don't have access to a Mac with that OS.
Is there a known workaround for this? or am I doing it wrong?
The ultimate goal would be to run on GitHub Actions, but I'm limited as I can't run a macOS Virtual Machine on there.
Maybe I could find the version of hiutil that ran on High Sierra (hiutil version 1.3.2 (55) ?) and run that in a Linux Docker?
Maybe I could find out the file format of the .helpindex files and write a program to generate them
Thanks
Chris
I think I have the answer, the commands need to be:
hiutil -I corespotlight -Caf Base.lproj.cshelpindex -vv .
hiutil -I lsm -Caf Base.lproj.helpindex -vv .
and to validate
hiutil -I corespotlight -Af Base.lproj.helpindex
hiutil -I corespotlight -Af Base.lproj.cshelpindex
Just use a virtual machine which runs another os inside your os. This is the easiest way for you: download Parallels Desktop Lite and see Install MacOS in Parallels Desktop Lite.

Resuming curl download that goes through some bash script

I am trying to download a huge file via curl. As far as I can see it there is some bash script hooked in between to deliver the correct file (in that case a virtual machine that runs IE10):
curl -s https://raw.githubusercontent.com/xdissent/ievms/master/ievms.sh | IEVMS_VERSIONS=10 bash
Due to a wobbly internet connection the download fails constantly so I need a way to resume the download at its current position. I've tried resuming the download like so:
curl -s -C - https://raw.githubusercontent.com/xdissent/ievms/master/ievms.sh | IEVMS_VERSIONS=10 bash
However, all I get is some MD5 check failed error...am I missing something?
The curl command you're running there doesn't download the VM images. It downloads a bash script called ievms.sh and then pipes the script to bash, which executes it.
Looking at the script, it looks like the file it downloads for IE10 is here:
http://virtualization.modern.ie/vhd/IEKitV1_Final/VirtualBox/OSX/IE10_Win8.zip
I think if you download that file (you could use your browser or curl) and put it in ~/.ievms, and then run the command again, it should see that the file has already been downloaded and finish the installation.
If the partially-downloaded file is already there, then you could resume that download with this command:
curl -L "http://virtualization.modern.ie/vhd/IEKitV1_Final/VirtualBox/OSX/IE10_Win8.zip" \
-C - -o ~/.ievms/IE10_Win8.zip
(Then run the original IEVMs curl command to finish installation.)

Running UIAutomation scripts from Xcode

Did anyone succeed in setting up automated UIAutomation tests in Xcode?
I'm trying to set up a target in my Xcode project that should run all the UIAutomation scripts I prepared. Currently, the only Build Phase of this target is this Run Script block:
TEMPLATE="/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate"
MY_APP="/Users/Me/Library/Application Support/iPhone Simulator/6.0/Applications/564ED15A-A435-422B-82C4-5AE7DBBC27DD/MyApp.app"
RESULTS="/Users/Me/Projects/MyApp/Tests/UI/Traces/Automation.trace"
SCRIPT="/Users/Me/Projects/MyApp/Tests/UI/SomeTest.js"
instruments -t $TEMPLATE $MY_APP -e UIASCRIPT $SCRIPT -e UIARESULTSPATH $RESULTS
When I build this target it succeeds after a few seconds, but the script didn't actually run. In the build log I get these errors:
instruments[7222:707] Failed to load Mobile Device Locator plugin
instruments[7222:707] Failed to load Simulator Local Device Locator plugin
instruments[7222:707] Automation Instrument ran into an exception while trying to run the script. UIATargetHasGoneAWOLException
+0000 Fail: An error occurred while trying to run the script.
Instruments Trace Complete (Duration : 1.077379s; Output : /Users/Me/Projects/MyApp/Tests/UI/Traces/Automation.trace)
I am pretty sure, that my javascript and my run script are both correct, because if I run the exact same instruments command in bash it works as expected.
Could this be a bug in Xcode?
I finally found a solution for this problem. It seems like Xcode is running the Run Scripts with limited rights. I'm not entirely sure, what causes the instruments command to fail, but using su to change to your user will fix it.
su $USER -l -c <instruments command>
Obviously, this will ask you for your password, but you can't enter it when running as a script. I didn't find a way to specify the password for su, however if you run it as root, you don't have to specify one. Luckily sudo can accept a password via the pipe:
echo <password> | sudo -S su $USER -l -c <instruments command>
If you don't want to hardcode your password (always a bad idea), you could use some AppleScript to ask for the password.
I posted the resulting script below. Copy that to a *.sh file in your project and run that script from a Run Script.
#!/bin/bash
# This script should run all (currently only one) tests, independently from
# where it is called from (terminal, or Xcode Run Script).
# REQUIREMENTS: This script has to be located in the same folder as all the
# UIAutomation tests. Additionally, a *.tracetemplate file has to be present
# in the same folder. This can be created with Instruments (Save as template...)
# The following variables have to be configured:
EXECUTABLE="TestApp.app"
# Optional. If not set, you will be prompted for the password.
#PASSWORD="password"
# Find the test folder (this script has to be located in the same folder).
ROOT="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Prepare all the required args for instruments.
TEMPLATE=`find $ROOT -name '*.tracetemplate'`
EXECUTABLE=`find ~/Library/Application\ Support/iPhone\ Simulator | grep "${EXECUTABLE}$"`
SCRIPTS=`find $ROOT -name '*.js'`
# Prepare traces folder
TRACES="${ROOT}/Traces/`date +%Y-%m-%d_%H-%M-%S`"
mkdir -p "$TRACES"
# Get the name of the user we should use to run Instruments.
# Currently this is done, by getting the owner of the folder containing this script.
USERNAME=`ls -l "${ROOT}/.." | grep \`basename "$ROOT"\` | awk '{print $3}'`
# Bring simulator window to front. Depending on the localization, the name is different.
osascript -e 'try
tell application "iOS Simulator" to activate
on error
tell application "iOS-Simulator" to activate
end try'
# Prepare an Apple Script that promts for the password.
PASS_SCRIPT="tell application \"System Events\"
activate
display dialog \"Password for user $USER:\" default answer \"\" with hidden answer
text returned of the result
end tell"
# If the password is not set directly in this script, show the password prompt window.
if [ -z "$PASSWORD" ]; then
PASSWORD=`osascript -e "$PASS_SCRIPT"`
fi
# Run all the tests.
for SCRIPT in $SCRIPTS; do
echo -e "\nRunning test script $SCRIPT"
COMMAND="instruments -t \"$TEMPLATE\" \"$EXECUTABLE\" -e UIASCRIPT \"$SCRIPT\""
COMMAND="echo '$PASSWORD' | sudo -S su $USER -l -c '$COMMAND'"
echo "$COMMAND"
eval $COMMAND > results.log
SCRIPTNAME=`basename "$SCRIPT"`
TRACENAME=`echo "$SCRIPTNAME" | sed 's_\.js$_.trace_g'`
mv *.trace "${TRACES}/${TRACENAME}"
if [ `grep " Fail: " results.log | wc -l` -gt 0 ]; then
echo "Test ${SCRIPTNAME} failed. See trace for details."
open "${TRACES}/${TRACENAME}"
exit 1
break
fi
done
rm results.log
It seems as though this really might be an Xcode problem; at any rate, at least one person has filed a Radar report on it. Someone in this other thread claims you can work around this exception by disconnecting any iDevices that are currently connected to the computer, but I suspect that does not apply when you're trying to run the script as an Xcode target.
I would suggest filing a Radar report as well; you may get further details on the issue from Apple, or at least convince them that many people are having the problem and they ought to figure out what's going on.
Sorry for a not-terribly-helpful answer (should have been a comment, but comments and links/formatting do not mix very well). Please update this question with anything you find out on the issue.
Note: this is not a direct answer to the question, but it is an alternative solution to the underlying problem.
While searching for in-depth information about UIAutomation, I stumbled across a framework by Square called KIF (Keep it functional). It is a integration testing framework that allows for many of the same features as UIAutomation, but the great thing about is is that you can just write your integration tests in Objective-C.
It is very easy to setup (via CocoaPods), they have good examples too, and the best thing is that it's a breeze to set up with your CI system like Jenkins.
Have a look at: http://github.com/square/KIF
Late to the game but I have a solution that works for Xcode 5.1. Don't know if that's what broke the above solution or not. With the old solution I was still getting:
Failed to load Mobile Device Locator plugin, etc.
However, this works for the release version of Xcode 5.1.
echo <password> | sudo -S -u username xcrun instruments
Notice I removed the unneeded su command and added the xcrun command. The xcrun was the magic that was needed.
Here is my complete command:
echo <password> | sudo -S -u username xcrun instruments\
-w "iPhone Retina (3.5-inch) - Simulator - iOS 7.1"\
-D "${PROJECT_DIR}/TestResults/Traces/Traces.trace"\
-t "${DEVELOPER_DIR}/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate"\
"${BUILT_PRODUCTS_DIR}/MyApp.app"\
-e UIARESULTSPATH "${PROJECT_DIR}/TestResults"\
-e UIASCRIPT "${PROJECT_DIR}/UITests/main.js"
By the way if you type:
instruments -s devices
you will get a list of all the supported devices you can use for the -w option.
Edit: To make this work for different people checking out the project replace the following:
echo <password> | sudo -S -u username xcrun instruments
with
sudo -u ${USER} xcrun instruments
Since you are just doing an sudo to the same user no password is required.
Take a look at this tutorial that explains how to have Automated UI testing with Jenkins. It also uses Jasmine in the tutorial though. http://shaune.com.au/automated-ui-testing-for-ios-apps-uiautomation-jasmine-jenkins/ hope this helps. It has an example project file so you can download that as a template. Hope this helps.
In XCode - if you load up organizer (XCode->Window->Organizer)
Then select your machine under devices -> 'Enable Developer Mode'
This should remove the need for prompts with instruments.

How do I use 'screencapture' on OS X

I'm using OS X 10.6.5 and occasionally access it via ssh. While accessing it this way I need to be able to use the screencapture utility to take an image of the screen. The man page for screencapture says to do the following, but this doesn't seem to work for me:
SECURITY CONSIDERATIONS
To capture screen content while logged in via ssh, you must launch
screencapture in the same mach bootstrap hierarchy as loginwindow:
PID=pid of loginwindow
sudo launchctl bsexec $PID screencapture [options]
The command I'm using currently is:
sudo launchctl bsexec 53 screencapture foo.png
The result is that no PNG is outputted and the command silently returns. Can any of you help me make this work? Thanks!
Try logging in via ssh to the same username currently logged in at the OS X main display. You should then be able to run screencapture directly in the ssh session.
Maybe this "gist" helps: https://gist.github.com/323256
#!/usr/bin/env bash
screenshot="screnshot.png"
screencapture='/usr/sbin/screencapture -xC'
if [ `whoami` == 'root' ]; then
loginpid=`ps -ax | grep [l]oginwindow.app | awk '{print $1}'`
launchctl bsexec $loginpid $screencapture $screenshot
else
$screencapture $screenshot
fi

Resources