This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Add this to a custom build phase script to enable preprocessing plist files. | |
# | |
# This takes as input all the input files from the build phase script | |
# and runs the preprocessor using the token definitions from the GCC_PREPROCESSOR_DEFINITIONS | |
# enviroment variable. | |
# | |
# This allows you to have the following plist: | |
# | |
# <dict> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: | |
// $/usr/bin/xcrun --sdk macosx swift replacePlistEnvironmentVariables.swift "$inputfile.plist" "$outputfile" | |
// This will replace all the referenced enviroment variables with their value, for example: | |
// <string>$(A_VARIABLE)</string> | |
import Foundation | |
enum ScriptError: Error { | |
case invalidPlistArgument(argument: URL) | |
case sameInputAndOutptFile | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example of a convient method to allow declaring | |
// the view modifiers at the begining of the view instance | |
// instead at the end. | |
extension VStack { | |
static func with<T: View>(modifiers: (Self) -> T, alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil, @ViewBuilder content: () -> Content) -> some View { | |
modifiers(VStack(alignment: alignment, | |
spacing: spacing, | |
content: content)) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hold the filter and the closure that updates its value | |
var filtersAndValueUpdaters: [ (Filter, ((Float, Int) -> Void)) ] = [] | |
// The selected filter has also the closure that updates its value | |
var selectedfilter: (Filter, (Float, Int) -> Void) | |
let filterA = FilterA() | |
filtersAndValueUpdaters.append((filterA, { [weak filterA] value, _ in | |
filterA?.param = value | |
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Helper macros to convert a preprocessor token to String | |
#define xstr(s) str(s) | |
#define str(s) #s | |
// Example of compile time assertions to validate that tha macro argument was not empty | |
// and avoid building a application that will fail at runtime | |
// Clang and gcc are both able to compute this at compile-time, you can use sizeOf() | |
// instead of the build-in method here. | |
_Static_assert(__builtin_strlen(xstr(OAUTH_CLIENT_ID)) > 0, | |
"The OAUTH_CLIENT_ID is missing"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UIViewControllerTransitionCoordinatorMocked: NSObject, UIViewControllerTransitionCoordinator { | |
var animateWasCalled = false | |
func animate(alongsideTransition animation: ((UIViewControllerTransitionCoordinatorContext) -> Void)?, completion: ((UIViewControllerTransitionCoordinatorContext) -> Void)? = nil) -> Bool { | |
animateWasCalled = true | |
if let completion = completion { | |
completion(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Combine | |
var dispatchGroup = DispatchGroup() | |
dispatchGroup.enter() | |
DispatchQueue.global().asyncAfter(deadline: .now() + 3, execute: { | |
dispatchGroup.leave() | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'xcodeproj' | |
require 'set' | |
project_file, target_name = ARGV | |
# open the project | |
project = Xcodeproj::Project.open(project_file) | |
# find the target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://github.com/CocoaPods/Specs.git' | |
platform :ios, '9.0' | |
use_frameworks! | |
target 'TargetName' do | |
end | |
class Pod::Installer | |
# The only way to run my custom method after the pod integrates with the project (http://blog.bigbinary.com/2012/01/08/alias-vs-alias-method.html) | |
# Repace the method implementation integrate_user_project with ours |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit=`git rev-parse --short HEAD` | |
branch=`git rev-parse --abbrev-ref HEAD` | |
build=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}"` | |
version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${INFOPLIST_FILE}"` | |
function processIcon() { | |
export PATH=$PATH:/usr/local/bin | |
base_file=$1 | |
base_path=`find ${SRCROOT}/DominosOrder -name $base_file` | |
flag_image=`find ${SRCROOT}/DominosOrder -name top_left_flag.png` |
NewerOlder