Skip to content

Instantly share code, notes, and snippets.

View plu's full-sized avatar
🏠
Working from home

Johannes Plunien plu

🏠
Working from home
View GitHub Profile
@crewshin
crewshin / KeyboardAvoiding.swift
Last active July 18, 2024 20:39
KeyboardAvoiding SwiftUI
import SwiftUI
class KeyboardAvoidingHostingController<Content>: UIHostingController<Content> where Content: View {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChangeFrame), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
@chriseidhof
chriseidhof / collectionview.swift
Last active January 31, 2024 19:00
SwiftUI Flow Layout
//
// ContentView.swift
// DeleteMe
//
// Created by Chris Eidhof on 02.02.21.
//
import SwiftUI
/*
@timothycosta
timothycosta / UIViewWrapper.swift
Last active February 18, 2020 21:08
Get the position of a child View by wrapping it in a UIView
//
// UIViewWrapper.swift
// lingq-5
//
// Created by Timothy Costa on 2019/06/14.
// Copyright © 2019 timothycosta.com. All rights reserved.
//
import SwiftUI
import UIKit
@4np
4np / HowTo use xcconfig or plist with SPM.md
Last active August 5, 2024 11:06
How to use a .xcconfig file and a .plist with a Swift Package Manager based project.

How to use a .xcconfig file and a .plist file with SPM

Worth a read for some more context.

Create a Package.xcconfig file

Create the file in the root of the project (where your Package.swift file lives as well), and use the following contents:

/// Package.xcconfig
@jdmcd
jdmcd / API.swift
Last active June 19, 2020 07:37
Alamofire + Codable
class API {
static let apiKey = "test"
static let baseUrl = ""
enum Endpoint {
case login
case register
var endpoint: String {
switch self {
NOTIFY / HTTP/1.1
HOST: 192.168.1.116:3500
CONNECTION: close
CONTENT-TYPE: text/xml
CONTENT-LENGTH: 1146
NT: upnp:event
NTS: upnp:propchange
SID: uuid:RINCON_000xxxxxxxx01400_sub0000003246
SEQ: 0
SUBSCRIBE /MediaRenderer/GroupRenderingControl/Event HTTP/1.1
TIMEOUT: Second-600
CALLBACK: <http://192.168.1.116:3500/>
NT: upnp:event
Host: 192.168.1.154:1400
Connection: close
Content-Length: 0
@alanzeino
alanzeino / lldb-debugging.md
Last active September 8, 2025 00:06
LLDB debugging with examples

LLDB Debugging Cheat Sheet

Commands

LLDB Commands

LLDB comes with a great set of commands for powerful debugging.

help

Your starting point for anything. Type help to get a list of all commands, plus any user installed ones. Type 'help for more information on a command. Type help to get help for a specific option in a command too.

# Warning: BUILD_DIRECTORY must be an absolute path for this script to work properly
rm -rf $BUILD_DIRECTORY
ARCHIVE_PATH=$BUILD_DIRECTORY/$TARGET.xcarchive
IPA_PATH=$BUILD_DIRECTORY/$TARGET.ipa
xcodebuild -workspace $WORKSPACE -scheme $SCHEME -derivedDataPath $BUILD_DIRECTORY -archivePath $ARCHIVE_PATH archive
# As xcodebuild -exportArchive doesn't seem to work properly with WatchKit apps, I ended up making the IPA file by hand.
# https://devforums.apple.com/message/1120211#1120211 has some information about doing that.