Skip to content

Instantly share code, notes, and snippets.

View wilmarvh's full-sized avatar
💻

Wilmar van Heerden wilmarvh

💻
View GitHub Profile
@dkun7944
dkun7944 / CDView.swift
Last active January 14, 2024 23:45
SwiftUI + Swift.Shader CD
//
// CDView.swift
// CD
//
// Created by Daniel Kuntz on 7/3/23.
//
import SwiftUI
struct ShapeWithHole: Shape {
@brennanMKE
brennanMKE / README.md
Last active May 11, 2022 08:49
Xcode Purge

Xcode Purge

Sometimes you just have to purge. With Xcode, it helps to completely blow away the Derived Data and SPM Cache directories. These directories contain all of the build artifacts produced by Xcode and resolved Swift packages. When a clean action does not completely reset your build it is time to purge.

These 2 functions can be added to your shell so you can simply run xcpurge to send Derived Data and SPM Cache to your Trash. You can recover it if necessary.

Usage

You likely are now using zsh with macOS and so you can update ~/.zshrc to define these functions. What I recommend is creating a folder at ~/.shell and create a file named ~/.shell/functions in that folder. Add the functions below to this file. Make sure to also run chmod u+x ~/.shell/functions and then add source $HOME/.shell/functions to ~/.zshrc so your shell has these functions defined. You can then run xcpurge or trash like any other command. The first time you run it you will need to grant permission since i

@lukaskubanek
lukaskubanek / Bundle+TestFlight.swift
Last active February 25, 2024 19:38
A code snippet for detecting the TestFlight environment for a macOS app at runtime
/// MIT License
///
/// Copyright (c) 2021 Lukas Kubanek, Structured Path GmbH
///
/// 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:
@krzysztofzablocki
krzysztofzablocki / NetworkResponseConvertible.swift
Last active August 22, 2021 12:09
A good way to deal with mapping network data to your local models in a consistent way, This is how @noremac standardised it in Times codebase
import Combine
import Foundation
/// This protocols allows you to declare your type as having a distinct network
/// representation.
///
/// Rather than writing and maintaining a custom `Decodable` implementation for
/// your type, declare a brand new struct that exactly matches the expected
/// network response, and then write an initializer for your actual type that
/// accepts a `NetworkResponse`.

ZSH CheatSheet

This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.

Strings

Description Syntax
Get the length of a string ${#VARNAME}
Get a single character ${VARNAME[index]}
@manmal
manmal / print_advertisingid_usage.sh
Created September 14, 2020 08:51
Find IDFA usage in 3rd party frameworks
for framework in Frameworks/*.framework; do
fname=$(basename $framework .framework)
echo $fname
otool -v -s __TEXT __objc_methname $framework/$fname | grep advertisingIdentifier
done
@abhi21git
abhi21git / ExtensionURLRequest.swift
Last active February 19, 2024 12:23
Swift cURL Printer
//
// ExtensionURLRequest.swift
//
// Created by Abhishek Maurya on 16/07/20.
// Copyright © 2020. All rights reserved.
//
import Foundation
extension URLRequest {
@DreamingInBinary
DreamingInBinary / Best in Class iOS Checklist
Last active January 29, 2024 18:18
This is a public checklist updated every year after the latest version of iOS and iPadOS are shipped. It's a boiled down version of a "Best in Class" app checklist created by Jordan Morgan.
# A Best in Class Checklist
A boiled down checklist adapted from this [post](https://www.swiftjectivec.com/a-best-in-class-app/), created by @jordanmorgan10.
> To use this, create a Github Issue in your own repo, and simply copy and paste this text.
## iOS Core Technology
_Things any iOS app can benefit from_
- [ ] iCloud Sync
- [ ] Focus Filter Support
@NSExceptional
NSExceptional / AutoLayout.md
Last active December 8, 2021 06:19
The best damn AutoLayout guide I've ever seen

Edit Feb 4 5:16 PM: Skip to the bottom if you just want the article

It has been brought to my attention that rehosting someone else's content without asking them — even if you link to the original content — is not exactly polite. I did not ask the author before I rehosted his article, and while I feel I should have known better than to that, it just didn't occurr to me. It's not exactly plagarism, but it's still wrong on some level. I have reached out to him now about hosting it here publically, and if he says it's alright, I'll put it back.

You can find the original article here, on his site, and on his Medium page.

@keith
keith / simctl-commands.txt
Last active December 7, 2022 23:27
All the subcommands of `xcrun simctl` (including ones that aren't listed in `simctl help`) LC_SOURCE_VERSION 776.1 (Xcode 13.0 beta 5)
addmedia
addphoto
addvideo
appinfo
boot
bootstatus
clone
create
darwinup
delete