<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.4.3">Jekyll</generator><link href="http://blog.aitali.co/feed.xml" rel="self" type="application/atom+xml" /><link href="http://blog.aitali.co/" rel="alternate" type="text/html" /><updated>2017-04-04T12:27:40-04:00</updated><id>http://blog.aitali.co/</id><title type="html">Anas AIT-ALI’s Blog</title><subtitle>To do so...</subtitle><author><name>Anas AIT-ALI</name><email>contact@aitali.co</email></author><entry><title type="html">QuickTip Series #3</title><link href="http://blog.aitali.co/article/quicktip-3" rel="alternate" type="text/html" title="QuickTip Series #3" /><published>2017-03-24T00:00:00-04:00</published><updated>2017-03-24T00:00:00-04:00</updated><id>http://blog.aitali.co/article/quicktip-3</id><content type="html" xml:base="http://blog.aitali.co/article/quicktip-3">&lt;h1 id=&quot;goal&quot;&gt;Goal&lt;/h1&gt;

&lt;p&gt;Display the application version within the app.&lt;/p&gt;

&lt;h1 id=&quot;tip&quot;&gt;Tip&lt;/h1&gt;

&lt;p&gt;Simply access the main bundle info dictionary with &lt;code class=&quot;highlighter-rouge&quot;&gt;Bundle.main.infoDictionary&lt;/code&gt;. 
You can print this array and see all the information specified in your info.plist.
 &lt;!--more--&gt;&lt;/p&gt;
&lt;h1 id=&quot;example&quot;&gt;Example&lt;/h1&gt;

&lt;p&gt;For example if you want to print the app version and build version (i.e 1.0.0(1)):&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-Swift&quot;&gt;func getAppVersion(infoDictionary: [String : Any]? = Bundle.main.infoDictionary) -&amp;gt; String? {
    if let dict = infoDictionary {
        if let version = dict[&quot;CFBundleShortVersionString&quot;] as? String,
            let bundleVersion = dict[&quot;CFBundleVersion&quot;] as? String {
	         return &quot;\(version)(\(bundleVersion))&quot;
        }
    }
    return nil
}

print(getAppVersion()) // =&amp;gt; will display 1.0.0(0)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Simple!&lt;/p&gt;</content><author><name>Anas AIT-ALI</name><email>contact@aitali.co</email></author><category term="programming" /><summary type="html">Goal Display the application version within the app. Tip Simply access the main bundle info dictionary with Bundle.main.infoDictionary. You can print this array and see all the information specified in your info.plist.</summary></entry><entry><title type="html">Pod: AABlurAlertController</title><link href="http://blog.aitali.co/article/aablurcontroller" rel="alternate" type="text/html" title="Pod: AABlurAlertController" /><published>2017-02-06T00:00:00-05:00</published><updated>2017-02-06T00:00:00-05:00</updated><id>http://blog.aitali.co/article/aablurcontroller</id><content type="html" xml:base="http://blog.aitali.co/article/aablurcontroller">&lt;p&gt;&lt;img src=&quot;/images/aablurcontroller.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;As often my work is done for companies or personal projects, I don’t often end up sharing what I do.&lt;/p&gt;

&lt;p&gt;So from time to time, I like to take a moment to create a pod out of some code that I wrote for something else.   &lt;!--more--&gt;
And if people like it and use it, I am more than happy to work on it and adapt it to their needs. It’s just my way to say thank you to all the people out there making amazing libraries that I use myself.&lt;/p&gt;

&lt;p&gt;Anyway, I’ve decided to share them also on my blog now.&lt;br /&gt;
And this is the first one that I would like to post here.&lt;/p&gt;

&lt;p&gt;I’m really bad at finding a name, so I decided to call it: AABlurAlertController.&lt;br /&gt;
It is a custom alert controller with a blurred background that you can use anywhere in your app.&lt;br /&gt;
It is fully written in Swift (3.0 as I’m writing this).&lt;/p&gt;

&lt;p&gt;You can find it on Github at : &lt;a href=&quot;https://github.com/anas10/AABlurAlertController&quot;&gt;AABlurAlertController&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope you like it.&lt;/p&gt;</content><author><name>Anas AIT-ALI</name><email>contact@aitali.co</email></author><category term="projects" /><category term="cocoapods" /><category term="ios" /><category term="library" /><summary type="html">As often my work is done for companies or personal projects, I don’t often end up sharing what I do. So from time to time, I like to take a moment to create a pod out of some code that I wrote for something else.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://blog.aitali.co/%7B%22feature%22=%3Enil%7D" /></entry><entry><title type="html">QuickTip Series #2</title><link href="http://blog.aitali.co/article/quicktip-2" rel="alternate" type="text/html" title="QuickTip Series #2" /><published>2016-07-31T00:00:00-04:00</published><updated>2016-07-31T00:00:00-04:00</updated><id>http://blog.aitali.co/article/quicktip-2</id><content type="html" xml:base="http://blog.aitali.co/article/quicktip-2">&lt;p&gt;Hello guys,&lt;br /&gt;
No introduction needed! Let’s go straight for our quick tip number 2.&lt;/p&gt;

&lt;h1 id=&quot;goal&quot;&gt;Goal&lt;/h1&gt;

&lt;p&gt;Debug the view controllers hierarchy in the console as sometimes the Xcode UI Debugger can’t give us what we are looking for&lt;!--more--&gt;&lt;/p&gt;

&lt;h1 id=&quot;tip&quot;&gt;Tip&lt;/h1&gt;

&lt;ol&gt;
  &lt;li&gt;Add a breakpoint where you want to debug the views and put the following code in the debugger console once you reach your breakpoint:&lt;/li&gt;
  &lt;li&gt;Run the command in the lldb console&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When debugging Objective-C code:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-lldb&quot;&gt;po [UIViewController _printHierarchy]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and for Swift:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-lldb&quot;&gt;expr -l objc++ -O -- [UIViewController _printHierarchy]
&lt;/code&gt;&lt;/pre&gt;

&lt;h1 id=&quot;example&quot;&gt;Example&lt;/h1&gt;

&lt;p&gt;Below an output example of when using this command :&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-lldb&quot;&gt;&amp;lt;PieOverlayMenu.PieOverlayMenu 0x7f86854755e0&amp;gt;, state: appeared, view: &amp;lt;UIView 0x7f868548c500&amp;gt;
   | &amp;lt;Pie_for_Drivers.SplitViewController 0x7f8686877800&amp;gt;, state: appeared, view: &amp;lt;UILayoutContainerView 0x7f8684ce8410&amp;gt;
   |    | &amp;lt;UINavigationController 0x7f8688896200&amp;gt;, state: appeared, view: &amp;lt;UILayoutContainerView 0x7f8685417d10&amp;gt;
   |    |    | &amp;lt;Pie_for_Drivers.LegsListViewController 0x7f8685604f40&amp;gt;, state: appeared, view: &amp;lt;UIView 0x7f8684d51290&amp;gt;
   |    | &amp;lt;Pie_for_Drivers.MapViewController 0x7f8685416e10&amp;gt;, state: appeared, view: &amp;lt;UIView 0x7f86851dab80&amp;gt;
   | &amp;lt;PieOverlayMenu.PieOverlayMenuContentViewController 0x7f8685476080&amp;gt;, state: appeared, view: &amp;lt;UIView 0x7f86855423c0&amp;gt;
   |    | &amp;lt;Pie_for_Drivers.MenuViewController 0x7f8685474320&amp;gt;, state: appeared, view: &amp;lt;UIView 0x7f86854845b0&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;h1 id=&quot;under-the-hood&quot;&gt;Under the hood&lt;/h1&gt;

&lt;p&gt;Apple added the &lt;a href=&quot;https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/special_debugging_workflows.html&quot;&gt;debub view hierarchy&lt;/a&gt; feature in XCode 6. But to inspect the view controller hierarchy Apple only introduced this private helper : &lt;a href=&quot;https://github.com/nst/iOS-Runtime-Headers/blob/a8f9f7eb4882c9dfc87166d876c547b75a24c5bb/Frameworks/UIKit.framework/UIViewController.h#L365&quot;&gt;_printHierarchy&lt;/a&gt; silently in iOS 8.&lt;/p&gt;

&lt;p&gt;Let me now explain what the expression does.&lt;br /&gt;
Basically, it’s just calling the private helper :P&lt;/p&gt;

&lt;p&gt;However, the command is different for Swift and Objective-C simply because the methode &lt;code class=&quot;highlighter-rouge&quot;&gt;_printHierarchy&lt;/code&gt; isn’t available in Swift.&lt;br /&gt;
So what we do here is that we tell LLDB to execute an Objective-C expression.&lt;/p&gt;

&lt;p&gt;Let’s break down the command for Swift code :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;po&lt;/code&gt; (for print object) is simply an alias to &lt;code class=&quot;highlighter-rouge&quot;&gt;expr -O --&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;-l objc++&lt;/code&gt; is here to specify the language used.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;br /&gt;Voila!&lt;/p&gt;</content><author><name>Anas AIT-ALI</name><email>contact@aitali.co</email></author><category term="programming" /><summary type="html">Hello guys, No introduction needed! Let’s go straight for our quick tip number 2. Goal Debug the view controllers hierarchy in the console as sometimes the Xcode UI Debugger can’t give us what we are looking for</summary></entry><entry><title type="html">QuickTip Series #1</title><link href="http://blog.aitali.co/article/quicktip-1" rel="alternate" type="text/html" title="QuickTip Series #1" /><published>2016-07-17T00:00:00-04:00</published><updated>2016-07-17T00:00:00-04:00</updated><id>http://blog.aitali.co/article/quicktip-1</id><content type="html" xml:base="http://blog.aitali.co/article/quicktip-1">&lt;p&gt;Hello there,&lt;br /&gt;
I’m so excited to start this Quicktip series today.
The goal of this serie of articles is to give you some tips in a short, precise and consise way.
So enough talk and let’s get started.&lt;/p&gt;

&lt;h1 id=&quot;goal&quot;&gt;Goal&lt;/h1&gt;

&lt;p&gt;The idea is to be able to have different podfile configurations based on the current environnement.&lt;!--more--&gt;&lt;/p&gt;

&lt;h1 id=&quot;tip&quot;&gt;Tip&lt;/h1&gt;

&lt;p&gt;Simply check environnement variables in your podfile.&lt;br /&gt;
You can access and environnement variable this way : &lt;code class=&quot;highlighter-rouge&quot;&gt;ENV['USER']&lt;/code&gt;&lt;/p&gt;

&lt;h1 id=&quot;example&quot;&gt;Example&lt;/h1&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;source&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'https://github.com/CocoaPods/Specs.git'&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;platform&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:ios&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'8.0'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;use_frameworks!&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;inhibit_all_warnings!&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;target&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'TargetName'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'anas'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;include?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'USER'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#1&lt;/span&gt;
    	&lt;span class=&quot;c1&quot;&gt;# IF CURRENT USER IS ME, I use the local path&lt;/span&gt;
    	&lt;span class=&quot;n&quot;&gt;pod&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'AABlurAlertController'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'POD_LOCAL_HOME'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/AABlurAlertController&quot;&lt;/span&gt;
    	
       &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
       &lt;span class=&quot;c1&quot;&gt;# ELSE (CI for example) I use the github repository&lt;/span&gt;
       &lt;span class=&quot;n&quot;&gt;pod&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'AABlurAlertController'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:git&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'git@github.com:anas10/AABlurAlertController.git'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:branch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'master'&lt;/span&gt;
       
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;pod&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'AASquaresLoading'&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;[.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
	
    &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'TargetNameTests'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;inherit!&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:search_paths&lt;/span&gt;
        
		 &lt;span class=&quot;p&quot;&gt;[.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;The important part is &lt;code class=&quot;highlighter-rouge&quot;&gt;#1&lt;/code&gt; where we check the environement user and then act accordingly.&lt;/p&gt;

&lt;p&gt;Here we go with our first quick tip.&lt;br /&gt;
Let me know what you think and see you soon.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;UPDATE : 04/04/17&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I did something else recently that makes more sense in many cases.&lt;br /&gt;
Instead of looking for the user via an environment variable, I just look for a specific environnement variable such as &lt;code class=&quot;highlighter-rouge&quot;&gt;LOCALPODS&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'LOCALPODS'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;pod&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'AABlurAlertController'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'POD_LOCAL_HOME'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/AABlurAlertController&quot;&lt;/span&gt;    
&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;pod&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'AABlurAlertController'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:git&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'git@github.com:anas10/AABlurAlertController.git'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:branch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'master'&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Ans I set this variable only when needed before a pod install like this : &lt;code class=&quot;highlighter-rouge&quot;&gt;LOCALPODS=true pod install&lt;/code&gt;&lt;/p&gt;</content><author><name>Anas AIT-ALI</name><email>contact@aitali.co</email></author><category term="programming" /><summary type="html">Hello there, I’m so excited to start this Quicktip series today. The goal of this serie of articles is to give you some tips in a short, precise and consise way. So enough talk and let’s get started. Goal The idea is to be able to have different podfile configurations based on the current environnement.</summary></entry><entry><title type="html">Welcome</title><link href="http://blog.aitali.co/article/welcome" rel="alternate" type="text/html" title="Welcome" /><published>2016-07-13T00:00:00-04:00</published><updated>2016-07-13T00:00:00-04:00</updated><id>http://blog.aitali.co/article/welcome</id><content type="html" xml:base="http://blog.aitali.co/article/welcome">&lt;p&gt;Welcome to my blog.&lt;/p&gt;

&lt;p&gt;I always had notes about projects, tech stuff, ideas and so on. But they were always private and only accessible to me. It was like my personal journal.
And now I decided to simply share that with who may be interested :)&lt;/p&gt;

&lt;p&gt;Hope you’ll like it.
&lt;!--more--&gt;&lt;/p&gt;</content><author><name>Anas AIT-ALI</name><email>contact@aitali.co</email></author><category term="personal" /><summary type="html">Welcome to my blog. I always had notes about projects, tech stuff, ideas and so on. But they were always private and only accessible to me. It was like my personal journal. And now I decided to simply share that with who may be interested :) Hope you’ll like it.</summary></entry></feed>