Skip to content

Instantly share code, notes, and snippets.

View dive's full-sized avatar
👹

Artem Loenko dive

👹
View GitHub Profile

Script

#!/bin/env sh

# http://haxx.se 
# http://daniel.haxx.se

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
@dive
dive / fix_ios_15_simulator_spotlight_cpu.sh
Created December 16, 2021 10:35
Fix the iOS 15 Simulator high CPU usage due to the Spotlight/Suggestions Engine
#!/bin/env sh
disable_suggestions() {
if [ -d "$1" ]; then
pushd "$1" || return
find . -name com.apple.suggestions.plist \
-exec echo {} \; \
-exec plutil -replace SuggestionsAppLibraryEnabled -bool NO {} \;
popd || return
fi
@dive
dive / things_3_console_logs
Created June 3, 2021 19:47
Things 3 Console Logs (iMac M1, stuck on launch)
default 20:40:55.697729+0100 Things3 Requesting container lookup; class = 2, identifier = <private>, temp = 0, create = 0, euid = 501, uid = 501, personaid = -1, type = NOPERSONA, name = <unknown>
default 20:40:55.698792+0100 Things3 container_create_or_lookup_for_platform: success
default 20:40:55.721862+0100 Things3 CHECKIN: pid=2504
default 20:40:55.732980+0100 Things3 CHECKEDIN: pid=2504 asn=0x0-0xff0ff foreground=1
default 20:40:55.737016+0100 Things3 Received configuration update from daemon (initial)
default 20:40:55.751735+0100 Things3 FRONTLOGGING: version 1
default 20:40:55.751776+0100 Things3 Registered, pid=2504 ASN=0x0,0xff0ff
default 20:40:55.755234+0100 Things3 BringForward: pid=2504 asn=0x0-0xff0ff bringForward=1 foreground=1 uiElement=0 launchedByLS=1 modifiersCount=1 allDisabled=0
default 20:40:55.755675+0100 Things3 BringFrontModifier: pid=2504 asn=0x0-0xff0ff Modifier 0 hideAfter=0 hideOthers=0 dontMakeFrontmost=0 mouseDown=0/0 seed=0/0
default 20:40:55.755783+0100 Things3 BringForward: pi
@dive
dive / things_3_sample
Created June 3, 2021 19:45
Things 3 – Sample (iMac M1, stuck on launch)
Sampling process 2504 for 3 seconds with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Analysis of sampling Things3 (pid 2504) every 1 millisecond
Process: Things3 [2504]
Path: /Applications/Things3.app/Contents/MacOS/Things3
Load Address: 0x100dd0000
Identifier: com.culturedcode.ThingsMac
Version: 3.13.11 (31311505)
Code Type: ARM64
Platform: macOS
@dive
dive / carthage_update.sh
Created June 1, 2021 15:41
Carthage workaround for XCFrameworks and `arm64` arch
#!/usr/bin/env bash
# Usage example: ./carthage_update.sh Chatto
set -euo pipefail
xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)
trap 'rm -f "$xcconfig"' INT TERM HUP EXIT
# Serialize dsym paths for running on different machines, required in order for lldb debugging to work on xcode 12+
echo 'SWIFT_SERIALIZE_DEBUGGING_OPTIONS = NO' >> "$xcconfig"
@dive
dive / install_macports.sh
Last active May 23, 2021 14:02
MacPorts installation script
#!/bin/bash
set -euf -o pipefail
# FIXME: Check '/opt/local/bin/port' directly if MacPorts is not in the PATH?
if command -v port &> /dev/null; then
printf "%s\n%s\n%s\n" \
"MacPorts is already installed." \
"Consider to use 'sudo port selfupdate' command for upgrades." \
"Check the https://guide.macports.org/#installing.macports.uninstalling to uninstall MacPorts before reinstalling."
@dive
dive / current_selected_installed_xcode.md
Last active April 16, 2022 23:29
How to get the current selected Xcode and list installed

How to get the current selected Xcode and list installed

Current Selected Xcode

xcode-select

This is the most common way to get the path to the selected instance:

xcrun xcode-select --print-path
@dive
dive / grammarly_ios_keyboard_unboxing.md
Last active April 9, 2023 11:17
Grammarly iOS Keyboard — Unboxing

Grammarly iOS Keyboard – Unboxing

Grammarly is a lovely writing assistant. Twenty million people use the tool across the globe according to the statistics available on the site. I use it too. No complaints, it does its job quite well, and I am a happy user. The only thing that always worried me is the Grammarly iOS Keyboard. As an iOS engineer, I know how easily you can collect different data, sensitive information, and even do not ask users about the consent. So, let's check what is inside the Grammarly iOS application.

TL;DR

  • Grammarly iOS uses at least three trackers (Adjust, AppsFlyer, Internal analytics)
  • Grammarly Keyboard has access to keystrokes, sensitive data, and able to send them over the network

Frameworks

@dive
dive / xcrun_xcode_development_tools.md
Last active December 16, 2022 01:48
Multiple Xcode versions or Why `xcrun` is your friend

Multiple Xcode versions or Why xcrun is your friend

The story

I recently spent a few hours helping a friend of mine investigate a weird issue in their Continuous Development infrastructure. Builds were failing with different fatal errors mostly related to SDK paths and .platform directory locations. At first sight, it was clear that something is wrong with the current selected Xcode, but all our initial attempts to catch the problem failed.

In the end, we isolated the problem; one of the tools they use changes PATH silently for the environment to simplify access to Xcode tools. Due to their internal logic, the CD pipeline changes a current selected Xcode a few times on the way within the same script. In some cases, the pipeline ended with xcodebuild in the environment's PATH that does not reflect the expected version after the xcode-select --switch command.

How? Pretty easy, actually. A simplified sequence looked like this:

@dive
dive / xed_xcode_invocation_tool.md
Last active July 27, 2023 15:23
Xcode invocation tool - xed

Xcode invocation tool - xed

xed is a command-line tool that launches the Xcode application and opens the given documents (xcodeproj, xcworkspace, etc.), or opens a new document, optionally with the contents of standard input.

If you work from the command line, this tool is a better option than open (which can open Xcode projects as well). Why?

  • xed knows about the current selected Xcode version (open behaves unpredictably if you have multiple Xcode installed)
  • You can use it open all files from a specific commit (with a little help explained below). It is useful on code-reviews or when you want to explore significant changes in the repository
  • You can use it as a "quick open" helper. Helps with monorepo phenomena, when you have hundreds of projects in the repository (I will show you an example below)