Posts

Using Swift Package Manager with Carthage

Some users of my libraries have asked how they can integrate these libraries into their applications using Carthage dependency manager.

Carthage requires libraries to provide an Xcode project or a binary framework. However, since many of my Swift libraries are cross-platform, I am not developing them in Xcode. In addition, distributing binary frameworks from Swift source is not recommended by Apple because the Swift ABI is not yet stable. Therefore the frameworks are tied to specific releases of Xcode.

"While distribution and use of 3rd-party binary frameworks is not recommended …

Read more →

Migrating from OCUnit to XCTest

You might think you were in luck when Xcode offered you an option to migrate to XCTest, but shortly after trying you will discover that this isn't a true migration. Xcode will only migrate your code, it will not update your project to be testable with XCTest. There are still some steps left and unfortunately Apple have not shared any documentation on how to do this.

Note

I have later discovered that it does work as expected, but only if you run the conversion from a project directly. If you try running the conversion from a workspace you will get the problems mentioned above. I have filed this as rdar://16581037 so Apple can fix this in the future. For now, you'll need to follow the below steps.


OCUnit is deprecated, Convert to XCTest


You can follow these steps to migrate your project to XCTest once you've migrated the code with the automatic converter:

Read more →

Versioning with Xcode and git

Wouldn't it be great if your iOS or OS X projects just take their version and build number automatically from git? Well, it can!

Using a script in your build phase, you can run a shell to determine the version number and inject this into the Info.plist of a build. It will never modify your local project, just the created build.

GIT_RELEASE_VERSION=$(git describe --tags --always --dirty)
COMMITS=$(git rev-list HEAD | wc -l)
COMMITS=$(($COMMITS))
defaults write "${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH%.*}" "CFBundleShortVersionString" "${GIT_RELEASE_VERSION#*v}"
defaults write "${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH%.*}" "CFBundleVersion" "${COMMITS}"

Read more →