High Performance iOS Apps: Optimize Your Code for Better Apps

High Performance iOS Apps: Optimize Your Code for Better Apps

by Gaurav Vaish
High Performance iOS Apps: Optimize Your Code for Better Apps

High Performance iOS Apps: Optimize Your Code for Better Apps

by Gaurav Vaish

Paperback

$49.99 
  • SHIP THIS ITEM
    Qualifies for Free Shipping
  • PICK UP IN STORE
    Check Availability at Nearby Stores

Related collections and offers


Overview

Ready to build mobile apps that out-perform the rest? If you’re an iOS developer with app-building experience, this practical guide provides tips and best practices to help you solve many common performance issues. You’ll learn how to design and optimize iOS apps that deliver a smooth experience even when the network is poor and memory is low.

Today’s picky users want fast and responsive apps that don’t hog resources. In this book, author Gaurav Vaish demonstrates methods for writing optimal code from an engineering perspective, using reusable Objective-C code that you can use right away. Up your game and create high-performance native iOS apps that truly stand out from the crowd.

  • Measure key performance indicators—attributes that constitute and affect app performance
  • Write efficient apps by minimizing memory and power consumption, and explore options for using available CPU cores
  • Optimize your app’s lifecycle and UI, as well as its networking, data sharing, and security features
  • Learn about application testing, debugging and analysis tools, and monitoring your app in the wild
  • Collect data from real users to analyze app usage, identify bottlenecks, and provide fixes
  • Use iOS 9 upgrades to improve your app’s performance

Product Details

ISBN-13: 9781491911006
Publisher: O'Reilly Media, Incorporated
Publication date: 07/07/2016
Pages: 462
Product dimensions: 7.00(w) x 9.10(h) x 1.30(d)

About the Author

Gaurav was introduced to GW-BASIC when he was 12yrs old and he fell in love with its simplicity. Over 20yrs later, he has programmed in most of the major languages, on every popular operating system and probably for every popular device today.



He works in the Mobile and Emerging Products (MEP) group at Yahoo headquarters and more specifically in the Mobile SDK team whose charter is to create optimized reusable solutions that are incorporated across Yahoo mobile apps, run on dozens of variety of devices and used by hundreds of millions of users every month.



He started his career in 2002 with Adobe Systems India working in their engineering solutions group. In 2005, he started his own company, Edujini Labs, focusing on corporate training and collaborative learning.
He holds a B. Tech. in Electrical Engineering with a specialization in Speech Signal Processing from IIT Kanpur, India.



He is the author of the books "Reflections by IITians" and "Getting Started with NoSQL". He runs his personal blog at http://www.m10v.com. He currently lives in Silicon Valley.

Table of Contents

Preface xiii

Part I Getting Started

1 Performance in Mobile Apps 3

Defining Performance 4

Performance Metrics 4

Memory 4

Power Consumption 4

Initialization Time 5

Execution Speed 5

Responsiveness 6

Local Storage 6

Interoperability 7

Network Condition 8

Bandwidth 9

Data Refresh 9

Multiuser Support 9

Single Sign-on 11

Security 11

Crashes 11

App Profiling 12

Sampling 12

Instrumentation 12

Measurement 12

Project and Code Setup 13

Crash Reporting Setup 14

Instrumenting Your App 15

Logging 20

Summary 23

Part II Core Optimizations

2 Memory Management 27

Memory Consumption 28

Stack Size 28

Heap Size 29

Memory Management Model 32

Autoreleasing Objects 34

Autorelease Pool Blocks 35

Automatic Reference Counting 39

Rules of ARC 41

Reference Types 42

Variable Qualifiers 43

Property Qualifiers 44

Getting Your Hands Dirty 45

Photo Model 45

Storyboard Update 46

Method Implementations 47

Output Analysis 49

Zombies 50

Rules of Memory Management 51

Retain Cycles 52

Rules to Avoid Retain Cycles 53

Common Scenarios for Retain Cycles 54

Observers 67

Returning Errors 70

Weak Type: id 71

Solution to the Problem 72

Object Longevity and Leaks 74

Singletons 74

Finding Mystery Retains 77

Best Practices 78

Memory Usage in Production 79

Summary 80

3 Energy 81

CPU 81

Network 83

Location Manager and GPS 87

Optimal Initialization 89

Turn Off Inessential Features 90

Use Network Only If Essential 92

Background Location Services 92

NSTimers, NSThreads, and Location Services 93

Restart After App Kill 93

Screen 94

Animation 94

Video Play 94

Multiple Screens 94

Other Hardware 99

Battery Level and State-Aware Code 100

Profiling for Energy Use 102

Best Practices 103

Summary 106

4 Concurrent Programming 107

Threads 107

The Cost of Threads 108

Kernel Data Structures 108

Stack Size 108

Creation Time 109

CCD 109

Operations and Queues 110

Thread-Safe Code 112

Atomic Properties 112

Synchronized Blocks 113

Locks 115

Use Reader-Writer Locks for Concurrent Reads and Writes 121

Use Immutable Entities 123

Have a Central State Updater Service 128

State Observers and Notifications 134

Prefer Async over Sync 139

Summary 141

Part III iOS Performance

5 Application Lifecycle 145

App Delegate 145

Application Launch 147

First Launch 150

Cold Start 158

Warm Launch 166

Launch After Upgrade 169

Push Notifications 169

Remote Notifications 169

Local Notifications 173

Background Fetch 174

Summary 177

6 User Interface 179

View Controller 181

View Load 183

View Hierarchy 184

View Visibility 187

View 189

UILabel 191

UIButton 192

UIImageView 194

UITable View 195

UI Web View 199

Custom Views 203

Auto Layout 210

Size Classes 212

New Interaction Features in iOS 8 217

Interactive Notifications 217

App Extensions 219

Summary 222

7 Network 223

Metrics and Measurement 223

DNS Lookup Time 224

SSL Handshake Time 226

Network Type 227

Latency 234

Networking API 237

App Deployment 238

Servers 238

Request 239

Data Format 240

Tools 241

Network Link Conditioner 241

AT&T Application Resource Optimizer 243

Charles 245

Summary 248

8 Data Sharing 251

Deep Linking 252

Pasteboards 258

Sharing Content 261

Document Interaction 262

Activities 271

iOS 8 Extensions 274

Configuration for Action and Share Extensions 276

Action Extensions 277

Share Extensions 278

Document Provider Extension 282

App Groups 287

Summary 289

9 Security 291

App Access 292

Anonymous Access 292

Authenticated Access 294

Network Security 299

Use HTTPS 299

Use Certificate Pinning 300

Local Storage 305

Data Sharing 312

Security and App Performance 312

Checklist 313

Summary 315

Part IV Beyond Code

10 Testing and Release 319

Test Types 319

Definitions 320

Unit Testing 321

Setup 321

Writing Unit Tests 323

Code Coverage 325

Asynchronous Operations 330

Xcode 6 Bonus: Performance Unit Tests 331

Dependency Mocking 333

Other Frameworks 337

Functional Testing 338

Setup 339

Writing Functional Tests 341

Project Structure 344

Dependency Isolation 345

Testing and Component Design 347

Continuous Integration and Automation 349

Best Practices 351

Performance Testing 352

Summary 355

11 Tools 357

Accessibility Inspector 358

Xcode Accessibility Inspector 359

iOS Accessibility Inspector 360

Instruments 363

Using Instruments 364

Activity Monitor 367

Allocations 369

Leaks 372

Network 374

Time Profiler 374

Xcode View Debugger 375

PonyDebugger 377

Charles 382

Summary 388

12 Instrumentation and Analytics 389

Vocabulary 390

Instrumentation 391

Planning 392

Implementation 395

Deployment 398

Analytics 398

Real User Monitoring 399

Analytics Versus Real User Monitoring 399

Using RUM 399

Summary 400

Part V iOS9

13 iOS9 403

Application Lifecycle 403

Universal Links 404

Search 407

Search Best Practices 412

User Interface 414

UIKit Framework 414

Safari Services Framework 418

Extensions 421

Content Blocker Extension 422

Spotlight Index Extension 426

App Thinning 426

Slicing 427

On Demand Resources 427

Bitcode 431

Summary 432

Index 433

From the B&N Reads Blog

Customer Reviews