Skip to content

Instantly share code, notes, and snippets.

View indragiek's full-sized avatar

Indragie Karunaratne indragiek

View GitHub Profile
@indragiek
indragiek / movies_batch_load.patch
Last active December 10, 2020 03:31
The code change to enable batch loading of all data up-front in a single HTTP request.
@@ -287,7 +287,7 @@ class MovieDetailViewController: UIViewController, UIScrollViewDelegate, MovieDe
private func fetchMovieDetails() {
let spanName = "fetch-movie-details"
Specto.startSpan(spanName)
- client.getMovieDetails(movie: movie) { result in
+ client.getMovieDetails(movie: movie, additionalData: [.credits, .videos]) { result in
switch result {
case let .success(details):
self.details = details
@indragiek
indragiek / ios_sim_arm64.patch
Last active April 21, 2023 03:28
Bazel 3.7.1 patch to build an arm64 slice targeting the iOS Simulator. Use it by running `bazel build ... --cpu=ios_sim_arm64 --apple_platform_type=ios`
diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java b/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java
index 7759984b03..6f41eca83b 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java
@@ -42,7 +42,7 @@ public enum ApplePlatform implements ApplePlatformApi {
CATALYST("catalyst", "MacOSX", PlatformType.CATALYST, true);
private static final ImmutableSet<String> IOS_SIMULATOR_TARGET_CPUS =
- ImmutableSet.of("ios_x86_64", "ios_i386");
+ ImmutableSet.of("ios_x86_64", "ios_i386", "ios_sim_arm64");
@indragiek
indragiek / dsc_extractor.patch
Created November 2, 2020 21:29 — forked from lightbulbone/dsc_extractor.patch
Patch for Apple's dsc_extractor in the dyld package.
--- dyld-210.2.3/launch-cache/dsc_extractor.cpp 2012-05-21 02:35:15.000000000 -0400
+++ dyld-210.2.3/launch-cache/dsc_extractor.cpp 2013-07-26 16:05:03.000000000 -0400
@@ -37,6 +37,7 @@
#include <mach-o/arch.h>
#include <mach-o/loader.h>
#include <Availability.h>
+#include <dlfcn.h>
#define NO_ULEB
#include "Architectures.hpp"

iOS Shared Cache Extraction

Having fallen off the iOS-exploration train due to completing my Masters and other commitments, I have finally climbed back aboard in pursuit of understanding the telephony stack.

Like most things in iOS that are used frequently, the vast majority of the frameworks and libraries used in the telephony stack reside in the DYLD shared cache located at /System/Library/Caches/com.apple.dyld/dyld_shared_cache_armv7.

In this post I am going to explain how to go about extracting this cache file so that you can then work with each library individually.

Get The Cache

The first step in all of this is to copy the cache over to your local machine. I did this using a program called iExplorer, but you can just as easily do it over SSH. As a side note, you can connect to your iDevice using SSH over USB if you install a tool called iProxy.

# Use Google Cloud Platform stackdriver with python structlog
from google.cloud.logging import Client
from google.cloud.logging import _helpers
from google.cloud.logging.handlers import CloudLoggingHandler
from google.cloud.logging.handlers.transports.background_thread import _Worker
# pip install python-json-logger
from pythonjsonlogger import jsonlogger
@indragiek
indragiek / CStringArray.swift
Last active November 14, 2019 02:03
Helper for working with char ** in Swift
// Copyright © 2015 Indragie Karunaratne. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@indragiek
indragiek / Image.swift
Created October 18, 2015 00:45
vImage_Buffer wrapper
// Copyright © 2015 Indragie Karunaratne. All rights reserved.
import Foundation
import Accelerate
public class Image {
private var buffer: vImage_Buffer
public var size: CGSize {
return vImageBuffer_GetSize(&buffer)
/// Used to lift a bounding value for a `Double` into the type system.
/// This is an ugly workaround for the lack of dependent types in Swift.
public protocol BoundingValueType {
static var value: Double { get }
}
/// Type that represents a bounding value of 1.0
public struct _1: BoundingValueType {
public static var value: Double { return 1.0 }
}
func crashOnError<T>(f: Void throws -> T) -> T {
do {
return try f()
} catch {
fatalError("Uncaught error")
}
}
enum TestError: ErrorType {
case AnError
@indragiek
indragiek / Theming.swift
Last active February 3, 2018 23:21
Swift API for theming on iOS
// Created by Indragie on 5/3/15.
// Copyright (c) 2015 Indragie Karunaratne. All rights reserved.
import UIKit
public protocol ThemeType {
typealias Target
func apply(target: Target)
}