geek-is-stupid iOS, Objective, Swift tricks and more... https://geek-is-stupid.github.io iOS Unit-Test Tips & Tricks After few years working with iOS Unit-Test I conducted some tips & tricks to help to write a reliable & effectively unit-test. Time-out should be 0.1 rather than 1 or 3 waitForExpectations(timeout: 0.1) { _ in } wait(for: [expectation], timeout: 0.1) Apple does provide this in XCTest to sever all... Sun, 24 Jan 2021 00:00:00 -0800 https://geek-is-stupid.github.io/2021-01-24-iOS-UnitTest-Tips-and-Tricks/ https://geek-is-stupid.github.io/2021-01-24-iOS-UnitTest-Tips-and-Tricks/ iOS UITextView for Flutter Currently there is no TextView for Flutter, so we have to have an injection native TextView from iOS & Android to Flutter project. PlaformView & PlaformChannel https://flutter.dev/docs/development/platform-integration/platform-channels This is an API from Flutter to create Widgets from Native Views! And the way how Dart & iOS/Android communicate to each order... Fri, 14 Aug 2020 00:00:00 -0700 https://geek-is-stupid.github.io/2020-08-14-iOS-UITextView-for-Flutter/ https://geek-is-stupid.github.io/2020-08-14-iOS-UITextView-for-Flutter/ Transfer decelerating of UIScrollView to another UIScrollView When the dragging of Outer UIScrollView is ended, and it continues decelerating, we want to transfer that decelerating to the Nested UIScrollView to make users feel they’re only one UIScrollView Decelerator I was inspired by this nice article about Deceleration mechanics of UIScrollView So this article will show you how... Wed, 06 May 2020 00:00:00 -0700 https://geek-is-stupid.github.io/2020-05-06-Transfer-decelerating-of-UIScrollView-to-another-UIScrollView/ https://geek-is-stupid.github.io/2020-05-06-Transfer-decelerating-of-UIScrollView-to-another-UIScrollView/ Generate Test Coverage by Feature (Folder) with Slather Continue with Slather to generate test coverage reports for Xcode projects & hook it into CI, and from time to time you wonder how to generate the test for only your features which are contributed by you or your team. Get all test coverage percentage: Collecting the test coverage percentage... Fri, 27 Mar 2020 00:00:00 -0700 https://geek-is-stupid.github.io/2020-03-27-Generate-test-coverage-by-folder-with-Slather/ https://geek-is-stupid.github.io/2020-03-27-Generate-test-coverage-by-folder-with-Slather/ 0.1 over 3 seconds for Unit Test asynchronous time-out 0.1 over 3 seconds! Unit! Not Integration Just remind that we’re writing a UNIT test, which means test within a method, a small piece of code, we’re not trying to make an integration test to test multiple levels of code so it should not take that long. If your test... Wed, 18 Mar 2020 00:00:00 -0700 https://geek-is-stupid.github.io/2020-03-18-Unit-Test-asynchronous-timeout-0-1-seconds/ https://geek-is-stupid.github.io/2020-03-18-Unit-Test-asynchronous-timeout-0-1-seconds/ Open deeplink in iOS UI Test UI testing is the best way to verify how your iOS application working in Production environments and how it looks like when integrating with other services! There is an important feature that every e-commerce mobile applications need to included to do campaign marketing, it’s a deep link! So today we... Sat, 21 Sep 2019 00:00:00 -0700 https://geek-is-stupid.github.io/2019-09-21-how-to-test-open-deeplink-with-XCUITests/ https://geek-is-stupid.github.io/2019-09-21-how-to-test-open-deeplink-with-XCUITests/ How to get an iOS application's Scheme URL? From time to time we have to implement a feature that we have to open external apps from our apps! So here are some steps to extract an iOS application’s scheme URL Step 1: Download the partner’s iOS app to your iPhone Step 2: On your laptop, download iMazing application... Sat, 21 Sep 2019 00:00:00 -0700 https://geek-is-stupid.github.io/2019-09-21-how-to-get-iOS-app-scheme-url/ https://geek-is-stupid.github.io/2019-09-21-how-to-get-iOS-app-scheme-url/ Reduce iOS app's loading time by using 'staticlib' with CocoaPods In many of us, we’re iOS developers who are desire to reduce your app’s loading time. Many and many articles were written to gave you some tricks & tips to improve it, you can check it here Slow App Startup Times, Someday I go through this WWDC video Optimizing App... Tue, 06 Aug 2019 00:00:00 -0700 https://geek-is-stupid.github.io/2019-08-06-how-to-reduce-loading-time-by-using-staticlib-with-cocoapods/ https://geek-is-stupid.github.io/2019-08-06-how-to-reduce-loading-time-by-using-staticlib-with-cocoapods/ Way to approach Unit Tests in iOS development 🌡 Unit Tests I and you and many developers are too familiar with this level of testing, someone might know, someone might doing it everyday. But how to do it productivity? How to do it in a saving time? then it gonna need you practice a lot with Unit Tests.... Sat, 20 Apr 2019 00:00:00 -0700 https://geek-is-stupid.github.io/2019-04-20-way-to-approach-unit-tests-in-iOS-developmemt/ https://geek-is-stupid.github.io/2019-04-20-way-to-approach-unit-tests-in-iOS-developmemt/ Mocking for tests in iOS development 🧪 Mocking We might have some best practices from Way to approach Unit Tests in iOS development. Now we go to the details of mocking 🥳 What is Mocking? Mocking is creating objects that simulate the behavior of real objects! The mocking object is used to keep your dependencies out... Wed, 03 Apr 2019 00:00:00 -0700 https://geek-is-stupid.github.io/2019-04-03-mocking-for-test-in-ios-development/ https://geek-is-stupid.github.io/2019-04-03-mocking-for-test-in-ios-development/ How to render images and videos for App Review in iTunes Connect 🏞 Render images screenshot App Review with simulator 📱 ➡️ You’re able to use ⌘ + S with Simulators. ➡️ Or you can use io in simctl, following these commands: xcrun simctl io booted screenshot 🎞 Render videos with simulator 📱 Steps: 1️⃣ Launch your simulator 2️⃣ Run this xcrun... Sun, 03 Mar 2019 00:00:00 -0800 https://geek-is-stupid.github.io/2019-03-03-how-to-render-images-video-for-app-review-itunes-connect/ https://geek-is-stupid.github.io/2019-03-03-how-to-render-images-video-for-app-review-itunes-connect/ App crashes 'NSInternalInconsistencyException' while calling 'reloadRows(at:with:)' ⚡️ Problems Sometime I got a lot of crashes related to reloadRows(at:with:) due to the unsync between current data in UITableView and the data from dataSource Fatal Exception: NSInternalInconsistencyException Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update... Thu, 28 Feb 2019 00:00:00 -0800 https://geek-is-stupid.github.io/2019-02-28-app-crashes-when-table-view-reload-rows-at-index-path/ https://geek-is-stupid.github.io/2019-02-28-app-crashes-when-table-view-reload-rows-at-index-path/ 0x8badf00d - "ate bad food" 🤮 Someday you go to the office and immediately you get a message from you boss that telling you the app got some weird crashes with the logs look like below: Exception Type: EXC_CRASH (SIGKILL) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d Termination Description: SPRINGBOARD,... Mon, 15 Oct 2018 00:00:00 -0700 https://geek-is-stupid.github.io/2018-10-15-0x8badf00d-ate-bad-food/ https://geek-is-stupid.github.io/2018-10-15-0x8badf00d-ate-bad-food/ How to measure loading time for iOS app? There is a simple trick to show your app loading time included dylib loading time, rebase/binding time, ObjC setup time, initializer time, … Here how to setup: 1: Edit scheme 2: Add new Environment Variables with DYLD_PRINT_STATISTICS 3: Run and view in your console to see the results! Thu, 11 Oct 2018 00:00:00 -0700 https://geek-is-stupid.github.io/2018-10-11-how-to-measure-loading-time-for-ios-app/ https://geek-is-stupid.github.io/2018-10-11-how-to-measure-loading-time-for-ios-app/ Translating 'hidden' symbol names back to their original names by using atos + dSYM? Problems As we know that sometimes we got a crash with its stack trace which contains only the address on memories of some objects or some methods, without any line number of your implementation, then how we can indicate which part in your project raises the crash? 2018-03-20 04:09:03.858000000 410... Thu, 03 May 2018 00:00:00 -0700 https://geek-is-stupid.github.io/2018-05-03-how-to-translating-hidden-symbol-names-back-to-their-original-names-by-using-atos-dsym/ https://geek-is-stupid.github.io/2018-05-03-how-to-translating-hidden-symbol-names-back-to-their-original-names-by-using-atos-dsym/ How to mock a completion block in OCMock? Problems My dependency has a completion block, and inside the implementation of that block I do some logics, so how my test needs to make sure it calls all the logics? - (void)doSomething { [self.myService requestWithCompletion:^void(NSError *error) { [self.myEvent handleError:error]; }]; } NSInvocation + OCMStub - (void)testDoSomething { [OCMStub([self.myServiceMock requestWithCompletion:[OCMArg... Mon, 05 Mar 2018 00:00:00 -0800 https://geek-is-stupid.github.io/2018-03-05-how-to-mock-a-completion-block-in-OCMock/ https://geek-is-stupid.github.io/2018-03-05-how-to-mock-a-completion-block-in-OCMock/ How to catch the crash's stack trace? Problems How to log down the crash trace for investigation? 2018-03-20 04:09:03.858000000 410 30735 [2]: Collection <__NSArrayM: 0x13d5493c0> was mutated while being enumerated. 2018-03-20 04:09:03.864000000 410 30735 [2]: Stack Trace: ( 0 CoreFoundation 0x000000018635b17c <redacted> + 148 1 libobjc.A.dylib 0x00000001855a4528 objc_exception_throw + 56 2 CoreFoundation 0x000000018635a7f0 <redacted> + 0 3... Wed, 21 Feb 2018 00:00:00 -0800 https://geek-is-stupid.github.io/2018-02-21-how-to-catch-crash-trace/ https://geek-is-stupid.github.io/2018-02-21-how-to-catch-crash-trace/ How to test C/C++ functions by using Objective-C? Problems I guess that you already saw some C/C++ functions like these get called in Objective-C :] int status; change_network_status(status) or even GCD: dispatch_async(queue, ^{ //... }); The problem here is how you can make sure that the C/C++ functions or the block of dispatch_async get called? How we can... Sun, 17 Dec 2017 00:00:00 -0800 https://geek-is-stupid.github.io/2017-12-17-how-to-test-c-methods-by-using-objective-c/ https://geek-is-stupid.github.io/2017-12-17-how-to-test-c-methods-by-using-objective-c/ How to Find Bigger Number Without Using If/else or Switch/case Statements? Suppose we have 2 positive integer numbers: a and b Now print out which number is the bigger? Note that without using if/else, switch/case or comparing operations! 😎 For example: a = 5, b = 7 The bigger is: b It’s: ((a + b) + abs(a - b)) / 2... Sat, 12 Aug 2017 00:00:00 -0700 https://geek-is-stupid.github.io/2017-08-12-how-to-find-bigger-number-without-using-if-else-or-switch-case-statements/ https://geek-is-stupid.github.io/2017-08-12-how-to-find-bigger-number-without-using-if-else-or-switch-case-statements/ How to Record, Detect Faces, Overlay Video at Real-time Using Swift? This post will show the way how to record, detect faces, overlay video at real-time using AVFoundation via Swift3: 1. Create your recorder view: import AVFoundation import ImageIO final class RecorderView: UIView { //Your next steps will be implemented here :] } 2. Create camera: Let create some global variables... Wed, 14 Jun 2017 00:00:00 -0700 https://geek-is-stupid.github.io/2017-06-14-how-to-record-detect-faces-overlay-video-at-real-time-using-swift/ https://geek-is-stupid.github.io/2017-06-14-how-to-record-detect-faces-overlay-video-at-real-time-using-swift/