vendredi 26 août 2016

Code signing tool : check your provisioning profiles

Signing an application to make it run on a physical device or to distribute to clients may be a real pain for iOS developers. With experience you get a clearer picture of how this works. The tool I'm presenting here helps you get a better understanding at provisioning profiles and it has become essential to me over the past two years when a lot of my time went to delivery and project configuration.

This is an open source project hosted on GitHub with the latest release being available here.

It works as a Quicklook plugin and allows you to visualize the content of a provisioning profile simply by pressing space on the file in the finder.


It gives you basically all the information contained in a provisioning profile from the name/ID of the application to the creation / expiration dates including the list of devices allowed, the type of profile and the names and expiration dates of the certificates related to it. This way you can quickly know if a developer or device is included to the profile you have on your machine without having to explore the Apple Developer Portal. Used in combination with Apple Keychain application, it will give you a way to be sure your signing material is OK and your profile is matching your certificate/device duo.

As a reminder, to get the list of all profiles known to XCode, you can go to XCode > Preferences > Account , click on your team and "View details". You can download here any missing profile and then check it with the plugin : right-click and "Show in finder" on any line in the list. XCode will normally take you to this folder :
/Users/&ltusername&gt/Library/MobileDevice/Provisioning Profiles

Another interesting feature : the preview of a .ipa and .xcarchive displays the information about their embedded profile giving you a way to check the binary your intern just created is correctly signed before sending it to the client ;)

With iOS 10, XCode team seems to have done a lot of work to better integrate the signing process to our IDE. However I have the feeling this little Quicklook plugin may still be useful to many of us :)

jeudi 25 août 2016

Sweet Swift tricks

The more you look into the language, the more you realize that Swift is very well thought.

This ongoing article will give away some cool tricks of the language

Underscore characters in integers or floats


This is the kind of feature that makes you wonder why it hasn't been introduced in programming languages until these glorious Swift days. In Swift, reading large numbers isn't a struggle anymore.

let veryLargeInt = 1_000_000_000

You may place underscores anywhere you want in order for the number to make sense. Another example is credit card number

let uglyCreditCardNumber = 1234567890123456
let beautifulCreditCardNumber = 1234_5678_9012_3456

vendredi 15 janvier 2016

How to use Objective-C and Swift snippets on Blogger

If you're like me and starting a blog about software engineering, your first bump on the road to success will be the publication of code snippets in your articles. Those little bits of code always come in handy when arrives the time of giving examples :

func foo(){
    print("this is just a little bit of code")
}

First, you need to choose a good syntax highlighter that you're going to use on your blog pages. Personally,  I chose to work with PrismJs. It is lightweight and doesn't add a self-promotional link to each snippet which I fear may be annoying from the reader point of view. However, it doesn't display the line numbers.

1) First download the CSS and Javascript files on this page. You have to select a theme for your snippets and the languages you will need to render.

2) In order for the reader's browser to parse these files, they need to be stored somewhere accessible publicly. The speed of the server holding them is essential for your blog pages to be rendered quickly.
The easiest solution I found is to upload them on google drive. There is a complete tutorial on how to make them public on this blog
EDIT 19/08/2016 : This solution won't be valid anymore as Google is dropping the hosting feature on Drive to promote his Firebase solution. You can give it a try but for me it seemed a little over-powered to just serve a CSS and a javascript file. Instead I used Dropbox file sharing feature.

In order to do that, you need to register and create a Dropbox account. 
- Drag and drop your CSS & Javascript files in the Dropbox root folder (on this page https://www.dropbox.com/home). 
- Right-click on each file to share it. Create the link and you should en dup with an URL that looks like this : 
https://www.dropbox.com/s/av1jmgqj5glwgny/prism.css?dl=0
- Replace "www.dropbox.com" with "dl.dropboxusercontent.com" :  https://dl.dropboxusercontent.com/s/av1jmgqj5glwgny/prism.css?dl=0 

You have the addresses of your CSS and JS files ;)

3) Now that the files are online, you can reference them in the template file of your blog. To do that, just go to the "template" section of your blog settings. Hit the "modify HTML content" and add those two lines with your Dropbox file URLs at the end of the head section (before </head> tag)

<link href='your CSS file URL goes here' rel='stylesheet'/>
<script src='your Javascript file URL goes here'/>

4) In your articles, to put code snippets, you must be in HTML mode (upper left corner) and format your code as follows :

<pre><code class="language-swift">func foo(){
    print("this is just a little bit of code")
}</code></pre>

which is the code I used to produce the snippet at the top of this article. The "class" attribute of the "code" tag must respect the pattern language-**** , **** being the language of your snippet (objectivec, swift, html, etc...)

That's it for this short tutorial. I hope it was useful to you. If you have any question, don't hesitate and ask in the comments or send me a message ;)