/dev/trouble
Eric Roller's blog

Thursday, May 17, 2018

MacOS: Internet Recovery

Starting off with a replaced internal SSD on a MacBook Air, it doesn’t boot, obviously. It is necessary to boot into “Internet Recovery Mode” by selecting Command-R at startup, or, as I did, Option-Command-R to recover onto High Sierra.

I erase the disk in Disk Utility and select to install macOS High Sierra. After a few seconds I am greeted with the error:

The Recovery Server Could Not Be Contacted

A number of possible solutions are listed on the Mac OS X Blog. I used the first one, except that using sudo was not possible (command not found ?); I ran date in the Terminal which confirmed that the date was wrong, then I updated it using Apple’s time server (without sudo):

% ntpdate -u time.euro.apple.com

The run ‘date’ once more to check that the date & time has been updated.

[Read More…]

Thursday, April 20, 2017

Open Xcode from the Terminal

Quite often I find myself in the Terminal and want to open Xcode with the project in the current directory:

> open CurrentProject.xcodeproj

This works just fine, of course, but with the following alias (added to ~/.cshrc), I don’t need to know the name of the project, assuming there is always only one project in the current directory:

> alias xcode '\ls | grep xcodeproj | xargs open'
> xcode

N.B. The use of ‘\ls’ ignores the alias that I have for ‘ls’. Instead of “ls *.xcodeproj”, the pipe via grep avoids errors like “ls: No match.”.

P.S. Knowing the name of the project is actually not the problem; since there are multiple items named “Current*” or “CurrentProject*” in the same folder, the issue is that I can’t just type “open SHIFT+C<TAB><CR>” (where pressing TAB autocompletes the name); instead, I have to type: “open SHIFT+C<TAB>SHIFT+P<TAB>.x<TAB><CR>”.

Monday, March 6, 2017

Decimal.init(value: UInt64) crashes for very large values

Puzzled by a crash in my application, on a line of code that looked reasonable, it became necessary to dig a little deeper in how some of my Decimal numbers are created:

let newValue = Decimal.init(binary.maskedUInt64Value)

After testing a series of different 64-bit integer values, I found this:

(lldb) po Decimal.init(UInt64.max - 1024)
▿ 18446744073709547520
  ▿ _mantissa : 8 elements
    - .0 : 38912
    - .1 : 39321
    - .2 : 39321
    - .3 : 6553
    - .4 : 0
    - .5 : 0
    - .6 : 0
    - .7 : 0

(lldb) po Decimal.init(UInt64.max - 1023)
error: warning: couldn't get required object pointer (substituting NULL): Couldn't load 'self' because its value couldn't be evaluated

error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0).
The process has been returned to the state before expression evaluation.

[Read More…]

Wednesday, August 10, 2016

Weekly / Monthly Git Backups

Similar to what I have been doing with subversion, I now also create backups for my git repositories.

[Read More…]

Sunday, November 22, 2015

UIATarget.captureScreenWithName() producing corrupt images?

I like Jonathan Penn’s screen shooter scripts to automate the recording of screen shots for different iOS devices (screen sizes) as well as for multiple localisations (languages). Having said that, creating the automation scripts can be a pain and maintaining them with every change of the UI can be a real nuisance. …Breathe In… Sigh!

The trouble that I am addressing today, however, is about the resulting images. In my scripts, the screen shots are generated by calling either UIATarget.captureScreenWithName() or its sister function: UIATarget.captureRectWithName(). Sometimes, the images can look as if only partial, corrupted screens have been rendered.

[Read More…]