Skip to content

Instantly share code, notes, and snippets.

View SheldonWangRJT's full-sized avatar
🎯
Focusing

Engineer Sheldon Wang SheldonWangRJT

🎯
Focusing
View GitHub Profile
#iOSBySheldon
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
SheldonWangRJT / Something About NSUserDefaults.txt
Last active February 13, 2018 21:26
Something About NSUserDefaults
Something About NSUserDefaults
#iOSBySheldon
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#>)
Git Cancel Commit Before Push
#iOSBySheldon
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
SheldonWangRJT / iOS - What does SiriKit do? How to use it in our app?
Created March 18, 2018 00:09
iOS - What does SiriKit do? How to use it in our app?
#iOSBySheldon
As Siri became more and more popular, people won't be satisfied to only use Siri in the iOS system level, instead, it will be much better if we can use Siri with apps that are not only from Apple. In WWDC 2016, Apple finally opened SiriKit to the developers. Time flies, it is almost two years past. I do believe in this year's WWDC 2018, Apple will give a big enhancement on the SiriKit. One of the bigger reason might be the release of the HomePod.
In this post, I don't want to show you any code, but I do want to explain to you guys what does SiriKit do and the basics of SiriKit.Same as Alex for Amazon and "OK Google", SiriKit uses a technique called Natural Language Processing.
If you check the link from WikiPedia, you will be find the following definition:"Natural-language processing (NLP) is an area of computer science and artificial intelligence concerned with the interactions between computers and human (natural) languages, in particular how to program computers to fruitfully process larg
@SheldonWangRJT
SheldonWangRJT / Keychain - local items alert
Created March 24, 2018 14:47
How to solve mac app wants to use the "Local Items" keychain endlessly
#iOSBySheldon
Sometimes due to Mac system error, you are seeing this alert a lot. This alert could be shown repleatedly and annoyingly.
--------------------------------------------------
| xxx wants to use the "Local Items" keychain. |
| Please enter the keychain password. |
| Password: ________________________ |
--------------------------------------------------
We can clean our KeyChain "Local Items" using Terminal to solve this issue.
@SheldonWangRJT
SheldonWangRJT / iOS Most Useful Debug Tricks
Created March 30, 2018 02:25
iOS Most Useful Debug Tricks
1. objc_exception_throw
When breakpoint auto landed on the assembly page, try to type
(lldb) po $arg1
(lldb) po [$arg1 name]
(lldb) po [$arg1 reason]
This may bring extra info, like "xxx is nil"
[1.1] https://stackoverflow.com/questions/3327828/xcode-lldb-how-to-get-information-about-an-exception-that-was-just-thrown
[1.2] https://www.natashatherobot.com/xcode-debugging-trick/
2. Double click break point to set break conditions & additional actions
@SheldonWangRJT
SheldonWangRJT / WWDC18-412-Notes-Sheldon.md
Last active July 12, 2018 15:30
WWDC18 Notes by Sheldon - Session 412 - iOS Advanced Debugging with LLDB

WWDC18 Notes - Session 412 - Advanced Debugging with Xcode and LLDB

All session list link: Here
Session Link: Here
Download session slides: Here

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

Quick Tab for Breakpoint

@SheldonWangRJT
SheldonWangRJT / WWDC18-234-Notes-Sheldon.md
Last active July 12, 2018 16:20
WWDC18 Notes by Sheldon - Session 234 - Safari and WebKit

WWDC18 Notes - Session 234 - Safari and WebKit

All session list link: Here
Session Link: Here
Download session slides: Here
More about AR file .usdz is Here

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

@SheldonWangRJT
SheldonWangRJT / Something About iOS Crashes.md
Last active August 4, 2018 21:35
Dealing with the Crash Log Files (.crash), dSYM, EXC_BAD_ACCESS, EXC_CRASH and so on.

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

@SheldonWangRJT
SheldonWangRJT / What Does "weak" Exactly Do in iOS.md
Last active August 5, 2018 02:26
What Does "weak" Exactly Do in iOS?

What Does "weak" Exactly Do in iOS?

#iOSBySheldon

As we all know making an property weak is a good way to solve retain cycle or strong reference cycle. But do you know what does weak key-word exactly do behind the scene?

Two Quick Challenging Questions

  • Why weak property is nil after its owner object is released?
  • What exactly happened after weak property's owner object released?