Skip to content

Instantly share code, notes, and snippets.

View perlguy99's full-sized avatar

Brent Michalski perlguy99

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 / Alamofire.request.error.handling.swift
Last active May 14, 2025 01:28
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 / AddingViewInspector.md
Last active July 24, 2024 15:23
Adding ViewInspector to your project

HowTo add ViewInspector to a Project

Shout Out!

First off, I need to give a shout out to Jon Reid and Quality Coding. His blog at Quality Coding Blog it was through Jon's posts and live coding sessions where all of this code got fleshed out.

1. Add ViewInspector branch 0.10.0 to your project

  • For the Target, choose your Test Target

2. Create a file named TestableView.swift with the following contents:

@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 / 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.