20 September, 2016

How to remove the Dashboard on a Mac

If you are just as annoyed as I am with the useless Dashboard app on a Mac - there is one effective way of killing it.

Open a terminal window and write:

Remove:

defaults write com.apple.dashboard mcx-disabled -boolean YES && killall Dock


Enable

defaults write com.apple.dashboard mcx-disabled -boolean NO && killall Dock

14 September, 2016

Running Xcode 7.3.1 and Xcode 8.0 on the same machine

If you need to be running Xcode 7.3.1 and 8 together (as I am!); you can not install them just like that. You need to fiddle a bit with the apps to have them work together.

  • Download the Xcode 7.3.1.dmg file from apple developer portal.
  • Download the Xcode 8.xip file from apple developer portal.

Once you’ve done that, you can install version 7.3.1 into “applications”:

Xcode 7.3.1

  1. Double click the .dmg file to open the “drive” it represents.
  2. Drag the Xcode icon into “application"
  3. Rename the resulting xcode.app in “applications" to xcode_7.app


Xcode 8

Now - the turn comes to Xcode 8. You unzip the .xip file and drag into Applications the resulting xcode.app file (it’s version 8).

You now have 2 versions of Xcode on your Mac and start them independently.

  • Xcode_7.app
  • Xcode.app


The reason I’m not renaming the XC8 version is due to future updates coming from Apple. I’m not sure how they search for apps locally during an update process...

13 September, 2016

Enums in C# vs. Swift - how to

The concept of a “flagged enum” is quite a powerful one as it allows you to express multiple things with just a simple number (integer). Coming from a .NET background - the ease of flagged enums found in C# is not that easily found in Swift I’ve come to realize. The expression in Swift is somewhat different and honestly a bit difficult to grasp.

Let’s give it a try:

C#

In C# you express an enum like this:

[Flags]public enum SecurityLevel : Int{
	case NoAccess = 0
	case Employee = 1,
	case LineManager = 2,
	case DivisionManager = 4,
	case RegionalManager = 8,
	case CountryManager = 16}


This constructed example serves a purpose like:

var person = new Person();
person.AccessLevel = 3 //meaning access as Employee AND LineManager

This will allow us to model a Person with multiple access levels (security levels) with just a single integer. An easy way to store in the backend database as well!

Swift

So - how does this look in Swift?

public struct securityLevel : OptionsSetType {
	let rawValue : Int
	static let noAccess = securityLevel (rawValue: 0)
	static let employee = securityLevel (rawValue: 1 << 0)
	static let lineManager = securityLevel (rawValue: 1 << 1)
	static let divisionManager = securityLevel (rawValue: 1 << 2)
	static let regionalManager = securityLevel (rawValue: 1 << 3)
	static let countryManager = securityLevel (rawValue: 1 << 4)
}


Quite a different beast, ey? How can this be the same you are thinking?
The strange << operator is called a bitwise left shift operator and and actually does what it says - it moves all bits in the array to the left by the number specified.

Looking at the securityLevel struct again, we have:

setting the value to noAccess:
0|0|0|0|0|0 = 0
setting the value employee:
0|0|0|0|0|1 = 1
setting the value lineManager:
0|0|0|0|1|0 = 2

combining the values (employee AND lineManager)
0|0|0|0|1|1 = 3


So the left shift stuff is actually initializing the struct with the value of 1, and then it moves all bits a number of slots to the left to end up with a whole new number. In our example with the combined employee and lineManager - we will see first the employee being set (rawValue:1 <<0)

  • init with 1 -> 0|0|0|0|0|1
  • next move it 0 places to the left -> 0|0|0|0|0|1
  • end result = 1

Next is the lineManager value (rawValue: 1 << 1):

  • init with 1 -> 0|0|0|0|0|1
  • next move it 1 places to the left -> 0|0|0|0|1|0
  • end result = 2


When combining the operations (employee AND lineManager) you are actually just performing the above operations in sequence ending up with the value 3.

Easy to understand? Not so much ;-)

23 August, 2016

Essential (developer) tools: A biased list – 2016 Mac version

I have been doing a collection of tools relevant to a life as a developer on .NET, but having recently swiched to Mac - here is the same (current) list as an XCode developer.

Development tools:


Quite a short list, but life in Mac world is simple (remember: simple != easy)

Publishing from Mac Sierra to TestFlight: problems

If you have jumped onto the band wagon that says beta on the side; you have also signed the certificate with a title that says “problems ahead”! I have indeed been on that wagon for some time as I’m currently running XCode 7.3.1 + XCode 8.0 at the same time on a Mac Sierrra OS (which is in beta for the time being).

Apple appearently only accept software that is built on a release version of their OS (El Capitan for now). This means, that you cannot build apps using (XCode 8.x or Mac Sierra) and expect the publishing process to go smoothly. You need to fiddle with stuff to make Apple believe you are indeed using a released OS (i.e. El Capitan).

So to downgrade the OS without uninstalling it - you need to “change the OS" to something that resembles a released OS as this value is presented to Apples servers during the submission process. Where do you change this OS version to publishing can function without problems? And where do you find a valid value for this setting?

Here is how:
You change the value here: /system/library/……/coreservices/systemversion.plist


What value is accepted (at the time of writing)?
If you log in to the developer portal - you will find the build number of the latest released OS here (the value us: 15G31)

To sum up the process:

  • Change the system version in the systemversion.plist file to a valid value (15G31)
  • Build your app using a valid XCode version (i.e. 7.3.1)
  • Archive the app and export the .ipa to your local disk
  • Here is the fun thing: I could only make the publishing process work if I published the app using the Application Loader coming with XCode 8.0!

This is what it takes to be allowed to publish your app to TestFlight using a mix of beta and release software.

Update: It turns out that also every single xib file (which is .xml) carries this very number embedded. Man, they are really keeping track of everything!

10 April, 2016

Using VSTS from SourceTree on a Mac

Using Visual Studio Team Services is a great joy. It is a seamless experience when on Windows, but does require one extra step when using it from a Mac. As is the case when using VSTS from XCode (see http://blog.clauskonrad.net/2016/03/using-visual-studio-team-services-git.html) you also here need to establish an alternative representation of yourself that can work as authentication.

Here is how to use the SourceTree application on a Mac against VSTS:

  1. Log into VSTS (website)
  2. Select your name (top right)
  3. Select My Profile
  4. Select Security
  5. Select Add
    image
  6. Copy the generated Token (it will show only once) into a text file on disk
  7. Open SourceTree
  8. Press Repositories
  9. Select Clone from Url
  10. Enter the SourceControl Endpoint (https://<nameofcollection>.visualstudio.com)
  11. When prompted for Username/password – enter the Token instead of your username
  12. Enter your normal password
  13. You are in!
Screen Shot 2016-04-08 at 10.27.01


Screen Shot 2016-04-08 at 10.23.49

16 March, 2016

Using Visual Studio Team Services (GIT) on Windows and Mac at the same time?

Why use Visual Studio Team Services?


Microsoft’s Azure backed (and thus hosted) source control system Visual Studio Team Services really is a great toolset to work with. As they have made it as easy as they have to work with; I find it extremely difficult to argue why you would want to host your own source control system anymore?

image


I agree that back in the day that was how you did it; but honestly few developers get paid for managing a source control system per se. They are paid to deliver the product the source control system holds, which is the software product they are building. If you are dealing with defence related software one might argue that due to IP rights and the nature of the product; it might make sense but for the rest of us mere mortals, it is just an unnecessary hassle to manage this piece of infrastructure. Therefore – it is with the greatest conviction I’m proposing and using myself the hosted source control system in Azure both in a private setting as well as a business related setting.


GIT on TFS?

Github has become extremely popular the recent years. Initially I found it difficult to understand and appreciate that popularity as I came with 10 years of experience with the original Team Foundation Server myself; but is it not always like that when you do not understand something foreign to you? Having gotten my head around this source control system known as GIT I with a full heart honestly can understand and appreciate the nature of this system.

Using VSTS (GIT) on Windows and Mac at the same time?


As I’m not only doing Windows development these days, I have a need for hosting my source code somewhere common. I do not want to setup two different systems just because I happen to be developing in two worlds (.NET and Apple). After all source code is ultimately just a set of text-files (strictly speaking).From a Windows machine (i.e. Visual Studio 2013/2015) it’s a walk in the park to authenticate with VSTS as this to no surprise supports Microsoft accounts natively.

image


Unfortunately, this is not the case when attempting to authenticate from Apple’s XCode IDE. They do not support the usage of ‘name@domain.com’ for some bizarre reason. You need to generate a person token that ‘imitate’ your username. How you do this is the topic of the below paragraph and I hope it can serve you as a guide so you do not need to figure this out yourself the hard way as I did.

Setting up GIT/VSTS access from XCode


    First you need to create a personal token for your username to work as stand in for you in XCode:
    1. Login to the website of your source control system (<name>.visualstudio.net)
      Screen Shot 2016-03-16 at 23.22.38
    2. When in the website – navigate to the section called My Profile –> Security
      Screen Shot 2016-03-16 at 23.22.54
    3. Press Add to crete a new token
      Screen Shot 2016-03-16 at 23.23.17
    4. You are done on the server side now. Open XCode on the Mac
    5. Open the Source Control menu item and press CheckOut
      Screen Shot 2016-03-16 at 23.25.24
    6. When it prompts you for credentials, enter the token instead of your normal username (microsoft account)
    7. Enter your password as you are used to and Next
    8. You are done and can now use Git from X-Code as if you were talking with Github or something else speaking GIT.


    That is actually all there is to it. You will be able to find your source code and branches in VSTS online immediately after a push.

    Technorati Tags: ,,,