Skip to content

Instantly share code, notes, and snippets.

View romainbriche's full-sized avatar

Romain Briche romainbriche

  • San Francisco, California
View GitHub Profile
# TODO First try it like below and check if Xcode is happy with the result.
# I don’t remember if the new config /has/ to be defined on the project-level as well.
# Add a duplicate of the target-level Release config to each target.
project.targets.each do |target|
build_config = project.new(Xcodeproj::Project::XCBuildConfiguration)
build_config.name = 'AdHoc'
build_config.build_settings = target.build_settings('Release')
target.build_configurations << build_config
end
@ZevEisenberg
ZevEisenberg / fixXcode.sh
Last active January 6, 2024 07:31
Function to fix Xcode’s code snippets library by replacing it with the one from the ZevEisenberg/ios-convenience git repo
function fixXcode
{
pushd > /dev/null
cd
xcodepath=`xcode-select --print-path`/..
destination=$xcodepath/Frameworks/IDEKit.framework/Versions/A/Resources/SystemCodeSnippets.codesnippets
shouldRelaunchXcode=false
if [[ `osascript -e 'tell app "System Events" to count processes whose name is "Xcode"'` == 1 ]]; then
@n-b
n-b / selfcompile.m
Last active April 29, 2019 03:43
A simple self-compiling objective-c file
/*/../bin/ls > /dev/null
COMPILED=${0%.*}
clang $0 -o $COMPILED -framework Foundation;
$COMPILED; rm $COMPILED; exit;
*/
#import <Foundation/Foundation.h>
int main(int argc, char *argv[])
@mattt
mattt / uiappearance-selector.md
Last active February 7, 2025 15:27
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@0xced
0xced / NSObject+Subclasses.h
Last active September 4, 2017 06:37
NSObject category to get subclasses
#import <Foundation/Foundation.h>
@interface NSObject (Subclasses)
+ (NSSet *) subclasses_xcd;
@end
@justin
justin / filter.json
Created March 5, 2013 04:17
A sample filter description for Wolfpack.
{
"formatVersion" : 1,
"filterIdentifier" : "filter.com.secondgear.Noir",
"filterName" : "Noir",
"filterDescription" : "FILTER_DESCRIPTION",
"requirements" : [
"iOS > 6.0"
],
"organizationName" : "Justin Williams",
"organizationURL" : "http://carpeaqua.com",
@steipete
steipete / gist:5063602
Last active December 14, 2015 09:18
Xamarin Native Code porting, thoughts.
  1. Better error handling. It took me 3 hours to figure out that the crash in the constructor happened because of out NSError. It did not directly crash on calling that method, but sometimes afterwards. The broken call in question was TryLoadAnnotationsFromFileWithError inside PSPDFFileAnnotationProvider's constructor - but it did not crash there. The class PSPDFFileAnnotationProvider has been overridden and that constructor was called as well, and THEN everything crashed with an opaque error. The 'fix' is also super messy (https://github.com/Krumelur/MonoTouch-PSPDFKit-bindings/commit/a2b225c4fd6ba7b7a0bdcd966bd39b1cc3f3e724#L1R1158). NSError** is a very common pattern in Cocoa to relay errors, there should be a builtin-way to address that. (sth. like bool TryLoadAnnotationsFromFileWithError (out [NullAllowed] NSError error);)

  2. Exceptions should show the native stack trace. It's not that hard to symbolicate this on the fly. Currently once you get sth like this... you're basically f*cked. http://cl.ly/ima

@gavrix
gavrix / gist:5054182
Created February 28, 2013 04:28
Script integrating OCLint into XCode. Put it in "Run script" build phase.
source ~/.bash_profile
hash oclint &> /dev/null
if [ $? -eq 1 ]; then
echo >&2 "oclint not found, analyzing stopped"
exit 1
fi
@mpospese
mpospese / CGRectIntegralScaled.m
Created February 28, 2013 03:34
Pixel aligns rectangles, taking the device's screen scale into account.
CGRect CGRectIntegralScaledEx(CGRect rect, CGFloat scale)
{
return CGRectMake(floorf(rect.origin.x * scale) / scale, floorf(rect.origin.y * scale) / scale, ceilf(rect.size.width * scale) / scale, ceilf(rect.size.height * scale) / scale);
}
CGRect CGRectIntegralScaled(CGRect rect)
{
return CGRectIntegralScaledEx(rect, [[UIScreen mainScreen] scale]);
}
@rnystrom
rnystrom / gist:5052675
Created February 27, 2013 23:04
Masking a chip out of a UIView.
- (void)maskChip {
UIGraphicsBeginImageContextWithOptions(self.containerView.bounds.size, NO, [UIScreen mainScreen].scale);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGRect frame = self.containerView.bounds;
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 0, 0);
CGPathAddLineToPoint(path, NULL, frame.size.width / 2.f - 6, 0);
CGPathAddLineToPoint(path, NULL, frame.size.width / 2.f, 6);
CGPathAddLineToPoint(path, NULL, frame.size.width / 2.f + 6, 0);