Skip to content

Instantly share code, notes, and snippets.

View ManWithBear's full-sized avatar
🐻
Bear with it

Denis Bogomolov ManWithBear

🐻
Bear with it
View GitHub Profile
@ManWithBear
ManWithBear / multi_devices_test.sh
Created April 20, 2018 15:01 — forked from fedejordan/multi_devices_test.sh
Blog01 - Script for run tests in different devices for an iOS project
#!/bin/bash
# Script configuration
devicesArray=(
"iPhone 8"
"iPhone 8 Plus"
"iPhone 5s"
"iPhone X")

FrontRow Style Guide

Principles:

  • Maximize readability
    • Code should be immediately readable by someone not familiar with that area. If you have to continuously refer to documentation, comments or dig into implementation to understand what's happening, the code isn't sufficiently self-descriptive and needs to be improved. When not possible, you must comment. Coding is a team sport, always write with other developers in mind
  • Be aware of the context
  • Use your judgement

There are some hard rules, but good style is context-sensitive.

ACTION = build
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation
@ManWithBear
ManWithBear / delete_all_simulators.sh
Created September 19, 2018 08:18
Script to delete all your simulators
#!/bin/bash
xcrun simctl delete $(xcrun simctl list | grep -o '[0-9A-F]\{8\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{12\}' | xargs)
xcrun simctl delete unavailable
@ManWithBear
ManWithBear / create_simulators
Last active January 17, 2022 15:18
Create my simulators setup
#!/bin/bash
xcrun simctl delete $(xcrun simctl list | grep -o '[0-9A-F]\{8\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{12\}' | xargs)
xcrun simctl delete unavailable
runtime="com.apple.CoreSimulator.SimRuntime.iOS-12-2"
xcrun simctl create "1. Monday (X)" com.apple.CoreSimulator.SimDeviceType.iPhone-X $runtime
xcrun simctl create "2. Tuesday (Air 2)" com.apple.CoreSimulator.SimDeviceType.iPad-Air-2 $runtime
xcrun simctl create "3. Wednesday (8)" com.apple.CoreSimulator.SimDeviceType.iPhone-8 $runtime
xcrun simctl create "4. Thursday (8 Plus)" com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus $runtime
xcrun simctl create "5. Friday (SE)" com.apple.CoreSimulator.SimDeviceType.iPhone-SE $runtime
@ManWithBear
ManWithBear / ReusableXibView.swift
Created November 22, 2018 12:10
Smarty way to init xib views inside other xibs
import UIKit
/// thanks to Badoo
/// https://github.com/badoo/Chatto/blob/master/ChattoAdditions/Source/Input/ReusableXibView.swift
@objc open class ReusableXibView: UIView {
func loadViewFromNib() -> UIView {
let bundle = Bundle(for: type(of: self))
let nib = UINib(nibName: type(of: self).nibName(), bundle: bundle)
let view = nib.instantiate(withOwner: nil, options: nil).first as! UIView
@ManWithBear
ManWithBear / Notes.md
Created May 28, 2019 09:28
iOS Dev notes
@ManWithBear
ManWithBear / flat_folders.sh
Created September 4, 2019 08:32
Recursively move files from subfolders to current folder
Transforms:
./Notification/[email protected]
./Notification/Black.png
./Sign out/Black.png
./Sign out/[email protected]
To:
[email protected]
.Notification_Black.png
.Sign out_Black.png
.Sign [email protected]
@ManWithBear
ManWithBear / Runtime_tests.md
Created October 7, 2019 14:30
How to create runtime tests in swift

You probably can't do it in pure swift since NSInvocation is not part of swift api anymore.

XCTest rely on + (NSArray<NSInvocation *> *)testInvocations function to get list of test methods inside one XCTestCase class. Default implementation as you can assume just find all methods that starts with test prefix and return them wrapped in NSInvocation. (You could read more about NSInvocation here)
So if we want to have tests declared in runtime, this is point of interest for us.
Unfortunately NSInvocation is not part of swift api anymore and we cannot override this method.

If you OK to use little bit of ObjC then we can create super class that hide NSInvocation details inside and provide swift-friendly api for subclasses.

/// Parent.h
@ManWithBear
ManWithBear / add_record_flag.sh
Created October 8, 2019 08:02
Adds -record command line argument to test run in Xcode.
#!/bin/bash
# Add -record flag to iOSUITests test run
# By default run all tests. If test name passed as argument, run tests only for this testcase
# setup destinations
export currentDirectory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Name of simulators to run tests on