<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sameh Mabrouk on Medium]]></title>
        <description><![CDATA[Stories by Sameh Mabrouk on Medium]]></description>
        <link>https://medium.com/@isameh?source=rss-f0b28db55a3b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*99ig2_F1nykH0n2usbZj3Q.jpeg</url>
            <title>Stories by Sameh Mabrouk on Medium</title>
            <link>https://medium.com/@isameh?source=rss-f0b28db55a3b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:10:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@isameh/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Checklist of my code review]]></title>
            <link>https://isameh.medium.com/the-checklist-of-my-code-review-18cc6f6fb5b3?source=rss-f0b28db55a3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/18cc6f6fb5b3</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Sameh Mabrouk]]></dc:creator>
            <pubDate>Fri, 23 Jun 2017 01:32:58 GMT</pubDate>
            <atom:updated>2018-07-03T14:42:30.490Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q_9SjUnDqWnSp1f9YW9zjg.jpeg" /></figure><h3><strong>Definition of Code Review:</strong></h3><p>According to <a href="https://en.wikipedia.org/wiki/Code_review?utm_source=swifting.io&amp;utm_medium=web&amp;utm_campaign=blog%20post">Wikipedia</a> :</p><blockquote>Code review is systematic examination (sometimes referred to as peer review) of computer source code. It is intended to find mistakes overlooked in the initial development phase, improving the overall quality of software.</blockquote><p>Ok, I wanna do it! Wait, but …</p><h3>How to do it?</h3><p>Reviews can be done in various forms such as pair programming, informal walkthroughs, and formal inspections. The most known is probably this one — show me your code (aka informal review)! Simply ask your peer to have a look at your code.</p><p>Formal code reviews can be performed by different tools e.g. Atlassian’s Crucible/Fisheye or a pull request on BitBucket/GitHub or whatever you use. Thanks to those tools you get a nice visualization of what changes were made to source code, you can comment on them, ask author some questions and they can explain their code in return. It’s like a conversation you would have in real life, but documented — what has been agreed should be performed before merging into develop. Wait, what merging?! We were just talking about a review …</p><h3><strong>Git flow</strong></h3><p>When developing different parts of an application at work we use Git and Git Flow to merge all changes into a parent branch. Once a feature of an app is finished we create a pull request that contains changes to be added to a predecessor branch (usually <em>develop</em>). The best picture showing the flow comes, in my opinion, from <a href="https://guides.github.com/introduction/flow/?utm_source=swifting.io&amp;utm_medium=web&amp;utm_campaign=blog%20post">GitHub</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wdE0fErWcNbnppbvXHYGOw.jpeg" /></figure><p>The flow simply goes like this:</p><ul><li>create a branch from e.g. <em>develop</em></li><li>apply your changes to the source code</li><li>create a pull request to be merged into e.g. <em>develop</em></li><li>discuss changes with your peers, explain your point of view &amp; apply suggested improvements</li><li>your peers approves your changes</li><li>merge your code into source branch</li></ul><h3>What should you care about when doing a review?</h3><p>You definitely should check code integrity — does the style match previous solutions, does it follow agreed conventions? Are features implemented correctly<em>(for this point i would advice if the PR creator could add .GIF image that explain how the feature works that would be nice)</em>, does the old source code work correctly after changes?</p><h3>Why you should care about code review in your development process?</h3><p>For sure because it ensures code integrity :) , catches what others’ eyes didn’t see. It allows to learn and share your knowledge and expertise, strengthens communication in the team and builds good relationships due to conversations about what you have in common — code and programming skills ;)!</p><blockquote>Personally i have seen that lately in my current project. the team had problems in communication but after conversations we did in code review the communication became much more better.</blockquote><p>Consider code review as an investment into the future. If you don’t catch bugs now you will definitely have to conquer them in the future.</p><h3>What if you didn’t perform code reviews</h3><p>Imagine a company X. It delivers mobile app solutions for multiple clients. Their team is small and at some point they cannot meet clients’ demands. So they decide to outsource some of the work to an external company. They give project requirements to this company and meet again after 3 months to receive app source code. But the app is useless — it freezes at network calls, CoreData.ConcurrencyDebug flag crashes all the time. The project is delayed for a few months, team has to start from a scratch. They wish they had reviewed outsourced code on a daily basis…</p><h3>Do you want to perform code reviews?</h3><p>This is usually the question that gets lack of enthusiasm from the audience :(. But really, are we too busy to improve??</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*Pyh-kAasOAREQW0YDqyz2g.png" /></figure><p>This was an introduction to code review. Now let’s get deeper into the code review process, present some tips &amp; tricks when performing a review and also focus on some mistakes when reviewing a swift code.</p><p>As iOS developer most of things i think of are somehow related to iOS platform as of now Swift is my main programming language, but i think there are generic things not related to the platform or specific programming language. So let’s spill them out 🚀</p><h3><strong>General Tips:</strong></h3><blockquote>It is said that a review goes best when conducted on less than 400 lines of code at a time. You should do a proper and slow review, however, don’t spend on it more than 90 minutes <em>⏰</em></blockquote><p>you definitely will get tired after that time. It’s tiring to write and understand your own code and it’s even more tiring to understand someone’s.</p><p>After some years of experience in software development you know what common programming mistakes are. You also do realize what solutions to common problems are most efficient. It’s a good practice to write it down and to check code being reviewed against a checklist ✅ — it leads improved results. Checklists are especially important for reviewers because, if the author forgets a task, the reviewer is likely to miss it too.</p><p>In the git flow mentioned in above, code can get merged after receiving agreed number of approvals for a pull request. The number should depend on your team size, but it’s good to get at least ⓵ !😀</p><p>When you recommend fixes to the code, suggest their importance 💬. Maybe some of them could be postponed and extracted as separate tasks. Before approving a pull request, verify that defects are fixed 🔧🔨.</p><p>Spread in your company a Good Code Review Culture in which <em>finding</em> defects is viewed <em>positive</em>ly 😀. The point of software code review is to <em>eliminate</em> as many <em>defects</em> as possible, regardless of who “caused” the error. Few things feel better than getting praise from a <em>peer</em>. <em>Reward</em> developers for growth and effort. Offer as many <em>positive</em> comments as possible. I always try to put a line saying that a solution is good and clever (if it really is 😉).</p><p>You can also benefit from The Ego Effect 💎. The Ego Effect drives developers to <em>write better code</em> because they know that <em>others will be looking</em> at their code and their metrics. No one wants to be known as the guy who makes all those <em>junior-level mistakes</em>. The Ego Effect drives developers to <em>review</em> their <em>own work</em> carefully before passing it on to others.</p><p>And don’t bother with code formatting style …</p><p>… there are much better things on which to spend your time, than arguing ☔️ over the placement of white spaces.</p><p><strong><em>Looking for bugs and performance issues is the primary goal and is where the majority of your time should be spent.</em></strong></p><h3>What i look for during a review?</h3><h3>1. Style</h3><h3>Common red flags 🚩</h3><h4><strong>1. DRY (</strong><a href="http://sdfa/"><strong>Don’t repeat yourself</strong></a><strong>)</strong></h4><p>There are lots of examples for DRY principle let’s take the most simple one:</p><p>the simple meaning of DRY is don’t write the same code repeatedly. Let’s take for example this code:</p><pre>// let&#39;s assume we have a boolean and it&#39;s initialised with false<br>let isPositionCorrect = false</pre><pre>if isPositionCorrect {<br>    updateUI(&quot;Position Correct&quot;, isPositionCorrect)<br>} else {<br>    updateUI(&quot;Position InCorrect&quot;, isPositionCorrect)<br>}</pre><p>If we look into this piece of code we see that the call to updateUI function is duplicated twice. Now this is a bad code because from maintainability perspective if the method definition has changed then you need to change it twice for example now the method takes 2 parameters what if we need to change it to take 3 parameters we have to change it in 2 places.</p><p><strong>To fix that we have to follow the DRY principle:</strong></p><pre>let message = isPositionCorrect ? &quot;Position Correct&quot; : &quot;Position InCorrect&quot;</pre><pre>updateUI(message, isPositionCorrect)</pre><p>So in this case if we need to change the function we will change only one place, no duplication any more.</p><h4><strong>2. Use early exit</strong></h4><p>The more loops you have the more effort required from our mind to make sense of it. So with early exit instead of having your code wrapped in one <em>if loop</em> statement, you can just add the condition for which the loop is not executed first and just <em>return</em> if that is the case.</p><p>Example, instead of that :</p><pre>func function(items: [Int]) {<br>    if items.count &gt; 0 {<br>        for item in items {<br>            // do something<br>        }<br>    }<br>}</pre><p>you could write it like that:</p><pre>func function(items: [Int]) {<br>    if items.isEmpty {<br>        return<br>    }</pre><pre>for item in items {<br>        // do something<br>    }<br>}</pre><p>Even more Swifty style you could write it like that:</p><pre>func function(items: [Int]) {<br>    guard !items.isEmpty else { return }</pre><pre>for item in items {<br>        // do something<br>    }<br>}</pre><h4><strong>3. Returning booleans:</strong></h4><pre>func isItemExist(x: Int, items: [Int]) -&gt; Bool {<br>    if items.contains(x) {<br>        return true<br>    }<br>    else {<br>        return false<br>    }<br>}</pre><p>If your function returns boolean, just take a closer look and see if you can write it in a bitter way, because most of the times, it can be written in a simpler way.</p><pre>func isItemExist(x: Int, items: [Int]) -&gt; Bool {<br>    return items.contains(x)<br>}</pre><p>Also if you are dealing with <strong>booleans on objects:</strong></p><pre>func showImageViewIfEmptyItems(imageView: UIImageView, items: [Int]) {<br>    if items.isEmpty {<br>        imageView.isHidden = true<br>    }<br>    else {<br>        imageView.isHidden = false<br>    }<br>}</pre><p>Could be written like that:</p><pre>func showImageViewIfEmptyItems(imageView: UIImageView, items: [Int]) {<br>    imageView.isHidden = items.isEmpty<br>}</pre><h4><strong>4. Remove unused code</strong></h4><blockquote><a href="https://blog.codinghorror.com/the-best-code-is-no-code-at-all/"><em>The Best Code is No Code At All</em></a></blockquote><p>Removing code should be one of your activities as a developer. Always delete unused code also code that is generated by IDE. In code review when you see empty method, unused variable, outdated comments, imports hanging around your code, don’t just leave it, it should be removed.</p><p>Commented out code should be removed. don’t leave it hanging around there. Actually you have all the history in your source control tool. From my experience i think you rarely go back to code that you comment it in the first place. If you want to go back to this commented code you can just revert your file.</p><p>Sometimes i find stuff like this in codebase i review:</p><pre>func foo(String: item) -&gt; String {<br>  let baz = findKeyForItem(item)<br>  // we no longer do this for some good reason<br>  // if (baz == &quot;foobar&quot;) {<br>  // return baz<br>  // } else {<br>  // return item.foobar()<br>  // }<br>  return baz<br>}</pre><p>This function should looks like this:</p><pre>func foo(String: item) -&gt; String {<br>  return findKeyForItem(item)<br>}</pre><p>Now if you need to go back to the old code just use <a href="https://git-scm.com/docs/git-diff">git diff</a> if you prefer command line, you can use your git client integrated with your IDE or your preferred source control tool .We can grape those changes and boom! we’re back.</p><h4>5. Write “Shy” code</h4><p>As mentioned in <a href="https://pragprog.com/the-pragmatic-programmer/extracts/software-entropy"><strong>The Pragmatic Programmer</strong></a><strong>, </strong>your code should always be <strong><em>“shy code”</em></strong>. Write shy code that doesn’t interact with too many things. Write shy code that makes objects loosely coupled. Write everything with the smallest scope possible and only increase the scope if you really need to — for example, start with everything <strong><em>private</em></strong>, your properties as well as your methods.</p><p>This rule applies on the level of exposition of the properties your objects own. Let’s say you have a custom UI component which contains an image inside, which should also be set from outside your component. Instead of exposing the image as a <em>read/write</em> property, you could provide a method to update the corresponding property inside your class <strong><em>(in Swift we do that using computed properties as we can get and set this property)</em></strong>. The image will only be exposed as <em>read-only </em>and you can also have more control on the values that are being set on your property.</p><p>For example:</p><pre>class ReusableUIComponent {<br>    <br>    private var image: UIImage<br>    <br>    init(image: UIImage) {<br>        self.image = image<br>    }<br>    <br>    var componentImage: UIImage {        <br>        get {<br>            return image<br>        }<br>        <br>        set {<br>            image = newValue<br>        }<br>    }<br>}</pre><h4><strong>6. Hard-coded values</strong></h4><blockquote><strong><em>Always think of making things configurable instead of Hard-coding values.</em></strong></blockquote><p>This one of the trivial activities of reviewing code. Whenever you see Hard-coded values, first ask yourself if there is another way you could remove this static value <em>(String, Float, Int,…) </em>and make it configurable? Then go a head and make it better. If there isn’t a way to get ride of it, store it in a <em>static variable (Normally this will be in a constants class/file you use across the project).</em></p><p>The benefit of doing that obviously is to avoid code duplication. without storing this static value in a variable, you would need to change the code in all places when your value change.</p><h4><strong>7. Language style guide &amp; coding conventions</strong></h4><p>Almost every company should have it’s own language style guide and code convention e.g <a href="https://github.com/github/swift-style-guide">Github’s swift style guide</a>. Always make sure that coding style and team standards are followed by everyone. Because doing things your way can be more fun, but your colleagues might not be used to your coding style and if it’s unusual, it will be harder for the next developer to work on what you have built. Your review should include consistent way of naming variables, code formatting, best practice for your language agreed on in your team.</p><h3>2. Architecture / Design</h3><ul><li>The code should follow the defined architecture, Whatever the architecture is <strong>MVC, MVP, MVVM or VIPER</strong> make sure that your peers is following it. Also look out for new patterns that could be useful for your project.</li><li>Check if committed code is reusable. Consider generic functions and classes.</li><li>Check if committed code is designed correctly and following the software patterns that your team is using, So if your team is following <strong><em>TDD(Test Driven Development) </em></strong>you should always write tests before production code which is mean your code is designed perfectly. From my experience <strong><em>TDD</em></strong> is saving a lot of time for designing your code, but if <strong><em>TDD</em></strong> is not adding value in designing your code, then don’t do it and write your production code directly.</li><li>Check if committed code is <strong><em>clean code. </em></strong>it should follow <strong><em>Object oriented analysis and design (OOAD) principles</em></strong> or <strong><em>SOLID</em></strong> <strong><em>principles.</em></strong></li></ul><h4><a href="https://robots.thoughtbot.com/back-to-basics-solid">SOLID Principles:</a></h4><ol><li><strong><em>S - Single Responsibility Principle (SRS):</em></strong> Do not place more than one responsibility into a single class or function, refactor into separate classes and functions <strong><em>(Plain Objects).</em></strong></li><li><strong><em>O - Open Closed Principle:</em></strong> While adding new functionality, existing code should not be modified. New functionality should be written in new classes and functions <strong><em>(extensions)</em></strong>.</li><li><strong><em>L - Liskov substitutability principle:</em></strong><em> </em>The child class should not change the behavior (meaning) of the parent class. The child class can be used as a substitute for a base class.</li><li><strong><em>I - Interface segregation:</em></strong><em> </em>Do not create lengthy interfaces, instead split them into smaller interfaces based on the functionality. The interface should not contain any dependencies (parameters), which are not required for the expected functionality.</li><li><strong><em>D - Dependency Inversion principle:</em></strong> High level modules should not depend on low level modules but should depend on abstraction <strong><em>(Protocols), </em></strong><em>Which make Dependency injection easy.</em></li></ol><h3>3. Testing</h3><ul><li><strong><em>Unit Test: </em></strong>Check if unit tests have been written for new features. Do they cover the failure conditions? Are they easy to read? How fragile are they? How big are the tests? Are they slow?</li></ul><h3><strong>Some Swift</strong>🕊 <strong>related Code Review</strong></h3><h4><strong>1. Bang or <em>force unwrapping </em></strong>❗</h4><p>One of the things that i look for when reviewing Swift code is this exclamation mark ❗always look out for code that uses it.</p><pre>var foo: Object!<br>print(&quot;\(foo.someString)&quot;)</pre><p>as you can see here this print statement will cause a crash because we access <strong><em>foo</em></strong> variable which is not initialized. Always ask yourself isn’t there a better way of doing this? Maybe a <em>guard, optional chaining.</em></p><p>Make sure that your peers (and you as well) use the bang/force unwrapping operator wisely in their code.</p><h4><strong>2. autoreleasepool</strong></h4><p>Do you remember <em>autoreleasepool? </em>if you don’t know what is that<em> </em><a href="https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAutoreleasePools.html?utm_source=swifting.io&amp;utm_medium=web&amp;utm_campaign=blog%20post#//apple_ref/doc/uid/20000047-SW2"><em>here</em></a><em> </em>is some explanation<em>. </em>Always i pay attention when reviewing body of loop to check if local <em>autoreleasepool </em>could be used to reduce peak memory footprint.</p><p>For example in this piece of code we create <em>UIImage</em> 5 times</p><pre>func useManyImages() {<br>    let filename = pathForResourceInBundle<br><br>    for _ in 0 ..&lt; 5 {<br>        let image = UIImage(contentsOfFile: filename)<br>    }<br>}</pre><p>To reduce peak memory footprint we should use <strong><em>autoreleasepool </em></strong>like this:</p><pre>func useManyImages() {<br>    let filename = pathForResourceInBundle<br><br>    for _ in 0 ..&lt; 5 {<br>        autoreleasepool {<br>            let image = UIImage(contentsOfFile: filename)<br>        }<br>    }<br>}</pre><h4><strong>3. <em>Mutable</em> <em>vs</em> <em>immutable </em>property</strong></h4><p>If object’s properties depends on some values, never ever use <em>var. </em>Use<em> let. </em>Always value more immutable state over <em>var</em>. If your property really have to be mutable and another objects needs to access it like from <strong><em>unit tests</em></strong>, expose it to the public as immutable like that:</p><pre>private(set) var foo: AnyObject<br>let bar: AnyObject</pre><h4><strong>4. Remove/deregister observers</strong></h4><p>Whenever you are reviewing or writing code that registers for some sort of notification or subscribes as an observer for updates, make sure you check that they also unregister/unsubscribe. Please check that, because we all know how difficult to debug <em>“Message sent to deallocated instance”.</em></p><h4><strong>5. Retain cycles</strong></h4><p>Avoid retain cycles when using delegates, make sure that <strong><em>delegates are weak. </em></strong>also when using blocks, make sure you<strong><em> capture self as weak.</em></strong></p><p>An example:</p><pre>class Foo {<br>	let bar = Bar()<br>	bar.closeAsynchronous{ [unowned self]<br>		self.barIsClosed()<br>	}</pre><pre>	func barIsClosed(){<br>		println(&quot;Bar&quot;)<br>	}<br>}</pre><p>The code above has a retain cycle in it. The trailing closure <strong><em>closeAsynchronous{…}</em></strong> is called after some time without blocking the main queue. The <strong><em>[unowned self]</em></strong> is needed to brake the cycle. If <strong><em>bar</em></strong> is not a variable of <strong><em>Foo</em></strong> then we do not need <strong><em>[unowned self]</em></strong></p><h4>6. Delegates implemented in extension</h4><p>Make sure that code is readable and maintainable by ensuring that delegates are implemented in extensions.</p><p>An Example:</p><pre>class Foo {<br>}<br>extension Foo : Delegate {<br>    func delegateMethod (){<br>    }<br>}</pre><h4>7. Use most generic object references</h4><p>Always make sure when you are using an object, save it to a variable that has the most generic type.</p><p>See this example:</p><pre>private var viewController: UIAlertController?<br>    <br>    init() {<br>        viewController = UIAlertController()<br>        navigationController?.pushViewController(viewController, animated: true)<br>    }</pre><p>Here if you notice that pushViewController method only need <em>ViewController not UIAlertController</em> object<em>. </em>So as we don’t need any properties from <em>UIAlertController</em>, we can save it to <em>ViewController </em>like this:</p><pre>private var viewController: UIViewController?<br>    <br>    init() {<br>        viewController = UIAlertController()<br>        navigationController?.pushViewController(viewController, animated: true)<br>    }</pre><blockquote><strong>Here the idea is not to give more information that is not needed. The less the objects know about each others, the less dependencies you have in your code.</strong></blockquote><h4>8. Unit Tests</h4><p>In unit tests use <strong><em>! forced unwrap</em></strong> more because if it crashes on the unwrap this also means the test fails. As an example see <strong><em>testForcedUnwrap</em></strong></p><pre>class Foo() {<br>    func getOptional() -&gt; Type? {<br>        return Type?()<br>    }<br>}</pre><pre>func testForcedUnwrap(){<br>    let foo = Foo()<br>    let optional = foo.getOptional()! //a crash here means the test failed<br>    <br>    XCTAssertNotNil(optional)<br>}</pre><h4>9. Code Documentation</h4><p>When a class becomes too large, it is useful to add some kind of delimiter <strong><em>(pragma marks)</em></strong> for the public/private methods, the protocol implementations, public/private variables, anything that will help anyone to understand and work with the code and navigate easier through the class.</p><h4><strong>Final Thoughts:</strong></h4><p>Code review is a mindset, not a procedure. Please keep an open mind during code reviews. I think this is something everyone struggles with. Try not to get defensive and don’t take it personal when someone says code you wrote could be better.</p><p>If the reviewer makes a suggestion, and i don’t have a clear answer as to why the suggestion should not be implemented, I’ll usually make the change. If the reviewer is asking a question about a line of code, it may mean that it would confuse others in the future. In addition, making the changes can help reveal larger architectural issues or bugs.</p><p>One of the important aspects for me, is that there is nothing too small to comment on. As per the <a href="https://en.wikipedia.org/wiki/Broken_windows_theory"><strong>Broken window theory</strong></a>. This is also applies to software development.</p><p>And <strong><em>always </em></strong>— Review your own code first! Before committing a code <em>look through all changes</em><strong><em>(diff)</em></strong> you have made!</p><p><strong><em>Also</em></strong> you should use<strong><em> Lint tools </em></strong>e.g. <a href="https://github.com/realm/SwiftLint"><strong><em>SwiftLint</em></strong></a> that would make it easy for you to set automated code review guidelines. Simply you can automate some items from this checklist and save time while doing code review.</p><p>These are basic stuff i consider while doing code reviews that i learned during the past years, while working with very talented and passionate people.</p><p>I’ll always keep my checklist open and will update it once new stuff comes up.</p><p><strong><em>I would love to hear what is on your checklist for code review in your ?</em></strong></p><p><em>I hope you enjoyed reading this and that it was able to provide a little guidance in your review process.</em></p><p><em>Please Don’t hesitate to get in contact, shoot me an email at </em><a href="/service/mailto:mabrouksameh@gmail.com"><em>mabrouksameh@gmail.com</em></a></p><p><em>If you are looking for a new opportunity as an iOS Engineer, come join us at </em><a href="https://www.tiqets.com/en/"><strong><em>Tiqets</em></strong></a><strong><em>:</em></strong></p><p><a href="https://tiqets.recruitee.com/o/ios-engineer">https://tiqets.recruitee.com/o/ios-engineer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18cc6f6fb5b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS 10.3 Alternate App Icons]]></title>
            <link>https://isameh.medium.com/ios-10-3-alternate-app-icons-2abd7b4c0a38?source=rss-f0b28db55a3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2abd7b4c0a38</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Sameh Mabrouk]]></dc:creator>
            <pubDate>Sun, 29 Jan 2017 21:43:50 GMT</pubDate>
            <atom:updated>2017-01-29T21:43:50.970Z</atom:updated>
            <content:encoded><![CDATA[<p>Apple just introduced one of iOS 10.3 changes, the ability for an application to change its icon. This is a slightly strange feature. You may ask when it would be useful, I thought about some uses cases:</p><ol><li>In a game, when you want to show a major achievement, show high score or personalize a team in a sports app.</li><li>In a Location sharing apps like Swarm, to show app icon with user sticker.</li><li>In a trip planner apps like Google trips to show app icon as the next trip.</li><li>Upgrading Lit to Pro version of an app, maybe you want to remove free label from icon.</li><li>Change app icons at times of different holidays for promotional purposes.</li></ol><p>There are endless possibilities to this depending on the type of app.</p><h3>Developers Can Now Change Home Screen App Icons Whenever They Want.</h3><p>The ability to change app icon without an update means that developers can perform the operation whenever they like. While the addition of this feature does not seem important at first, but the move can open endless possibilities to how developers can interact with their apps. Developers can take advantage of the new iOS 10.3 SDK through the new Instance method to specify the primary and alternative app icons.</p><blockquote>Also specific app can not change the icon unless its visible on the Home screen. When you change the icon, there is a system alert saying saying You have changed the icon for &quot;Application Name&quot;.</blockquote><p>This gif shows how this feature works:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*SAY4HWHIz50_29AK3bAtBg.gif" /></figure><h3>The Setup</h3><p>I made a simple example to show how Alternate Icon works in iOS 10.3. The example is based on trip planner use case. You have to selected where do you want to go and the app icon will be changed accordingly. The sample app <a href="https://github.com/iSame7/AlternateAppIcons">available on github</a>.</p><h3><strong>Info.plist file</strong></h3><p>developer should declare all alternate icons in info.list. define <em>CFBundleIcons </em>key that contain 2 sub keys <em>CFBundlePrimaryIcon </em>and <em>CFBundleAlternateIcons.</em> In this case the problem is that developer should give up Asset catalog for icons and go back to the old method with <em>.png </em>resources.</p><pre>&lt;key&gt;CFBundleIcons&lt;/key&gt;<br> &lt;dict&gt;<br>  &lt;key&gt;CFBundleAlternateIcons&lt;/key&gt;<br>  &lt;dict&gt;<br>   &lt;key&gt;barca&lt;/key&gt;<br>   &lt;dict&gt;<br>    &lt;key&gt;CFBundleIconFiles&lt;/key&gt;<br>    &lt;array&gt;<br>     &lt;string&gt;ic_barca&lt;/string&gt;<br>    &lt;/array&gt;<br>    &lt;key&gt;UIPrerenderedIcon&lt;/key&gt;<br>    &lt;false/&gt;<br>   &lt;/dict&gt;<br>   &lt;key&gt;ams&lt;/key&gt;<br>   &lt;dict&gt;<br>    &lt;key&gt;CFBundleIconFiles&lt;/key&gt;<br>    &lt;array&gt;<br>     &lt;string&gt;ic_ams&lt;/string&gt;<br>    &lt;/array&gt;<br>    &lt;key&gt;UIPrerenderedIcon&lt;/key&gt;<br>    &lt;false/&gt;<br>   &lt;/dict&gt;<br>   &lt;key&gt;paris&lt;/key&gt;<br>   &lt;dict&gt;<br>    &lt;key&gt;CFBundleIconFiles&lt;/key&gt;<br>    &lt;array&gt;<br>     &lt;string&gt;ic_paris&lt;/string&gt;<br>    &lt;/array&gt;<br>    &lt;key&gt;UIPrerenderedIcon&lt;/key&gt;<br>    &lt;false/&gt;<br>   &lt;/dict&gt;<br>  &lt;/dict&gt;<br>  &lt;key&gt;CFBundlePrimaryIcon&lt;/key&gt;<br>  &lt;dict&gt;<br>   &lt;key&gt;CFBundleIconFiles&lt;/key&gt;<br>   &lt;array&gt;<br>    &lt;string&gt;ic_none&lt;/string&gt;<br>   &lt;/array&gt;<br>   &lt;key&gt;UIPrerenderedIcon&lt;/key&gt;<br>   &lt;false/&gt;<br>  &lt;/dict&gt;<br> &lt;/dict&gt;</pre><p>In this case we define 3 alternate icons:</p><ul><li>barca (icon ic_barca)</li><li>ams (icon ic_ams)</li><li><em>paris</em> (icon ic_paris)</li></ul><p>And we have the primary icon (the default one) ic_none.</p><h3>Call SetAlternateIconName API</h3><p>Once the icons are declared, we simply have to call <a href="https://developer.apple.com/reference/uikit/uiapplication/2806818-setalternateiconname">setAlternateIconName(_:completionHandler:)</a> on UIApplication shared instance with one of the declared icon names. For instance, if we want amsicon:</p><pre>UIApplication.shared.setAlternateIconName(&quot;it&quot;) { (error) in<br> if let error = error {<br>      print(&quot;error: \(error)&quot;)<br>    }<br>}</pre><h3>Get the name of the icon being displayed for the app</h3><p>If you want to know which icon is being displayed, just read <a href="https://developer.apple.com/reference/uikit/uiapplication/2806808-alternateiconname">alternateIconName</a> on UIApplication shared instance:</p><pre>let currentIcon = UIApplication.shared.alternateIconName</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2abd7b4c0a38" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Xcode]]></title>
            <link>https://isameh.medium.com/introducing-xcode-855cb825121c?source=rss-f0b28db55a3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/855cb825121c</guid>
            <dc:creator><![CDATA[Sameh Mabrouk]]></dc:creator>
            <pubDate>Wed, 19 Nov 2014 14:04:46 GMT</pubDate>
            <atom:updated>2014-11-19T14:04:46.547Z</atom:updated>
            <content:encoded><![CDATA[<h2>Introducing Xcode Source Control</h2><p>As projects grow larger, it becomes more and more important to keep track of the changes that you make and to be able to identify modifications to your code. A change can sometimes cause unintended behaviors that, without a good way to audit your coding, might be difficult to track<br>down. This point holds especially true for projects where one or more people need to access and modify the same project.<br>The answer to this problem is to use source control — a term that refers to a system that keeps track of changes to source code files. Xcode offers integration with two of the most popular source control systems currently available: Subversion and Git. This appendix walks through these options and helps you get started using the tools Xcode provides.</p><p><strong>A Brief Introduction to Source Control Systems</strong></p><p>Xcode includes support for two popular version control systems: Subversion, also known as SVN ( <a href="http://subversion.apache.org/">http://subversion.apache.org/</a> ), and Git ( <a href="http://git-scm.com/">http://git-scm.com/</a> ). Like any version control system, the purpose of these products is the same, but the implementation in Xcode differs enough to be confusing. Before trying to use Xcode with SVN or Git, you need a bit of background in the phi-losophy and terminology of each system.</p><p><strong>Repositories and Working Copies</strong></p><p>Both Git and Subversion can provide server-based repositories. These act as very lightweight file<br>servers that include the files for a project, along with a log of all the changes that have been<br>made over the life of the project.<br>To edit code that is stored in a repository, you create what is called a working copy from all, or<br>a portion of, the repository. The working copy is a local copy of a project that is edited on your<br>computer (often pulled from a Git or SVN repository). The initial creation of a working copy is<br>called a checkout in SVN terminology and a clone in Git terminology.</p><p><strong>Committing Changes</strong></p><p>One of the biggest differences between your use of Git and SVN in Xcode is saving changes to your code. You edit your projects exactly as you always have, editing the working copies of your code. When you decide you want to save a change to the repository, you execute a commit action. The commit notes the change, and gives you an opportunity to annotate the change, as well.</p><p>In Subversion, a commit stores the updated file back to the repository immediately. In Git, how-ever, your local copy is the repository, so nothing is updated on the remote repository. To push<br>your changes back to a network repository, you must execute a push command, as discussed<br>later in this hour.</p><p><strong>Downloading Changes</strong></p><p>As you commit and, in the case of Git, push changes to a central repository, you’ll also want to download changes that other users have added to the repository. To do this, you execute an update command on the SVN repositories and a pull on Git repositories. In either operation, if conflicts with the code occur in your working copy, you are given the opportunity to reconcile the conflicting code.</p><p><strong>Branching and Merging</strong></p><p>Developers often need to maintain a release version of a product while working on new features. The base/release version of a project in Git/SVN is the trunk. New versions of the trunk are developed in branches off of the trunk or off of another branch. In Subversion, you work on branches in a new working copy of your code. Git maintains a single working copy and enables you to switch branches at will.</p><p>When changes are complete, and a branched version is ready to become the release version, it is merged with another branch (or the trunk) to create a unified code base. Conflicts are dealt with, and then the finished code is committed to the repository and pushed (with Git) to the remote server, if desired.</p><blockquote>NOTE: You might, in your SVN/Git travels, encounter references to the term tags. Tags are simply named copies of a repository. You might maintain a tagged copy of each release of your software (version 1.0, version 2.0, and so on).</blockquote><blockquote>TIP:</blockquote><blockquote>If you want to experiment with server-hosted Git/Subversion repositories, I highly recommend signing up for an account at Beanstalk (<a href="http://beanstalkapp.com/">http://beanstalkapp.com/</a> ), Assembla ( <a href="https://www.assembla/">https://www.assembla</a>.com/ ), or Github ( <a href="https://github.com/">https://github.com/</a> ). The first two sites offer low-cost (and trial) accounts with access to both Subversion and Git. The third option (Github) provides free Git repositories for open source projects and low-cost options for private Git repositories.</blockquote><p><strong>Working with Subversion and Git Repositories</strong></p><p>Xcode’s integration of Subversion and Git features directly into the user interface (UI) make working with these systems quite simple, even if you have never touched a version control system before. In fact, Xcode even enables you to create local Git repositories that you can use to track your own changes on a project or share, via a file server, with other individuals working on a project. In this part of the appendix, we create a local repository, and then cover the process needed to connect to remote SVN or Git servers. Because these topics do not necessarily flow together as well as I would like, do not feel bad about jumping around to find the information relevant to you.</p><blockquote>TIP: You can find nearly all of Xcode’s source control features under the Source Control menu, although<br>new repositories can also be added within the Xcode Preferences, Accounts area.</blockquote><h3><strong>Creating Local Git Repositories</strong></h3><p>If you’re a small developer with a good backup system and only a few people working on a project, you’ll probably do just fine with a locally hosted Git repository that Xcode can create for you<br>when you start your project.</p><p>To create a project that includes its own Git repository, follow these steps:<em> 1. Begin the project-creation process, described in Hour 2 . 2. When prompted to save the project, be sure that the Source Control check box is checked, as shown in Figure A.1 . 3. Click Create. The project is created and opened.</em></p><p>As you work on your project, you’ll see status icons (letters) appear beside your files in the project navigator (most often M, as shown in Figure A.2 ). This shows the status of the project’s source control and demonstrates that your new project is within a repository. You’ll learn more about the source control status icons in the section “Managing a Project in Source Control,” later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*fxfzqquoU-C4N99oTZ86dQ.png" /><figcaption>Make sure that you have checked the option to use source control.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*_p3XpQNPPtCMIKRqLXRGsw.png" /><figcaption>You’ll see a source control icon appear in your main project group.</figcaption></figure><p>If you want to start working with files in your repository, skip ahead to the“Managing a Project in Source Control” section.</p><blockquote>TIP: If you establish a local Git repository that you later want to connect to a remote repository, you can do so by choosing Source Control, &lt; Project Name&gt;, Configure &lt; Project Name&gt; from the menu bar. Within these settings, you can click the Remotes button to add a remote Git repository connect.</blockquote><h3>Connecting to Remote Repositories</h3><p>If you have already established a hosted repository outside of Xcode, you can connect Xcode to the repository by walking through a simple setup assistant. This enables Xcode to download and work with copies of the stored code — or upload new code to the server. You manage access to your repositories through the Xcode preferences.</p><p>To add a new repository, follow these steps:</p><p>1. Open the Xcode preferences and click the Accounts icon.</p><p>2. Click the + button at the bottom of the window and choose Add Repository, as shown in Figure A.3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*GH3ZVcqIXlCOYIkjhoRJ3g.png" /></figure><p>3. Enter the URL for the repository, such as <a href="http://svn.placeforstuff.com/teachyourselfios7.">http://svn.placeforstuff.com/teachyourselfios7.</a></p><p>4. Click Next to continue.</p><p>5. If prompted for authentication information, enter your credentials. These are established with your repository provider.</p><p>6. Subversion repositories may prompt for additional information — the paths to the Trunk, Branches, and Tags directories. Enter these if you have them; they are special folders within the repository and are not necessary for creating your connection.</p><p>7. The repository is added to the Accounts settings, as shown in Figure A.4. Selecting the repository enables you to change your authentication information, add a description, and toggle the repository on and off.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*0fyxEcUL5mxkRTdsVKtYmg.png" /><figcaption>Select repository entries to edit information about them.</figcaption></figure><h3>Checking Out a Working Copy</h3><p>After creating a remote repository and connecting to it, you’ll likely want to add your project to it. To do this, you download a working copy of the repository, add your Xcode project, and then commit those changes back to the repository, as follows:</p><ol><li>From the Xcode Source Control menu, choose Checkout.</li></ol><p>2. Click the Repositories button at the top of the window, as shown in Figure A.5.</p><p>3. Select the repository that you want to use, and then click Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*iXC1MRk9O7gOb2WJvi9n5w.png" /><figcaption>FIGURE A.5 Choose the repository you want to access.</figcaption></figure><p>4. Select the directory where you want to save the files, and click the Check Out button, as shown in Figure A.6</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*BxSlTPGr5F9uY31yFACD5Q.png" /><figcaption>Pick where you want to save the working copy.</figcaption></figure><p>5. Xcode downloads the code into the directory you specified. If the repository is empty, this is just an empty folder.</p><p>6. Click the Show button (or simply navigate to the folder in the Finder) and copy your project to the folder.</p><p>Your project is now under source control with a remote repository connection. Your next step is to develop the world’s greatest app while working within the source control system.</p><p>to be continued…</p><p>see you soon…</p><p>Follow Me: <a href="https://twitter.com/same7mabrouk"><em>Twitter</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=855cb825121c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>