Skip to content

Instantly share code, notes, and snippets.

View rpassis's full-sized avatar

Rogerio de Paula Assis rpassis

  • ANZx
  • Sunshine Beach, Australia
View GitHub Profile
@rpassis
rpassis / AnyPublisher+Extension.swift
Created September 1, 2021 22:23 — forked from IanKeen/AnyPublisher+Extension.swift
Extension to create an AnyPublisher to easily 'lift' async code into Combine
extension AnyPublisher where Failure: Error {
struct Subscriber {
fileprivate let send: (Output) -> Void
fileprivate let complete: (Subscribers.Completion<Failure>) -> Void
func send(_ value: Output) { self.send(value) }
func send(completion: Subscribers.Completion<Failure>) { self.complete(completion) }
}
init(_ closure: (Subscriber) -> AnyCancellable) {
import Combine
import ObjectiveC
import UIKit
private var eventSubjectKey = "viewcontroller_lifecycle_subject"
private var swizzlingPerformed = false
private final class LifecycleSubjectBag: NSObject {
let viewDidLoadSubject = PassthroughSubject<Void, Never>()
let viewWillAppearSubject = PassthroughSubject<Bool, Never>()
@rpassis
rpassis / xcbuild-debugging-tricks.md
Created March 22, 2021 14:23 — forked from ddunbar/xcbuild-debugging-tricks.md
Xcode new build system debugging tricks

New Build System Tricks

Command Line

alias xcbuild=$(xcode-select -p)/../SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild
# THIS DOESNT WORK YET: xcbuild openIDEConsole  # … then switch to Xcode ➡️
xcbuild showSpecs
xcbuild build <foo.pif> [—target <target>]
@rpassis
rpassis / BetterXcodeJumpToCounterpartSwift.org
Created November 17, 2019 03:48 — forked from danielmartin/BetterXcodeJumpToCounterpartSwift.org
Add support for a better Xcode's Jump to Next Counterpart in Swift

If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).

You can do this in recent versions of Xcode by setting a configuration default.

From a terminal, just type this command and press Enter:

defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View"
@rpassis
rpassis / lldb_cheat_sheet.md
Created November 6, 2018 19:42 — forked from ryanchang/lldb_cheat_sheet.md
LLDB Cheat Sheet

LLDB Cheat Sheet

A complete gdb to lldb command map.

Print out

  • Print object
(lldb) po responseObject
(lldb) po [responseObject objectForKey@"state"]
  • p - Print primitive type
//
// EmitWhile.swift
//
// Created by Daniel Tartaglia on 09/06/2018.
// Copyright © 2018 Daniel Tartaglia. MIT License.
//
import RxSwift
/**
@rpassis
rpassis / HKT.swift
Created August 12, 2018 19:29 — forked from anandabits/HKT.swift
Emulating HKT in Swift
// This example shows how higher-kinded types can be emulated in Swift today.
// It acheives correct typing at the cost of some boilerplate, manual lifting and an existential representation.
// The technique below was directly inspired by the paper Lightweight Higher-Kinded Polymorphism
// by Jeremy Yallop and Leo White found at http://ocamllabs.io/higher/lightweight-higher-kinded-polymorphism.pdf
/// `ConstructorTag` represents a type constructor.
/// `Argument` represents an argument to the type constructor.
struct Apply<ConstructorTag, Argument> {
/// An existential containing a value of `Constructor<Argument>`
/// Where `Constructor` is the type constructor represented by `ConstructorTag`
@rpassis
rpassis / PagingCollectionViewController.swift
Created May 15, 2018 07:04 — forked from michaelevensen/PagingCollectionViewController.swift
An example of perfectly paging horizontal UICollectionViewController with overflowing cells. Works great with Storyboard — no need to set any specific attributes, just add this Class to the Controller and set your desired size for the cells like you would normally.
import UIKit
private let reuseIdentifier = "Cell"
class CollectionViewController: UICollectionViewController {
/* Custom scrollView for paging */
let pagingScrollView = UIScrollView()
/* Return item size */
@rpassis
rpassis / RxStore.swift
Created August 8, 2017 13:50 — forked from Odrakir/RxStore.swift
ReSwift + Rx
import Foundation
import RxSwift
public class RxStore: StoreSubscriber {
private var stateObservable:Observable<AppState> {
return subject.asObserver()
.shareReplay(1)
}
private var subject = PublishSubject<AppState>()
@rpassis
rpassis / universal-framework.sh
Created September 20, 2016 12:24 — forked from cromandini/universal-framework.sh
This run script will build the iphoneos and iphonesimulator schemes and then combine them into a single framework using the lipo tool (including all the Swift module architectures).
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build