Plausible Blocks 1.1 Beta

February 8th, 2010 / Announcements / Open Source
By: landonf

Plausible Blocks (PLBlocks) provides a drop-in runtime and toolchain for using blocks in iPhone 2.2+ and Mac OS X 10.5 applications. We’ve started using PLBlocks in shipping iPhone applications, and soon-to-ship Mac OS X applications, and have been working to add support for some key features — the new PLBlocks 1.1-beta2 is the first release to include:

  • Objective-C Garbage Collection Support
  • C/C++ support

We’ve been using the new beta release for our own day-to-day development for a few weeks now, and hope you’ll help us test out some of the new features. The updated SDK is available for Leopard and Snow Leopard from the PLBlocks project page.

If you’d like to read more about using blocks in your own software, we recommend:

iPad Support

We’ve verified that both PLBlocks 1.0 and 1.1-beta2 work with the iPad SDK, and plan on integrating Apple’s beta iPhoneOS compiler updates in a future preview release of PLBlocks for iPad developers.

The new iPad compiler also appears to support the use of blocks on iPhone OS 3.2+; we’ll be very excited to see official block support for the platform. The iPhone OS 3.2 SDK GCC sources can be found at http://opensource.apple.com/tarballs/seeds/.

Tags: , , ,


PLBlocks 1.0-beta2 Released

July 11th, 2009 / Announcements / Open Source
By: landonf

We’ve just released Plausible Blocks 1.0-beta2, which provides a drop-in runtime and Xcode-compatible compiler for using Blocks in your iPhone 2.2+ and Mac OS X 10.5 applications.

Changes

This release was focused on expanding the supported host and target architectures (thanks to everyone who provided testing!).

  • iPhone OS 2.2 and later are now supported.
  • The runtime is now available as an iPhone 3gs optimized armv6/armv7 universal binary.
  • Development is now supported on PowerPC systems.

Download

The initial beta of Plausible Blocks is available for Leopard and Snow Leopard:

This beta release is provided for developer testing and experimentation. Plausible Blocks supports targeting Mac OS X 10.5 (PPC, i386, x86-64), iPhone OS 2.2+ (armv6, armv7), and iPhoneSimulator 2.2+ (i386). Garbage collection and Mac OS X 10.4 are currently unsupported.

Further Reading

If you’re interested in learning more about blocks, here are a few articles to get your started:

Tags: , , ,


Blocks for iPhoneOS 3.0 and Mac OS X 10.5

July 2nd, 2009 / Announcements / Open Source
By: landonf

Introduction

Update Sept 3rd 2009: Check out our more recent posts on PLBlocks.

If you’ve been following the wide variety of developer features planned for Snow Leopard, you may have noticed Apple’s introduction of Blocks, which add closures to C and Objective-C, along with preliminary support for C++.

Blocks are a great addition to Objective-C, but unfortunately, are only available in Mac OS X 10.6. We have a quite a bit of code that could be greatly simplified using blocks, and so I decided to spend some time back-porting block support to iPhoneOS 3.0 and Mac OS X 10.5.

The result, Plausible Blocks, provides a drop-in runtime and Xcode compiler for using blocks in your iPhone and Mac OS X 10.5 applications, based on Apple’s Snow Leopard blocks runtime and compiler support.

Closures are not a new idea — originally conceived nearly 40 years ago, they’re a staple of many languages, from Lisp to JavaScript. If you’ve used a functional language (or a language that borrowed some ideas from one), chances are very good that you’ve made use of closures:

Ruby

books.each { |book| puts (library.to_s + ': ' + book.title) }

JavaScript

function setClickMessage (button, message) {
    button.addEventListener("click", function() {
        /* This is a closure */
        alert(message);
    }, false);
}

Scala

def findBooks (title:String): Seq[Book] = books.filter { book =>
    /* This is a closure */
    book.title == title
}

C and Objective-C Blocks

NSArray *result = [values mapConcurrent: ^(id value) {
    /* Execute closure concurrently on available CPUs, collecting the results */
    return ExpensiveComputation(value);
}];

Closures are well suited to modeling a wide variety of higher-level programming constructs, and in doing so, can greatly simplify your code and enable functionality that would simply be too cumbersome to implement any other way. For some additional information on blocks, and why they’re interesting, I’d suggest reading Mike Ash’s great Friday Q&A on Blocks, and my own Using Blocks post, which includes some sample code to get you started.

Download

The initial beta of Plausible Blocks is available for Leopard and Snow Leopard:

This beta release is provided for developer testing and experimentation, and should not be used for production software prior to further testing and review. Plausible Blocks supports targeting Mac OS X 10.5 (PPC, i386, x86-64), iPhone OS 3.0 (armv6), and iPhoneSimulator 3.0 (i386). Garbage collection and Mac OS X 10.4 are currently unsupported, and the SDK requires an Intel Mac.

The Plausible Blocks runtime makes use of custom, prefixed symbol names to avoid any binary conflicts that could occur should Apple add block support to iPhone OS, or when running your binaries on 10.6. The provided compilers are based directly on the Apple standard, stable compiler versions as shipped with the Mac OS X and iPhone SDKs.

Installation & Use

Plausible Blocks is composed of two pieces:

  • Plausible Blocks SDK: Supplies custom compilers for use in Xcode.
  • PLBlocks Runtime: A runtime library required by all applications making use of Plausible Blocks.

To install the SDK, simply install the included “Plausible Blocks SDK” package. Once installed, an additional “GCC 4.2 (Plausible Blocks)” compiler will be available for selection in your Xcode project and targets. To build with the new compiler, simply select in either your project’s build settings, or on a per-target basis:

In addition to the SDK, you’ll need to include the PLBlocks runtime framework in your application. It is provided as an embeddable framework for Mac OS X, and as a static framework for iPhone applications.

To include in your project:

  1. Copy the Mac OS X or iPhone PLBlocks.framework to your project directory
  2. Within Xcode, select “Add -> Existing frameworks” and add the copied PLBlocks.framework to your project.
  3. Ensure that PLBlocks.framework has been added to your targets “Link Binary With Libraries” section.
  4. (Mac OS X Only) Add a new “Copy Files” build phase to copy PLBlocks.framework to your application’s “Framework” directory.
  5. Set the project, or a specific target, to use the “GCC 4.2 (Plausible Blocks)” compiler.

Development

The full PLBlocks source code is available from the PLBlocks project page. If you’d like to contribute to the SDK, runtime, or simply discuss programming with blocks, please consider joining the development list at: http://groups.google.com/group/plblocks-devel

To build PLBlocks, select one of the following targets:

  • Disk Image: Builds entire project and generates a distribution DMG.
  • Package SDK: Builds SDK package, including all compilers, and Xcode plugins
  • Runtimes: Builds all runtimes

The project should build on Mac OS X 10.5 and 10.6. In addition to Xcode 3.1.3 or 3.2, the iPhone 3.0 SDK is required.

Building the full SDK, including compilers, may take an extraordinarily long time. Unless you are experimenting with the compiler toolchain — or you are the type to enjoy watching paint dry — building only the Runtime targets during development is highly recommended.

Tags: , , ,