Xcode 6 GM & Learning Swift (with the help of Xebia)

I guess re-iterating the announcements Apple did on Tuesday is not needed.

What is most interesting to me about everything that happened on Tuesday is the fact that iOS 8 now reached GM status and Apple sent the call to bring in your iOS 8 uploads to iTunes connect. iOS 8 is around the corner in about a week from now allowing some great new features to the platform and ... Swift.

Swift

I was thinking about putting together a list of excellent links about Swift. But obviously somebody has done that already
https://github.com/Wolg/awesome-swift
(And best of all, if you find/notice an epic Swift resource out there, submit a pull request to that REPO, or leave a comment on this blog post.)

If you are getting started, check out:
https://github.com/nettlep/learn-swift
It's a Github repo filled with extra Playgrounds to learn Swift in a hands-on matter. It elaborates a bit further on the later chapters of the Swift language book.

But the best way to learn Swift I can come up with is to join Xebia for a day (or two) and attend one of our special purpose update training offers hosted by Daniel Steinberg on 6 and 7 november. More info on that:

Running unit tests on iOS devices

When running a unit test target needing an entitlement (keychain access) it does not work out of the box on Xcode. You get some descriptive error in the console about a "missing entitlement". Everything works fine on the Simulator though.

Often this is a case of the executable bundle's code signature not begin valid anymore because a testing bundle was added/linked to the executable before deployment to the device. Easiest fix is to add a new "Run Script Build Phase" with the content:

codesign --verify --force --sign "$CODE_SIGN_IDENTITY" "$CODESIGNING_FOLDER_PATH"

codesign

Now try (cleaning and) running your unit tests again. Good chance it now works.

Welcome to the Swift Playground

Imagine... You're working in swift code and you need to explain something to a co-worker. Easiest would be to just explain it and show the code right. So you grab your trusty editor and type some markdown.

let it = "be awesome"

Great!

So now you have a file filled with content:
swift-markdown

But it would be better if it looked like:

playground

Well you can and it's super simple, all you need is some Markdown and:

npm install -g swift-playground-builder

After that it's a matter of running:

playground my-super-nice-markdown-with-swift-code.md

Enjoy!

More info: https://github.com/jas/swift-playground-builder

Mattt Thompson visits Xebia

Mattt Thompson visited Xebia Netherlands.

For three days Mattt presented on various topics of interest. On the 15th Mattt presented to a group of Xebians. On the 16th he did a similar day at my current project at the Dutch ING bank. Finally on the 17th Mattt hosted an open roster training for anybody interested. During the three days Mattt talked about AFNetworking, ReactiveCocoa, Heroku, general tips and tricks related to iOS and ... a preview on the content of the pub quiz he was giving the next week in Amsterdam. No worries we respected Mattt's request to not spoil the fun during the real event by participating with advance knowledge.

In between Mattt and me found some time to go to a CocoaHeadsNL meet-up and have a great diner with a couple of colleagues. As a bonus surprise the ING surprised Mattt with a museum visit as well.
Read more →

A day with Mattt Thompson @ Xebia

On thursday the 17th of October, Xebia is hosting a day long public session with Mattt Thompson.
Mattt is best known as the creator of AFNetworking and Postgres.App, he also maintains the website NSHipster. He is the Mobile Lead at Heroku, a premier cloud hosting platform.

As such, Mattt is an expert iOS developer and speaker. He is also well versed in other technologies, but the focus of the day will be software development on the iOS platform. Mattt will be talking about AFNetworking 2.0 internals, Objective-C API design latest NSHipster and ReactiveCocoa for sure. The rest of the content highly depends on the input of those attending.

We are looking for experienced iOS developers to join us on the 17th. If you are interested please contact us for more details or leave a reply on this blog post.

iOS - Just a quick way to create a shadow on any view

Sometimes you would want a shadow on a view.

Easiest and quickest way is to just add it on the view's layer:

-(void)loadView {
    CGRect frame = [[UIScreen mainScreen] applicationFrame];
    
    self.view = [[UIView alloc] initWithFrame:frame];
    self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    self.view.backgroundColor = [UIColor blackColor];
    
    UIView *glowView = [[UIView alloc] initWithFrame:CGRectMake(frame.size.width /2 -10, frame.size.height /2 -30, 20, 60)];
    glowView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | 
                                    UIViewAutoresizingFlexibleTopMargin |
                                    UIViewAutoresizingFlexibleLeftMargin |
                                    UIViewAutoresizingFlexibleRightMargin;
    
    glowView.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:glowView];
    
    //Setup the shadow on the view's CALayer.
    CALayer *viewLayer = glowView.layer;
    viewLayer.shadowOffset = CGSizeMake(0, 0);
    viewLayer.shadowColor = [[UIColor yellowColor] CGColor];
    viewLayer.shadowPath = [UIBezierPath bezierPathWithRect:glowView.bounds].CGPath;
    viewLayer.shadowRadius = 10.0f;
    viewLayer.shadowOpacity = 1.0f;
 
    //Let's animate it while we're at it.
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
    animation.duration = 0.5f;
    animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
    animation.fromValue = [NSNumber numberWithFloat:1.0];
    animation.toValue = [NSNumber numberWithFloat:0.0];
    animation.autoreverses = YES;
    animation.repeatCount = HUGE_VALF;
    [viewLayer addAnimation:animation forKey:@"shadowOpacity"];
}

I must admit, this is kind of basic stuff. But it seems a lot of people actually forget about the fact that all UIView subclasses are based on Core Animation CALayers.

See the source code https://github.com/xebia/ios-DemoForBlog and try the example, the interesting bits about this example are all contained within the fourth tab of the application, it's the XSDFourthViewController in the code.

iOS - Voiceover and view picking

Something that might interest the developers out there working with accessibility on iOS.

If you have strange behavior, as in, being unable to (partially) pick an accessibility frame by just dragging your finger over the screen, I might be able to answer just why.

As it turns out. VoiceOver and sub views being out of bounds of their parent's view bounds don't really mix.Read more →

iOS - Animation glitch example

A short while ago we were running into an interesting animation glitch. The actual solution is quite simple.

Here's what the glitch was about. A table view could be toggled into an edit mode. On performing this toggle a label would be animated out of the view and hidden. The strange thing was, that this label was resizing it's font size right the second before the actual animation started.

Fortunately we were able to fix this problem.Read more →