Category Archives: Apple Programming

Getting Started with Swift, For NON-Apple Devs

This past weekend I attempted to get started with Swift coding. Since I have not been an Apple Developer for a while, it wasn’t immediately obvious how to get started. But once I fumbled around a few minutes I realized I needed a developer account to get the latest XCode. Jeez, it really shows how much Apple loves to lock you in hard core to their development ecosystem. An unfortunate trait of a company that is actually extremely closed in much of its behavior, while taking advantage of so much of the open source community. But I digress, this isn’t a rant about the unethical behavior of Apple. I’ll reserve that for the novels worth of material it deserves.

One I signed up for the developer program, which costs $99 bucks, I immediately made my first huge mistake. This damnable mistake blew the entire weekend of hacking. I added under “Company” my simple DBA (Doing Business As) name. I already had an account, and because of this change for making this existing account become a developer account from a personal base level account, sprung a red flag. I checked back frequently over the weekend, but it wasn’t until Monday that somebody checked the app, realized the Company name I added was merely a DBA and ok’d my account. So far, 38 hours down the drain for getting started hacking on Swift! Dammit.

However, this morning I was happy to find everything was ok’d, and thus, the remaining bit of this blog entry is a bit more example and a little less story of my day.

Developer @ Apple

Developer @ Apple

Getting XCode 6 beta

I wanted to do Swift hacking, the first step was to download XCode 6 beta. That’s available via download on the iOS Developer page (and I suppose the Mac Developer page). Scroll down on that page until you find the XCode Download button.

The Warnings and the Download XCode 6 beta page.

The Warnings and the Download XCode 6 beta page.

Also note, if you’re looking to do Swift hacking like I’m doing here, I’d actually advise against getting the iOS 8 beta or OS-X Yosemite Developer Previews right now. Best to keep as stable a machine while toying around with a new language. At least, that’s what the conversations have been so far…

OS-X Yosemite & iOS 8

OS-X Yosemite & iOS 8

Once I got Xcode 6 beta installed I dove right into creating a Swift Project. I created a simple new project that is empty to just check out what Xcode 6 provides out of box for the Swift Project.

Selecting an empty Xcode 6 beta project to use with Swift.

Selecting an empty Xcode 6 beta project to use with Swift.

The next dialog is where the Swift magic is selected.

Selecting Swift, entering a project name and other information dialog.

Selecting Swift, entering a project name and other information dialog.

After that I just clicked through on defaults until I got into the Xcode IDE with the project open.

Selecting the appropriate simulator.

Selecting the appropriate simulator.

Next I executed the project. Since I’d had my phone attached it wanted to run it there, but I have 7.1 iOS on it which won’t execute Swift code. I had to select the appropriate simulator then to run the application project. Once that ran, since I’d not done so on this particular computer, I needed to enable developer mode.

Enabling developer mode.

Enabling developer mode.

I did so and the empty application launched.

An empty iOS 8 iPad Retina Application.

An empty iOS 8 iPad Retina Application.

So that’s the basic getting started, no code actually slung. But rest assured I’ll have another post soon detailing some first code snippets. I also hope to get some comparisons written up between XCode with Swift and Xamarin Studio and C#. It’s cool that Apple finally has a modern feature rich language, so it’ll be interesting to see how each stacks up from a language and IDE perspective.

References:

Thor HAMMA! OS-X Cocoa UI for Cloud Foundry

So today we’re super excited to release Thor release candidate from the furnaces of the Iron Foundry. We’ve had number of people working not he project and core Objective-C Coder Benjamin van der Veen @bvanderveen (Twitter), @bvanderveen (Github) and site tearing through tests, implementation, refactoring and UI hacking non-stop these last few weeks. I’ll admit, I think he’s slept some, but nobody knows.

With this new release, the features around…  well…  check out the video.

For a more complete list of the features check out Github, Github Issues & the Iron Foundry Blog.

Thor Project Opens Up, Building the Cloud Foundry Ecosystem with the Community

The Iron Foundry Team are big advocates of open source software. We write code across all sorts of languages, just like many of the development shops out there do. Sometimes we’re heavy on the .NET, other times we’re all up in some Java, Ruby on Rails, spooling up a Node.js Application or something else. So keeping with our love of open source and our polyglot nature we’ve created the Thor Project with three distinct apps.

Before jumping into the applications though, a little context for what and where Thor is in the grand scheme of things. We need to roll back to the Cloud Foundry Project to get into that. The Cloud Foundry Project is an open source project built around software for PaaS (Platform as a Service) which can be used to build your own PaaS internally or externally, in a cloud provider or directly on hardware. It’s your choice how, when and where you want to use it. For more context on PaaS check out my previous entry “The Confusions of IaaS, PaaS and SaaS“.

Thor Project

Cocoa for OS-X

Thor Odinson

Thor Odinson, God of Thunder

You know who Thor is right? He’s this mythic Norse God, also known as the God of Thunder. Since we’re all about bringing the hamma we welcomed Thor into our team’s stable of applications. So starting immediately we’ve released Thor into the realms for contributions and fighting the good open source software battle! If you’d like to join the effort, check out the github project and feel free to join us!

Technically, what is the Thor Application? This is a Cocoa Application built for OS-X that is used for managing, deploying and publishing applications to Cloud Foundry enabled and or Iron Foundry extended PaaS Environments.

.NET for Windows 7

The .NET Metro version of the Thor Application is also released via github with a provided installer. We’ve almost taken the same path, except of course for the very different UX and UI queues with Windows 7 and the Metro UX design guidelines.

WinRT for Windows 8

I wasn’t really sure what to call this version. Is it Metro or WinRT or Windows 8 or something else? Anyway, there is a project, it is albeit empty at this point, but it is the project where the Windows 8 version of Thor will go! For now get the Windows 7 version and install it on Windows 8, it won’t have touch interface support and things, but should work just like a regular application on Windows 8.

The Code

To get started with these, generally you’d just clone the repo and do a build, then get started checking out the code. There is one catch, for the OS-X version you’ll want to pull down the sub-modules with the following command.

git clone git@github.com:YourForkHere/Thor.git
git submodule update --init --recursive

Once you do that in XCode just make sure to then select the right project as the starting build project.

…then when the application is launched…

Thor Running in OS-X

Thor Running in OS-X

I’ll have more in the coming days and weeks about Thor & Iron Foundry. For now, check out the blog entry on the Iron Foundry Blog and subscribe there for more information.

Thor – Cool Objective-C Bits, Libraries and Code Snippets [[TheSeries alloc] init];

Benjamin Van Der Veen (@bvanderveen) has been working with me to build out the Thor Application  based on Nathan Young’s (@nathanyoung) awesome designs. We’ll be releasing open source real soon. I wanted to cover some of the cool libraries, specific code snippets and such. These are a few of the things that have come in very useful as the coding deluge began.

Reactive Cocoa (AKA Reactive Extensions)

When you need to compose and transform sequences of values (kind of like Reactive Extensions for .NET) this is your library when working in Objective-C land. Reactive Cocoa or “RAC” for short can observe on key values to provide a key value for compliant properties. RAC helps to keep mutability under wraps (which is really really needed in Objective-C), pulls together behaviors and relationships between properties, and helps tremendously with asynchronous actions. The last bit we have a good amount of occurring with Thor since it talks to the Cloud Foundry web service API end points.

An example I snagged from the github site is below. It watches for changes on the username property.

[RACAbleSelf(self.username) subscribeNext:^(NSString *newName) {
    NSLog(@"%@", newName);
}];

Which serves, as pointed out in the README.md (be sure to read it if you’re going to use the library), as a wrapper around KVO. It goes on to show further sequences on complex actions.

[[[[RACAbleSelf(self.username)
    distinctUntilChanged]
    take:3]
    where:^(NSString *newUsername) {
        return [newUsername isEqualToString:@"joshaber"];
    }]
    subscribeNext:^(id _) {
        NSLog(@"Hi me!");
    }];

For some that write C# all the time this might seem like a “meh” moment. But considering the work that would be needed in Objective-C usually this could take significantly more lines of code, such as setting an observer, using a property or something to watch the value, monitor the non-distinct changes, and then bounce the value of the property for every non-distinct value. Yeah, and it still isn’t done. But anyway, that’s just the icing, the cake is delicious. If you’re in Objective-C land much, it is worth checking out.

Check it out on Github.

A Tour of My Workspace & Dev Tools – Virtual & Physical

First off, here’s a tour of my physical space where I do the bulk of my coding when I’m not travelling.

Right Side Monitors (and iPad3)

Right Side Monitors (and iPad3) Click for full size image

The second bit, a good many months ago I published my developer tools list, which is still available in my blog entry “My Current Windows Developer Machine“. That entry however is very outdated. I’ve since dropped the Windows OS as my primary developer platform operating system for a deluge of reasons. In it’s place is OS-X, Ubuntu, and VMs for Windows and other operating systems. Even though I’ve changed my OS of choice, and boy has life been much simpler ever since, I still do a ton of .NET & C# Development. My toolset however has been minimized for Windows. It now includes the following.

Music Generation

Music Generation (Click for full size image)

Virtualized Windows Development Machine

  • Windows 7
  • Visual Studio 2010 w/ SP1 + other downloads available at http://www.asp.net
  • ReSharper ( I keep this updated, even if I buy it out of pocket because it saves THAT much time w/ .NET Dev )

Yup, my Windows machine is now THAT simplified. Dev on it is just as easy or easier before. With an SSD drive in my MacBook Air and the iMac I have w/ 16GB of RAM, it’s easy to have the VM perform BETTER than a natively installed version of Windows 7. I know it is hard to believe, but it is true. But I digress, I won’t try to sell you on that. Give it a try, research it, you’ll need to know for sure yourself to make that leap.

My main development OS these days however is OS-X, and here’s my stack of tools for it.

  • Ruby on Rails (It comes w/ the default install, but in case hit the site to check out the latest bits)
  • Gems so I can get any of those shiny bits I need.
  • Node.js w/ Express.js generally.
  • WebStorm for PHP/JavaScript/Ndoe.js hacking w/ an IDE => Check out JetBrains
  • IntelliJ for Java Dev => Check out JetBrains
  • Objective-C with XCode (easy, just grab it via the app store)
  • TextMate
  • Sublime 2

For office things, I sometimes use Microsoft Office, but generally Google Docs works just fine.

For video editing and creation, such as the video above I use ScreenFlow. Again, something you can easily get via the App Store.

I use MOU for editing README.md files on github, cuz it makes life simpler.  🙂

…and that about wraps it up. Enjoy. If you have any suggestions, thoughts, or rants, please let me know in the comments!  Cheers!

OS-X Cocoa Quickie #1 => Make Sure to Have Unit Tests

When starting an Xcode Cocoa Project you should have a testing project that you include. It’s a simple check box on the project creation dialogs.

Keep This Checked! Write Tests!

Keep This Checked! Write Tests!

If for some reason you inherit a project that doesn’t have unit tests, tests, or anything of the sort and need to add a testing project follow these steps. With the project open add a new target as shown below.

Add a New Target to the Project

Add a New Target to the Project

Add a Cocoa Unit Testing Bundle.

Cocoa Touch Unit Testing Bundle

Cocoa Touch Unit Testing Bundle (Click for full window and full size image)

Set the appropriate parameters for your project. Be sure to select the project from the drop down.

Set the product name and be sure to select the correct Project from the drop down. (Click for full window and full size image)

Set the product name and be sure to select the correct Project from the drop down. (Click for full window and full size image)

Once finished adding the testing target, edit the schema. The project will have an additional schema. I personally like to keep them rolled together, so delete the “*Tests” schema and just make sure that the Tests section has the right target listed.

Schema Settings

Schema Settings

If it isn’t listed, as shown in the above dialog, click the + to add the tests project. Select it in the target dialog as shown below.

Adding the test target for the schema

Adding the test target for the schema

Once all that is done then the tests can be executed from the Product -> Test menu option or the shortcut key combo of ⌘U. With the default code that is added to the target project, you’ll end up with one failing test.

Test FAIL!

Test FAIL!

Now write tests!