Skip to content

Instantly share code, notes, and snippets.

@DenTelezhkin
DenTelezhkin / main.m
Last active December 26, 2015 23:19
Running XCTests without creating any of application controllers.
static bool isRunningTests()
{
NSDictionary* environment = [[NSProcessInfo processInfo] environment];
NSString* injectBundle = environment[@"XCInjectBundle"];
return [[injectBundle pathExtension] isEqualToString:@"xctest"];
}
int main(int argc, char *argv[])
{
@autoreleasepool
@DenTelezhkin
DenTelezhkin / README.md
Last active July 11, 2016 09:19
CI Rakefile for iOS applications.Prerequisites: xcpretty, shenzhen, cocoapods, testflight, XCTest.Put this Rakefile into directory with your .xcodeproj and run rake. Remove build tasks you don't need in your setup.

Usage

Install dependencies and run tests

rake 

Dependencies, tests, archive in Release configuration and upload to TestFlight

rake testflight 
@DenTelezhkin
DenTelezhkin / gist:beab675d853fcd2fd464
Created July 22, 2014 15:02
Multipart-form PUT request for image upload. NSURLSession, iOS 7
+(void)uploadUserPhoto:(UIImage *)image
success:(void (^)(void))success
failure:(FailureBlock)failure
{
GTSessionManager * manager = [GTSessionManager manager];
NSString* tmpFilename = [NSString stringWithFormat:@"%f", [NSDate timeIntervalSinceReferenceDate]];
NSURL* tmpFileUrl = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:tmpFilename]];
NSString * query = [NSString stringWithFormat:@"%@user?auth_token=%@",[manager.baseURL absoluteString],[[UserManager shared] authToken]];
@DenTelezhkin
DenTelezhkin / README.md
Last active December 8, 2016 10:08
Rakefile for iTunesConnect upload and testing, iOS

What's this stuff about?

This is a build script for installing dependencies, running tests, and uploading your iOS application builds to Apple's iTunesConnect & Testflight.

Used technologies

  • CocoaPods
  • XCTest
  • Ruby gems: xcpretty, deliver, shenzhen
  • Apple's iTunesConnect&Testflight
@DenTelezhkin
DenTelezhkin / NetworkingTest.m
Created March 25, 2014 15:59
Testing networking with OHHTTPStubs and Expecta
@interface BitcoinLoaderSpecs : XCTestCase
@property (nonatomic, strong) RateModel * rate;
@end
@implementation BitcoinLoaderSpecs
- (void)setUp
{
[super setUp];
@DenTelezhkin
DenTelezhkin / Fastfile
Created March 27, 2019 10:33
Fastfile example for MLSDev blog article.
before_all do
cocoapods
scan
end
# Increment build number to current date
lane :set_build_number do
increment_build_number(
build_number: Time.new.strftime("%Y.%m.%d.%H%M")
)
@DenTelezhkin
DenTelezhkin / UIView+extensions.swift
Created March 27, 2019 10:34
IBInspectable example for MLSDev blog articles
extension UIView {
@IBInspectable var cornerRadius: CGFloat {
get { return layer.cornerRadius }
set {
layer.cornerRadius = newValue
layer.masksToBounds = newValue > 0
}
}
@IBInspectable var borderWidth: CGFloat {
@DenTelezhkin
DenTelezhkin / LoadableFromXibView.swift
Created March 27, 2019 10:35
LoadableFromXibView example for MLSDev blog article.
protocol NibDefinable {
var nibName: String { get }
}
extension NibDefinable {
var nibName : String {
return String(self.dynamicType)
}
}
@DenTelezhkin
DenTelezhkin / StackViewExample.swift
Created March 27, 2019 10:36
StackView example for MLSDev blog article
let stacks = [UserProfileStatsView(), SwitchCompanyView(), SendInvitationToCompanyView(), LogoutButtonView()]
stackView.axis = .Vertical
stacks.forEach {
stackView.addArrangedSubview($0)
}
@DenTelezhkin
DenTelezhkin / prepare_icons.sh
Created September 30, 2016 07:56
Slice iOS app icons from 1024x1024 PNG file, originally taken from https://gist.github.com/jessedc/837916#file-ios-icon-png-bash-script. Updated for Xcode 8 - September 2016.
#!/bin/bash
f=$(pwd)
sips --resampleWidth 512 "${f}/${1}" --out "${f}/iTunesArtwork"
sips --resampleWidth 1024 "${f}/${1}" --out "${f}/iTunesArtwork@2x"
sips --resampleWidth 20 "${f}/${1}" --out "${f}/Icon-20.png"
sips --resampleWidth 40 "${f}/${1}" --out "${f}/Icon-20@2x.png"
sips --resampleWidth 60 "${f}/${1}" --out "${f}/Icon-20@3x.png"