Swarm (Mac OS X)
Swarm is a software package for multi-agent simulation of complex systems, originally developed at the Santa Fe Institute. Swarm is intended to be a useful tool for researchers in the study of agent based models.
Swarm software comprises a set of code libraries which enable simulations of agent based models to be written in the Objective-C or Java computer languages. These libraries will work on a very wide range of computer platforms.
The basic architecture of Swarm is the simulation of collections of concurrently interacting agents: with this architecture, we can implement a large variety of agent based models.
The Swarm software is available to the general public under GNU licensing terms. Swarm is experimental software, which means that it is complete enough to be useful but will always be under development.
Getting Started
This document is an aid for setting up Swarm on Mac OS X 10.6 (Snow Leopard), using the swarm source from subversion trunk. At the time of this writing, the subversion revision is at r7896.
To get started, lets set a few environment variables that we will refer back to throughtout this document...
% setenv FRAMEWORKS ${HOME}/Library/Frameworks
% setenv STAGING ${HOME}/devel
% setenv TRUNK Swarm
% setenv XCODE_TEMPLATES "/Library/Application Support/Developer/Shared/Xcode/Project Templates/Applications"
The Framework
Get the Source from Subversion
% cd ${STAGING}
% svn co svn+ssh://nima@svn.savannah.nongnu.org/swarm/trunk ${TRUNK}
If you happen to open Xcode now, you'd notice that quite a few files are missing, for example...
version.h
swarmconfig.h
SwarmEnvironment_getters.[hm]
externvar.h
{collections,defobj,activity}_types.h
{collections,defobj,activity}_classes.h
...as indicated by the filename being rendered in red in Xcode. This is because these file must first be generated.
Note that you have to do these in the source before you can compile in Xcode...
% cd ${STAGING}/${TRUNK}/swarm
% test ! -f Makefile || make distclean
% ./autogen.sh
% ./configure --enable-openstep --without-jdkdir
To make this easier, you may wish to create a new top-level Makefile...
PROJECT := Swarm SDK := macosx10.6 BASE := swarm/macosx/SwarmOSX OS := $(shell uname -s) PRODUCT := ${HOME}/Library/Frameworks/Swarm.framework all: build; ################################################################################ build: .${OS}_build .Darwin_build: cd swarm && ./autogen.sh cd swarm && ./configure --enable-openstep --without-jdkdir cd ${BASE} && xcodebuild \ -configuration Release \ -sdk ${SDK} \ -parallelizeTargets \ -project ${PROJECT}.xcodeproj \ -alltargets cd ${BASE} && xcodebuild \ -configuration Debug \ -sdk ${SDK} \ -parallelizeTargets \ -project ${PROJECT}.xcodeproj \ -alltargets touch $@ install: .${OS}_build .${OS}_install .Darwin_install: ${PRODUCT} ${PRODUCT}: test ! -d $@ || rm -rf $@ cp -R ${BASE}/build/Release/${@F} ${PRODUCT} x: ${OS}_x Darwin_x: open ${BASE}/${PROJECT}.xcodeproj info: ${OS}_info Darwin_info: xcodebuild -showsdks clean: ${OS}_clean Darwin_clean: cd ${BASE} && xcodebuild \ -configuration Debug \ -alltargets \ clean cd ${BASE} && xcodebuild \ -configuration Release \ -alltargets \ clean @ test ! -f swarm/Makefile || $(MAKE) -C swarm distclean -find . -depth -name 'build' -exec rm -rf {} \; -find swarm -depth -name '*.cache' -exec rm -rf {} \; -find swarm -name '*.xm' -exec rm -f {} \; -find swarm -name '*.elc' -exec rm -f {} \; -find swarm -name 'aclocal.m4' -exec rm -f {} \; -find swarm/tests -name '*.in' -exec rm -f {} \; -find swarm/src -name 'Makefile.in' -exec rm -f {} \; -find swarm/tools -name 'Makefile.in' -exec rm -f {} \; -find swarm/libobjc/ -name 'Makefile.in' -exec rm -f {} \; -rm -f swarm/{,m4/}Makefile.in -rm -f swarm/{etc,COM,java}/Makefile.in -rm -f swarm/src/activity/activity_* -rm -f swarm/src/collections/collections_* -rm -f swarm/src/SwarmEnvironment_getters.* -rm -f swarm/src/defobj/modulemap{,.c} -rm -f swarm/{swarmconfig.h.in,configure} -rm -f swarm/{libobjc,avcall}/configure -rm -f swarm/libobjc/config.h.in @ -rmdir ${BASE}/build/{${PROJECT}.build/,}Release -rmdir ${BASE}/build/{${PROJECT}.build/,}Debug -rmdir ${BASE}/build/${PROJECT}.build -rmdir ${BASE}/build @ svn update -rm -f .${OS}_* ################################################################################ .PHONY: all clean info ${OS}_build ${OS}_install ${OS}_clean ${OS}_info ${OS}_x
Build
Next, launch Xcode...
% open ${STAGING}/${TRUNK}/swarm/macosx/SwarmOSX/Swarm.xcodeproj
...set the build to 10.6|Release and build the framework.
Drop it into Place
Once the framework is build, you should find it in the release build area, copy it into your designated frameworks area as follows...
% mkdir -p ${FRAMEWORKS}
% cp -R ${STAGING}/${TRUNK}/swarm/macosx/SwarmOSX/build/Release/Swarm.framework !$
The framework is now in place, and ready to use.
The Xcode Swarm Template
% sudo mkdir -p "${XCODE_TEMPLATES}"
% cd ${STAGING}/${TRUNK}
% sudo cp -R swarm/etc/XcodeTemplate "${XCODE_TEMPLATES}"
The Applications
Let's start by making sure the POC application Heatbugs works.
Heatbugs

Launch Xcode again by opening the Hearbugs project...
% open ${STAGING}/${TRUNK}/apps/openstep/Heatbugs/Heatbugs.xcodeproj
Now set the following frameworks to the path specific to your environment...
Finally, I had to add two options to my build settings as follows...

...namely, I had to add Framework Search Paths (Use ${HOME}/Library/Frameworks and let Xcode expand it, don't hard-code it as the actual path to your home directory), and Other C Flags. Note that as of r7897, you no longer need to worry about the -DSWARM_OSX.

