Skip to content

Instantly share code, notes, and snippets.

@evnik
evnik / Framework2XCFramework.sh
Created December 30, 2020 20:23
This script allows to convert an iOS framework binary to XCFramework
# Copyright (c) 2020 Eugene Berdnikov
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
@lattner
lattner / async_swift_proposal.md
Last active December 28, 2024 11:11 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

@NSExceptional
NSExceptional / XcodeBuildSettingsReference.md
Last active November 14, 2024 02:25
The Xcode Build Settings Reference in a searchable document, as of Xcode 8.3.2

Build settings reference

Active Build Action (ACTION)

A string identifying the build system action being performed.

Additional SDKs (ADDITIONAL_SDKS)

The locations of any sparse SDKs that should be layered on top of the one specified by Base SDK (SDKROOT). If more than one SDK is listed, the first one has highest precedence. Every SDK specified in this setting should be a "sparse" SDK, for example, not an SDK for an entire macOS release.

Alternate Install Group (ALTERNATE_GROUP)

@shaps80
shaps80 / ReusableView.swift
Last active June 18, 2019 18:08
A generic cell provider implementation in Swift
//
// ReusableView.swift
// Pods
//
// Created by Shahpour Benkau on 27/02/2017.
//
//
import UIKit
@steipete
steipete / PSPDFRuntime.mm
Created June 3, 2016 09:45
Main thread checks
PSPDF_EXTERN BOOL PSPDFIsMainThread(void) {
// dispatch_get_current_queue is deprecated because most of the time it's not a good idea to call it.
// NSThread.isMainThread simply calls pthread_main_np so we can save a bit if we call it directly.
PSPDF_DEPRECATED_NOWARN(return pthread_main_np() || dispatch_get_current_queue() == dispatch_get_main_queue();)
@Lutzifer
Lutzifer / replaceNSlocalized.sh
Last active September 18, 2018 15:13
Automatically replace NSLocalizedString(...) in Swift with corresponding tr(...) calls for https://github.com/AliSoftware/SwiftGen. Copy both into the project and call 'sh replaceNSlocalized.sh'
#/bin/sh
# Run this inside the project to replace NSLocalizedString calls with swiftgen calls in all .swift files.
# Do not forget to make a backup before.
find . -type f | grep ".swift" > swiftindex.temp
while IFS= read -r filename
do
grep -o "NSLocalizedString(\"[^\")]*\", comment:\s*\"\")" "$filename" > strings.temp
#include <iostream>
#include "plugins.h"
int main()
{
auto &factory = PluginSystem::PluginFactory::Instance();
auto plugin = factory.GetPlugin("Plugin1");
plugin->DoSomething();
@steipete
steipete / PSPDFBlockAssert.m
Created January 12, 2016 21:56
Check if object is a block - nice for assertions.
PSPDF_EXTERN BOOL PSPDFIsBlock(id _Nullable block) {
static Class blockClass;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
blockClass = [^{} class];
while ([blockClass superclass] != NSObject.class) {
blockClass = [blockClass superclass];
}
});
@evakili
evakili / malloc_unique_ptr.h
Last active March 15, 2024 02:13
A generic unique_ptr with malloc/free
#ifndef MALLOC_UNIQUE_PTR_H
#define MALLOC_UNIQUE_PTR_H
/*
idea borrowed from http://www.codeproject.com/Articles/820931/Using-std-unique-ptr-RAII-with-malloc-and-free
*/
#include<memory>
template<typename T>
#define PSPDF_NOT_DESIGNATED_INITIALIZER() PSPDF_NOT_DESIGNATED_INITIALIZER_CUSTOM(init)
#define PSPDF_NOT_DESIGNATED_INITIALIZER_CUSTOM(initName) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wobjc-designated-initializers\"") \
- (instancetype)initName \
{ do { \
NSAssert2(NO, @"%@ is not the designated initializer for instances of %@.", NSStringFromSelector(_cmd), NSStringFromClass([self class])); \
return nil; \
} while (0); } \
_Pragma("clang diagnostic pop")