Introduction
Plausible Blocks (PLBlocks) provides a drop-in runtime and toolchain for using blocks in iPhone 2.2+ and Mac OS X 10.5 applications. Both the runtime and compiler patches are direct backports from Apple's Snow Leopard source releases.
PLBlocks is provided by Plausible Labs.
Supported Architectures (1.0):
Targets
- Mac OS X 10.5 (ppc, i386, x86-64)
- iPhoneOS 2.2 and later (armv6, armv7)
- iPhoneSimulator 2.2 and later (i386)
Hosts
- Mac OS X 10.5 (i386, x86-64, ppc)
- Mac OS X 10.6 (i386, x86-64)
Languages
- Objective-C (no garbage collection)
- C, C++, and Objective-C garbage collection support are available in the 1.1-beta2 release.
If you're interested in supporting additional platforms (Linux, Windows, etc.) please feel free to join the development mailing list
Download
Plausible Blocks 1.0 SDK
Plausible Blocks 1.1-beta2 SDK
The Plausible Blocks runtime makes use of custom, prefixed symbol names to avoid any binary conflicts when Apple adds block support to iPhone OS, or when running your binaries on Mac OS X 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. The runtime is based on Apple's original implementation donated to the LLVM project.
The 1.1 compiler remains compatible with the existing PLBlocks 1.0 runtime, but use of new features (garbage collection, C/C++ support) also requires a PLBlocks 1.1+ runtime.
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:
- Copy the Mac OS X or iPhone PLBlocks.framework to your project directory
- Within Xcode, select “Add -> Existing frameworks” and add the copied PLBlocks.framework to your project.
- Ensure that PLBlocks.framework has been added to your targets “Link Binary With Libraries” section.
- (Mac OS X Only) Add a new “Copy Files” build phase to copy PLBlocks.framework to your application’s “Framework” directory.
- Set the project, or a specific target, to use the “GCC 4.2 (Plausible Blocks)” compiler.
Additional Resources
If you'd like to read more about using blocks in your own software, we recommend:
- Joachim Bengtsson's Programming with C Blocks
- Mike Ash's Series on Blocks and PLBlocks (Part 1 and Part 2)
Building
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.