You are on page 1of 45

Less painful iOS development

Samuel Edwin - Tokopedia


Tweaks
https://github.com/facebook/tweaks
Tweaks - Why?
// NSString *serverUrl = @ws.tokopedia.com;
NSString *serverUrl = @ws-alpha.tokopedia.com;
Tweaks
Server Selection
Tweaks
User Onboarding
Tweaks
User Onboarding

Always show onboarding: YES


Tweaks - Login
Tweaks - OTP
Countdown
Tweaks - OTP
Countdown
Reduced to 5s
Tweaks - Other Usages

- Quick prototyping

- React Native JS bundle configuration


Tweaks - Installation

- _window = [[UIWindow alloc] initWithFrame:[[UIScreen


mainScreen] bounds]];

+ _window = [[FBTweakShakeWindow alloc]


initWithFrame:[[UIScreen mainScreen] bounds]];
FLEX
https://github.com/flipboard/FLEX
FLEX - Network
Debugging
FLEX - Network
Debugging
- Request headers

- Request body

- Response headers

- Response body

- cURL request generator


FLEX - Find Current
View Controller
FLEX - Modify UI
Directly
FLEX - Detect
Memory Leaks
FLEX - Inspect
User Defaults
FLEX - Modify User
Defaults
FLEX - Other Usages

- HTTP cookie inspection

- NSLog inspection

- File browser

- Inspect private API


FLEX - Installation

pod FLEX, :configurations => [Debug]

- (void)applicationDidBecomeActive:(UIApplication *)application {

[FLEXManager.sharedManager showExplorer];

}
Knuff
https://github.com/KnuffApp/Knuff
Knuff - Without

Example: Transaction rejected push notification

- Add to Cart

- Finish payment

- Reject transaction

- Server send push notification payload

- Slow to reproduce
Knuff - Much better!

Example: Transaction rejected push notification

- Put payload and device token to Knuff App

- Send push notification

- Super easy to reproduce


Knuff - Push Notification Debugging
Knuff - Installation (Optional)

pod Knuff

Thats it!
SwiftFormat
https://github.com/nicklockwood/SwiftFormat
SwiftFormat
Without
SwiftFormat
SwiftFormat
Much better!
No more code
style debate!
SwiftFormat - if x {
Rules - // foo
} else {
indent - // bar
- }

if x {
+ // foo
} else {
+ // bar
+ }
SwiftFormat - - if x
- {
Rules // foo
}
braces - else
- {
// bar
}

+ if x {
// foo
}
+ else {
// bar
}
SwiftFormat -
Rules - let foo = 5
+ let foo = 5
consecutiveSpaces
SwiftFormat - var foo: Int {
- get {
Rules - return 5
- }
redundantGet
}

var foo: Int {


+ return 5
}
SwiftFormat -
Rules - if (foo == true) {}
+ if foo == true {}
redundantParens
SwiftFormat -
Rules
- DispatchQueue.main.async(execute: {
trailingClosures // do stuff
- })

+ DispatchQueue.main.async {
// do stuff
+ }
SwiftFormat - Installation Options

- brew install SwiftFormat

- pod SwiftFormat/CLI
SwiftFormat - How to Use

- Command line - swiftformat dir

- Xcode editor extension

- Git pre-commit hook


SwiftLint
https://github.com/realm/SwiftLint/
Defensive
programming
SwiftLint - Rules var aControlThatShouldBeAButton: UIView = UIButton()

var thatButton: UIButton =


force_cast aControlThatShouldBeAButton as! UIButton

error: Force Cast Violation: Force casts should be


avoided. (force_cast)
SwiftLint - Rules
func a() throws {}; try! a()
force_try

error: Force Try Violation: Force tries should be avoided.


(force_try)
protocol CarDelegate {}
SwifLint - Rules class Car {
var delegate: CarDelegate
weak_delegate
init(delegate: CarDelegate) {
self.delegate = delegate
}
}

warning: Weak Delegate Violation: Delegates should be weak to avoid


reference cycles. (weak_delegate)
Thank You!

You might also like