Skip to content

Instantly share code, notes, and snippets.


Engineer Sheldon Wang SheldonWangRJT

View GitHub Profile
SheldonWangRJT / Convert .mov or .MP4 to
Last active Feb 18, 2021
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal
View Convert .mov or .MP4 to

This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.


Convert .mov/.MP4 to .gif


As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

This is not limited to developer, anyone has this need can use this method to convert the files.

SheldonWangRJT / iOS Dynamic vs. Static Library &
Last active Nov 12, 2019
iOS Dynamic vs. Static Library / Framework
View iOS Dynamic vs. Static Library &

iOS Dynamic vs. Static Library / Framework

Find me on Github, Facebook, Youtube, etc by #iOSBySheldon.


Library and Framework are not same but close. Frameworks are just libraries with linking (binding). In other words, frameworks are just libraries that are bundled into targets. Therefore, their file extensions are different.

File Format

  • Static Library - xxxx.a
  • Dynamic Library - xxxx.dylib
SheldonWangRJT / iOS Create a Carthage Supported Framework.txt
Last active Jan 24, 2020
iOS Create a Carthage Supported Framework
View iOS Create a Carthage Supported Framework.txt
iOS Create a Carthage Supported Framework
A little bit Background of Carthage:
- Carthage works like Cocoapods, but a little bit simpler.
* When creating a Cocoapods supported framework need a .podspec file to do some config, which is not required by Carthage.
* When using a Cocoapods supported framework, a workspace file will be automatically created, the umbrella header will be setup in a pod project inside workspace. It feels simple, but the whole process creates a lot files including a "giant" workspace.
* When using a Carthage supported framework, it will just download the framework, and its dependencies if any, to a folder. All we need to do is to drag and drop it to the binary linking section in the project build setting tab, for the first time. It sounds complicated but it makes the project clean.
- Carthage is written in Swift.
- Carthage internally uses `-xcodebuild` to build dependency.
SheldonWangRJT / Git - Revert a Merge.txt
Last active Mar 5, 2019
Git - Common Used Commands
View Git - Revert a Merge.txt
Git - Revert a Merge
Reverting a commit is usually not hard, specially with the help of Source Tree, if, you are reverting a simple commit on a branch. What you need to do is just to right click the commit you want to revert and then choose "Reverse Commit".
However, if the commit you want to revert is a "Merge", it will be a little bit harder. If you do the same thing in Source Tree, right click - "Reverse Commit", it will give you an error that Source Tree cannot revert it because there are two branches involved.
Let's name the merge-from branch as "F" and "merge-to" branch as "T".
Here is the solution for it (only can be done in Terminal, at least today):
View A little thing about Xcode LLVM C++ Settings
Apple LLVM 9.0 - Language - C++ Settings
This is an option setting under a Target - Build Settings tab. The idea is to let Xcode (LLVM) to be able to handle C++ functions, if you are using any static framework that is written in C++.
This is two items that need to be selected(it may be defaulting different values by different Xcode version):
C++ Language Dialect: GNU++14 [-std=gnu++14]
C++ Standard Library: libc++ (LLVM c++ standard library with C++11 support)
14 indicates this version came out in 2014 [1], if you have to use older version, 11 is in the droplist. If you need 98 you can still run some script to achieve it. [2]
SheldonWangRJT / Something About iOS
Last active Aug 4, 2018
Dealing with the Crash Log Files (.crash), dSYM, EXC_BAD_ACCESS, EXC_CRASH and so on.
View Something About iOS

Something About iOS Crashes

#iOSBySheldon Apps are crashing all the time. No matter how good you write your app, it will crash in some cases.

When apps crashed, iOS will automatically generate a crash log file, the file has the extension as .crash. A crash file contains a lot of info like which version, which build, which device your app is crashing on. And the most important part of a crash file a the stack trace that indicates which function of your code in which file is crashing.

However, to find out which function of your code is crashing is not that straight forward from the crash log files. Because when we build our app, Xcode compiles our code files into binaries that changes the looking of our code. Therefore, to find out which line of code is crashing, we need a file to kinda to the translation for us, in iOS, this "translation" needs to be handled by debug-symbols files, which is also called dSYM files. (.dSYM)

Please see [1] as the image that indicates the whole process of creating the bu

View Something About NSUserDefaults.txt
Something About NSUserDefaults
As an iOS developer, you must have heard NSUserDefaults, because, it is one of the easiest way to store something locally in users device. Even you have known it, this quick post may still help you know some details. [1]
1. NSUserDefaults is just a plist file.
Although Apple has built the interface to use it, the core of NSUserDefaults is just a plist file. The interface is pretty straight forward
UserDefaults.standard.set(<#T##value: Any?##Any?#>, forKey: <#T##String#>)
View Git Cancel Commit Before Push.txt
Git Cancel Commit Before Push
Sometimes, we have committed something and then we regret and don't want to push it anymore. In case of this, we can discard our commit, which is better done in terminal, I mean, SourceTree is limited sometime.
There are multiple ways to do this, you can rebase, you can reset, today, I will use reset.
1. Soft reset
$ git reset --soft HEAD^
SheldonWangRJT / Map, FlatMap (CompactMap), Reduce, Filter &
Last active Dec 4, 2020
Swift Map, FlatMap (CompactMap), Reduce, Filter & Sort
View Map, FlatMap (CompactMap), Reduce, Filter &

High Order Functions in iOS Swift

Written by Sheldon, please find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

It is exaggerating to say we don't need to use for loop or while loop any more but we can take advantage of the Swift language built in functions to do loops. If I give you a question now. Q: Assuming we have an optional nested array, please calculate the production of the values that are less than 5. let numbers: [[Int]?] = [[1, 3], nil, [2], [5, 10], nil, [4]], what is your best approach to do it?

And you know the solution that I am talking about is following Swift functions:

  1. Map
  2. FlatMap / CompactMap
View iOS Swift - Cancellable Task with

iOS Swift - Cancellable Task with GCD


I think most of you guys know GCD pretty well. Basically, GCD is a high level API to handle multi-threading operations. We use GCD almost on daily basis to switch thread and execute codes like:

DispatchQueue.main.async { //execute some codes here } 
//switch to main queue and execute codes asynchronously

DispatchQueue.main.sync { //execute some codes here } 
//switch to main queue and execute codes synchronously