Skip to content

Instantly share code, notes, and snippets.

View perlguy99's full-sized avatar

Brent Michalski perlguy99

  • Senior iOS Engineer
  • St. Louis, MO
View GitHub Profile
@perlguy99
perlguy99 / gist:31de4267c31e628cad40f4b69ea49546
Created May 3, 2024 16:07
If Xcode gets stuck at "Preparing iPhone Simulator for Previews"
xcrun simctl --set previews delete all
@perlguy99
perlguy99 / Xcode_Variables.txt
Created July 10, 2017 18:07
Xcode Environment variables
ACTION=build
AD_HOC_CODE_SIGNING_ALLOWED=NO
ALTERNATE_GROUP=staff
ALTERNATE_MODE=u+w,go-w,a+rX
ALTERNATE_OWNER=brent
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO
ALWAYS_SEARCH_USER_PATHS=NO
ALWAYS_USE_SEPARATE_HEADERMAPS=NO
APPLE_INTERNAL_DEVELOPER_DIR=/AppleInternal/Developer
APPLE_INTERNAL_DIR=/AppleInternal
@perlguy99
perlguy99 / printObjectMemoryAddress.swift
Created June 21, 2023 21:21 — forked from IamMarik/printObjectMemoryAddress.swift
print object memory address #swift
print(Unmanaged.passUnretained(self).toOpaque())
@perlguy99
perlguy99 / Alamofire.request.error.handling.swift
Last active January 16, 2023 19:52
Alamofire Request Error Handling - From their documentation
Alamofire.request(urlString).responseJSON { response in
guard case let .failure(error) = response.result else { return }
if let error = error as? AFError {
switch error {
case .invalidURL(let url):
print("Invalid URL: \(url) - \(error.localizedDescription)")
case .parameterEncodingFailed(let reason):
print("Parameter encoding failed: \(error.localizedDescription)")
print("Failure Reason: \(reason)")
@perlguy99
perlguy99 / View+LightDarkPreviews.swift
Created January 8, 2022 19:37
View Extension for Light and Dark Previews
extension View {
var previewedInAllColorSchemes: some View {
ForEach(ColorScheme.allCases, id: \.self, content: preferredColorScheme)
}
}
@perlguy99
perlguy99 / iOS_Debugging.md
Last active July 28, 2021 07:21
Debugging Hints, Tips, Tricks
@perlguy99
perlguy99 / SwiftUI_Anyview.md
Last active December 22, 2020 21:36
SwiftUI AnyView vs Group: type erasure in practice

SwiftUI

AnyView vs Group: type erasure in practice

SwiftUI in 100 Days

Key Points

  • Type erasure is the process of hiding the underlying type of some data.
    • This is used often in Swift: we have type erasing wrappers such as AnyHashable and AnySequence, and all they do is act as shells that forward on their operations to whatever they contain, without revealing what the contents are to anything externally.
@perlguy99
perlguy99 / KeyboardAwareModifier.swift
Last active October 23, 2020 04:22
SwiftUI Keyboard Aware Modifier
//
// KeyboardAwareModifier.swift
// KeyboardTest
//
import SwiftUI
import Combine
struct KeyboardAwareModifier: ViewModifier {
@State private var keyboardHeight: CGFloat = 0
@perlguy99
perlguy99 / video-howto.md
Created June 26, 2020 14:34
How to record a video of the Xcode Simulator

To take a video

xcrun simctl io booted recordVideo <filename>.<file extension>

For example:

xcrun simctl io booted recordVideo appVideo.mov

Press ctrl + c to stop recording the video.

@perlguy99
perlguy99 / clean_localizable.sh
Created June 5, 2020 14:57
Clean Localizable Strings (Starting Point)
#!/bin/bash
project_name="CleanLocalizableExample"
development_file="./$project_name/en.lproj/Localizable.strings"
es_duplicates=9
es_match=8
es_not_included=7
sort_and_find_duplicates() {