Skip to content

Instantly share code, notes, and snippets.

Hey, this is the voice translator app!

@gatamar
gatamar / uiview_animation_autotest.md
Last active March 20, 2021 16:41
a small research before asking stackoverflow
UIView's animation: snapshot testing / Instruments Profiling

I have an UIView hierarchy, when some views are semi-transparent, and there're views which can be animated simultaneously.

The hierarchy is quite complex and what's worse, managed from different places.
There's a bug which can be reduced to the following: we animate UIView' background color from `rgba(0,0,255,1)` to `rgba(0,0,255,0)` for 200ms, and instead of fading green frames, sometimes a reddish one appears (most probably it's an underlaying view, or an underlaying view of an underlaying view).

Do you know how to debug such stuff automatically? 
I can make screen recording, disable/enable some views (but the bug tends to disappear when the code changed). 
@gatamar
gatamar / TestAnimationRecording.mm
Last active August 18, 2020 20:32
Taking snapshots of a UIView during animation using CADisplayLink. To try it, just create a default "Single view" iOS project and replace the contents of ViewController.m with contents of this gist.
//
// ViewController.m
// TestAnimationRecording
#import "ViewController.h"
static int anim_dur = 10;
@interface ViewController ()
{
find . -iname *.h -o -iname *.cpp | xargs clang-format -i --dry-run

Override the status bar appearance:

$ xcrun simctl status_bar F433A439-5E1E-4AAD-BF54-A1B3D661D891 override --time 10:00 --dataNetwork wifi --wifiMode active --wifiBars 3 --cellularMode active --cellularBars 4 --batteryState charged --batteryLevel 100 --operatorName 'Notificare'

Deep linking, video recording, etc

Checklist for adding Swift support to Objc project

  1. Add (auto-generated) bridging header ProductName-Bridging-Header.h.
  2. Add SWIFT_VERSION to Build Settings -> Swift Compiler - Language.
  3. Fix Multiple commands produce '.../Objects-normal/x86_64/ProductName.swiftmodule' - target ProductNames should differ.
  4. Set "Defines Modules" to "Yes" in Build Settings -> Packaging.
  5. #import "Objective-C Generated Interface Header Name"
  6. Remove #import "ProductName-Swift.h" from headers to implementation, add forward declaration to headers.

The "rules" of converting Swift names to Objc

I've got such a crash in Release mode. Xcode showed only 2 rows in the Main thread tab:

pthread_kill
...
start

The address at which the app crashed looked like this: