Slide 1

Slide 1 text

SwiftTweaks @ikesyo ؔ੢ϞόΠϧΞϓϦݚڀձ #14, 2016-05-25 Wed #ؔϞό

Slide 2

Slide 2 text

@ikesyo • ͍͚͠ΐʔʗ஑ా ᠳ • ͸ͯͳ@ژ౎ • https://twitter.com/ikesyo • https://github.com/ikesyo

Slide 3

Slide 3 text

✨ Contributions ✨ • ReactiveCocoa • Carthage (Commandant, ReactiveTask) • Result • Himotoki • APIKit

Slide 4

Slide 4 text

Tweaking

Slide 5

Slide 5 text

Why? • Parameters adjustment • Animation (location, duration, ...) • Color • Layout • ... • Debug mode • Clear settings • Change API environment • Toggle experimental features • ... • And what you want

Slide 6

Slide 6 text

Facebook/Tweaks

Slide 7

Slide 7 text

Tweaks An easy way to fine-tune, and adjust parameters for iOS apps in development.

Slide 8

Slide 8 text

Objective-C // Value CGFloat animationDuration = FBTweakValue(@"Category", @"Group", @"Duration", 0.5); // Bind FBTweakBind(self.headerView, alpha, @"Main Screen", @"Header", @"Alpha", 0.85); FBTweakBind(webView.scrollView, scrollEnabled, @"Browser", @"Scrolling", @"Enabled", YES); // Action FBTweakAction(@"Player", @"Audio", @"Volume", ^{ NSLog(@"Action selected."); });

Slide 9

Slide 9 text

Swift // FBTweak~~ are macro, so those can't be used in Swift let tweak = FBTweak(identifier: "com.tweaks.example.advanced") tweak.name = "Advanced settings" tweak.defaultValue = false let collection = FBTweakCollection(name: "Enable"); collection.addTweak(tweak) let category = FBTweakCategory(name: "Settings") category.addTweakCollection(collection) let store = FBTweakStore.sharedInstance() store.addTweakCategory(category) tweak.addObserver(self) func tweakDidChange(tweak: FBTweak!) { self.advancedSettingsEnabled = tweak.currentValue as Bool }

Slide 10

Slide 10 text

!!!

Slide 11

Slide 11 text

Khan/SwiftTweaks

Slide 12

Slide 12 text

SwiftTweaks Tweak your iOS app without recompiling! • Supported types • Bool • Int • CGFloat • Double • UIColor • Group template • Floating window

Slide 13

Slide 13 text

Steps 1. Create a TweakLibraryType. 2. Reference that TweakLibraryType in your code to use a Tweak. 3. Use the TweakWindow in your AppDelegate.

Slide 14

Slide 14 text

Make your TweakLibrary public struct ExampleTweaks: TweakLibraryType { public static let colorTint = Tweak( "General", "Colors", "Tint", UIColor.blueColor()) public static let marginHorizontal = Tweak( "General", "Layout", "H. Margins", defaultValue: 15, min: 0) public static let marginVertical = Tweak( "General", "Layout", "V. Margins", defaultValue: 10, min: 0) public static let featureFlagMainScreenHelperText = Tweak( "Feature Flags", "Main Screen", "Show Body Text", true) public static let buttonAnimation = SpringAnimationTweakTemplate( "Animation", "Button Animation") ... }

Slide 15

Slide 15 text

Make your TweakLibrary public struct ExampleTweaks: TweakLibraryType { ... public static let defaultStore: TweakStore = { let allTweaks: [TweakClusterType] = [colorTint, marginHorizontal, marginVertical, featureFlagMainScreenHelperText, buttonAnimation ] #if DEBUG let tweaksEnabled: Bool = true #else let tweaksEnabled: Bool = false #endif return TweakStore( tweaks: allTweaks, enabled: tweaksEnabled ) }() }

Slide 16

Slide 16 text

Using Your TweakLibrary // Assign button.tintColor = ExampleTweaks.assign(ExampleTweaks.colorTint) // Bind ExampleTweaks.bind(ExampleTweaks.colorTint) { button.tintColor = $0 } // Bind multiple let tweaksToWatch: [TweakType] = [ ExampleTweaks.marginHorizontal, ExampleTweaks.marginVertical ] ExampleTweaks.bindMultiple(tweaksToWatch) { let horizontal = ExampleTweaks.assign(ExampleTweaks.marginHorizontal) let vertical = ExampleTweaks.assign(ExampleTweaks.marginVertical) scrollView.contentInset = UIEdgeInsets( top: vertical, right: horizontal, bottom: vertical, left: horizontal) }

Slide 17

Slide 17 text

Roadmaps Let's contribute! ✨ • "Backups" feature • Support String as a TweakViewDataType • Add a "closure" Tweak Type • Design & Build tvOS UI • Design & Build iPad UI

Slide 18

Slide 18 text

☺☺☺

Slide 19

Slide 19 text

!" Happy Tweaking!! "!

Slide 20

Slide 20 text

Thank you❗"