Package.swift - manual

Here is documentation for SPM manifest file Package.swift. I couldn't find a list of possible configuration values for Package.swift, so I created one, for future reference. I put here all available settings, with examples of use. Please find examples at the end of the post. Preamble Package.swift…

Sharing distribution certificate. automat.

One thing at a time Importing and sharing iOS/macOS certificates and keys required for AppStore distribution of application can be pain 🔥 as we know it. with a little command line, I can help myself a little bit. Here, I'm building command line shell script that will load certificates if…

Documenting Swift protocol

In Swift, I can write documentation at a protocol level now. There is a kick-ass feature added recently to Xcode 8 (beta 4). If I add documentation of function at the protocol level, it's available at the level of implementation. look, I wrote documentation to Task.run() and I can…

Queues are not bound to any specific thread

It all started with this snippet from @jspahrsummers #import <Foundation/Foundation.h> int main (int argc, const char **argv) { @autoreleasepool { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_sync(dispatch_get_main_queue(), ^{ NSLog(@"is main thread? %i", (int)[NSThread isMainThread]); }); }); dispatch_main(); } return…

Status of Portable Swift code

Portable Swift source code is so damn hard to do. Main problem is that OSX and Linux Swift is using different Foundation codebase. Linux is using SwiftFoundation and OSX is using Foundation. What's the difference ? Foundation vs SwiftFoundation Foundation is written in Objective-C, it's complete and stable. SwiftFoundation on the…

CloudKit Security model

CloudKit security model is barely described in documentation, yet it's very important aspect of this cloud solution. I do care about privacy and I believe privacy aspect is important when implementing Cloud driven solutions. The subject is not widely explained in documentation, hence I'm writing this blog post as a…

Overload Swift type ambiguity

I may define default type for overloaded functions. sometimes. This is Swift return overloading that may lead to ambiguity: extension String { func encode() -> NSData? { return self.dataUsingEncoding(NSUTF8StringEncoding)?.base64EncodedDataWithOptions([]) } func encode() -> String? { return self.dataUsingEncoding(NSUTF8StringEncoding)?.base64EncodedStringWithOptions([]) } } I have two functions encode() that returns value of…

Retry! in the wild

In perfect world every action finish with the success. In real world it's not. In perfect world sending network request returns with a result. In real world it fail sometimes due to dozen of reasons, and since we're living in the real world I have to deal with it. don't…

How to be awesome Swift developer

I don't know, but I received enough emails from various people asking me how to be "awesome Swift developer" to write this post. I’d be an iOS developer and it would be amazing if you could me advise on the right path to follow to accomplish that. Lets say…

Linux compatible Swift and Swift Package Manager

Apple opensourced Swift today, as promised in early 2015. This is great, awesome etc... but I'm not about that here. Together with Swift - programming language, Apple presented Linux port of Swift compiler and some tools. One of the tools is Swift Package Manager - that's the reason of this…

Code at the end of the queue

NSOperation and NSOperationQueue are great and useful Foundation framework tools for asynchronous tasks. One thing puzzled me though: How can I run code after all my queue operations finish? The simple answer is: use dependencies between operations in the queue (unique feature of NSOperation). It's just 5 lines of code…

Swift reflection about food

Reflection in practice Reflection technique may be useful to build quasi generic functions that operate at runtime. It may be quasi type safe, though it uses runtime too - as such can't be optimised/validated during compilation. With Objective-C we used <runtime/objc.h> and do all the…

Where "where" may be used?

This is by far the most faved/retweeted Swift tip of mine lately: don't forget you can do this 🎉 in Swift #swiftlang pic.twitter.com/izVlfcqOYv— Marcin Krzyzanowski (@krzyzanowskim) November 10, 2015 indeed cool, unexpected and forgettable feature of Swift pattern-matching. The fact is you can use…

Swift London about Natalie, the talk

Earlier this month (October 19, 2015), I had the pleasure to be part of Swift London meetup. I talked about Natalie - Storyboard Code Generator presenting my approach to the "problem" of Storyboards and Swift. Below you can find my presentation, along with an amateur video recording (captured by iPhone)…

ChunkSequence 🔪🍰

Have cake and eat it Have a cake and consume the cake by the Swift function, at the same time. Magic. The nature of the Swift type is that it is copied or copied on write. When I assign A to B (A = B), then effectively B is copy of…

CryptoSwift 0.1.0

Finally major update to CryptoSwift framework. Crypto related functions and helpers for Swift implemented in Swift. I really enjoy working on CryptoSwift in my spare time, this is why today I'm glad to announce version 0.1 with a major changes to the public API and to the internal state…

Generic Array of Int - what, why, how?

One of the great feature introduced by Swift 2.0 is possibility to define generic functions for type of Array. Array is container for values of some type. The type is known upfront. It's called Element now. what? Array is a struct with element and is defined like this: struct…

Fast pattern search in Swift... since 1974

the fastest known ways to find one string of characters in another Stay with me. At the beginning brief introduction, later on Swift implementation, tests and conclusion. Halt and Catch Fire thing I really enjoy Halt and Catch Fire tv show. Season 1 was about hardware, while season 2 is…

How to change iCloud password in 57 steps

First you have to find screen of horror, like the one I saw during activation my new iPad. Now sit back, brew a cup of tea and relax. You need it all to survive process of changing password designed by Apple. If happened you on you Mac at the moment,…

Collection Index and magic factor

An index is an indirect shortcut derived from and pointing into, a greater volume of values, data, information or knowledge. (wikipedia) In general (however it is not the rule) in modern programming languages Index values start at 0 position and ends at "length - 1" position. A lot of fathers…