Skip to content

Instantly share code, notes, and snippets.

View vitoziv's full-sized avatar
🐙
Writing bugs

Vito vitoziv

🐙
Writing bugs
View GitHub Profile
@lsavino
lsavino / compilation-optimization.md
Last active July 27, 2022 17:44
Compiler Optimizations, Compiling Optimally, and Whole Modules

DEPRECATED for Xcode 10 🎈

(check out What's New in Swift at 11:40, slide 42)

Whole Module Compilation Optimizations: Why these terms are sometimes misleading

When you look up how to compile swift faster for debug builds, people very earnestly give advice that seems contradictory: you should "try using the whole module optimization flag," and also "never use whole module optimization for debugging". [^1]

This is confusing because some of us are using these two general words:

compilation: "turning text into an executable program"

@tehnoir
tehnoir / set_project_profiles.sh
Created April 13, 2016 19:19
Update Xcode project's build settings to point to current provisioning profiles.
#!/bin/bash
##############################################################################################################
### 1. Name your profiles with the convention of ProjectName_TargetName_ConfigurationName.mobileprovision ###
### 2. Create a directory called CodeSign in your project directory ###
### 3. Move all your project's provisioning profiles into the CodeSign directory ###
### ###
### Running this script will update your project file to point to the correct UUIDs of each corresponding ###
### profile in your CodeSign directory. ###
##############################################################################################################
@brucetoo
brucetoo / RealmMigrationDemo.java
Created August 19, 2015 03:27
Realm数据库迁移实例
package com.brucetoo.realmdemo.realmmigration;
import android.app.Application;
import android.util.Log;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import io.realm.RealmMigration;
import io.realm.RealmObject;
import io.realm.internal.ColumnType;
@jspahrsummers
jspahrsummers / GHRunLoopWatchdog.h
Created January 28, 2015 20:50
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
@cromandini
cromandini / universal-framework.sh
Last active February 12, 2024 12:13 — forked from cconway25/gist:7ff167c6f98da33c5352
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
@cconway25
cconway25 / gist:7ff167c6f98da33c5352
Created August 11, 2014 15:06
This run script will build the iphoneos and iphonesimulator schemes and then combine them into a single framework using the lipo tool.
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 -arch x86_64 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
# Step 2. Copy the framework structure to the universal folder
@kostiakoval
kostiakoval / Associated-NSNumber.codesnippet
Last active August 29, 2015 13:57
Associated object. Associated-NSNumber.m and Associated.m are code snippets for creating methods for property with associated object. KKNSObject+Associated.h is a macro that can be use to automatically create associated methods for property.
- (<#type#>)<#propertyName#> {
return [objc_getAssociatedObject(self, _cmd) <#NSNumberMethod#>];
}
- (void)set<#propertyName#>:(<#type#>)object
{
objc_setAssociatedObject(self, @selector(<#propertyName#>), [NSNumber numberWith:object], OBJC_ASSOCIATION_);
}
@steipete
steipete / Macros.h
Last active January 6, 2024 07:24
Declare on your main init that all other init methods should call. It's a nice additional semantic warning. Works with Xcode 5.1 and above. Not tested with earlier variants, but should just be ignored. A reference to this macro shortly appeared in https://developer.apple.com/library/ios/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObj…
#ifndef NS_DESIGNATED_INITIALIZER
#if __has_attribute(objc_designated_initializer)
#define NS_DESIGNATED_INITIALIZER __attribute((objc_designated_initializer))
#else
#define NS_DESIGNATED_INITIALIZER
#endif
#endif
@bomberstudios
bomberstudios / sketch-plugins.md
Last active February 26, 2024 07:02
A list of Sketch plugins hosted at GitHub, in no particular order.
@floriankugler
floriankugler / gist:6870499
Last active September 29, 2023 15:56
Mapping of NSURLConnection to NSURLSession delegate methods. Created by Mattt Thompson.
NSURLConnection | NSURLSession
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connectionShouldUseCredentialStorage: |
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connection:willSendRequestForAuthenticationChallenge: | NSURLSessionDelegate URLSession:didReceiveChallenge:completionHandler:
| N