Begin main content

Load Interface Inspector's framework without modifying your Xcode project

Along the lines of Oliver Jones'€™ great tip about loading Reveal App'€™s* library into your iOS app without restarting the app or modifying your Xcode project, loading Interface Inspector'€™s** library into your Mac app at runtime is even easier thanks to Framework Bundles***. Simply add this into your .lldbinit:

command alias interface_inspector p (BOOL)[[NSBundle bundleWithPath:@"/Applications/Interface Inspector.app/Contents/Resources/InterfaceInspectorRemote.framework"] load]

and now at your lldb prompt just type "€œinterface_inspector" (or some unique part of that followed by tab) and then continue and you'€™ll be up and running.

* If you'€™ve been living in a cave you may not know about Reveal - the best thing for iOS developers since iOS 2.0.

** Interface Inspector is like Reveal for Mac apps (except not as good of course! No complaints about Interface Inspector, but you have to back your friends ;)

*** If you're thinking "€œwhy can't it be this easy on iOS?" - read Landon Fuller's excellent post: iOS Static Libraries Are, Like, Really Bad, And Stuff (Radar 15800975) and dupe his radar :)

05:30 AM, 20 Jan 2014 by Mark Aufflick Permalink | Comments (2)

GNUstep bleeding edge

For a client project I'm looking into Mac/Linux GUI cross platform options. Naturally GNUstep is high on my list. It's been a while (maybe 10 years) since I even played with GNUstep and I've struggled a bit getting all the latest things to compile together. So, like everyone else, I'm putting together a guide for how I did it since none of the other guides seem to be up to date (and I'm sure mine will be out of date shortly too!)

I'm installing on Ubuntu 12.04, but other Linux platforms will be very similar - just the dependencies might be different.

So firstly about those package dependencies. I've done so many apt-get installs that I've lost track exactly what I needed. Something a bit like this:

sudo aptitude install build-essential git subversion ninja cmake libffi-dev libxml2-dev libgnutls-dev libicu-dev libblocksruntime-dev libkqueue-dev libpthread-workqueue-dev autoconf libtool

Make sure you've uninstalled any older clang or libobjc libraries (otherwise you'll need to be very careful with configure args etc. to specify our compiled versions) and also any older version of libdispatch

Firstly we want the trunk version of llvm/clang. Grit your teeth, because we're going to have to use subversion:

cd
mkdir -p src/gnustep
cd src/gnustep
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd ..
mkdir build
cd build
cmake ..
make -j4

Now add the following to your .bashrc etc:

export PATH=$PATH:~/src/gnustep/llvm/build/bin
export CC=clang
export CXX=clang++

Now reload your bashrc:

. ~/.bashrc

Check you can find clang:

which clang
clang -v
clang++ 0v

Now we want the latest gnustep libobjc2 with all the latest modern runtime goodies:

cd ~/src/gnustep
git clone https://github.com/gnustep/gnustep-libobjc2.git
cd gnustep-libobjc2
mkdir build
cd build
cmake ..
make -j4
sudo -E make install

Now add the following to your .bashrc:

export OBJCFLAGS="-fblocks -fobjc-runtime=gnustep"

cd ~/src/gnustep
git clone https://github.com/gnustep/gnustep-make.git
cd gnustep-make
./configure --enable-debug-by-default --with-layout=gnustep --enable-objc-nonfragile-abi
make
sudo -E make install

Now add the following to your .bashrc:

. /usr/GNUstep/System/Library/Makefiles/GNUstep.sh
. ~/.bashrc

Now we can start installing gnustep itself:

cd ~/src/gnustep
git clone https://github.com/gnustep/gnustep-base.git
cd gnustep-base
./configure
make -j4
sudo -E make install

If you get warnings about blocks during make, check that you don't have old libobjc libraries on your system. You can specify a particular libobjc library version when you build the gnustep-make package, but easier to just uninstall them.

Now lets run some tests.

make check

The gnustep-base check tests are very handy for making sure you have all the latest things. Warnings you should look out for are things like you haven't enabled blocks or subscripting. If you get warnings like that you should check your OBJCFLAGS etc. At this point I get no failures or skips:

7913 Passed tests 21 Dashed hopes

All OK!

Now we want the latest lib dispatch for all our GCD goodness:

cd ~/src/gnustep git clone git://github.com/nickhutchinson/libdispatch.git
cd libdispatch
sh autogen.sh
./configure CFLAGS="-I/usr/include/kqueue" LDFLAGS="-lkqueue -lpthread_workqueue -pthread -lm"
make clean make -j4
sudo -E make install sudo ldconfig

Now we can compile some test code from this post (http://lists.gnu.org/archive/html/discuss-gnustep/2012-12/msg00036.html) which I have pasted into a gist: https://gist.github.com/aufflick/5674798

clang `gnustep-config --objc-flags` `gnustep-config --objc-libs` -lobjc blocktest.m
./a.out

clang `gnustep-config --objc-flags` `gnustep-config --objc-libs` -lobjc -ldispatch -lgnustep-base Fraction.m helloGCD_objc.m
./a.out

And there we are! Ready to install the other gnustep-* modules from github.

08:10 PM, 29 May 2013 by Mark Aufflick Permalink | Comments (32)

AQXMLParser + OAuth

I've been enjoying using Jim Dovey's excellent AQXMLParser lately, and in fact am giving a talk on it tonight at Sydney CocoaHeads. To use it in a new project, I need to be able to authorise the outbound REST request with some OAuth 1 tokens etc.

OAuth can be a right pain, and the Cocoa implementations aren't awesome. gtm-oauth (the OAuth 1 library from the Google Toolbox for Mac) is a little odd in its implementation, but doing your own OAuth implementation would be so tedious it's one of the better options out there.

It's all pretty easy. Firstly, use gtm-oauth like normal to have your user authorise your app and receive a token.

Next, to make a request, gtm-oauth provides a way to authorise an NSMutableURLRequest, but AQXMLParser uses it's own HTTPMessage class (which wraps the lower level CFHTTPMessage from Core Foundation).

What I have done is extend HTTPMessage to provide a copy of itself as an NSURLRequest, and then write a category that auths that with gtm-oauth and then cribs the headers from that and applies them to the HTTPMessage. It's a little roundabout, but because of the need to sign the whole request and the way that gtm-oauth internals work, anything else would be very complicated. So in use, it looks like this:

#import "HTTPMessage+GTMOAuth.h"

...

GTMOAuthAuthentication * oauth = ...; // setup gtm-oauth like normal

HTTPMessage * myMessage = ...; // create the http request like normal

[myMessage authorizeWithGTMOAuth:oauth];

// now create the parser and use the http message etc. like normal

For now the changes and category are only in my fork, but I have a pending pull request with Jim that I will work out the best way to incorporate them into his master repository. My fork also contains tweaks to work with the latest llvm and ARC (although note neither gtm-oauth nor HTTPMessage or AQXMLParser use ARC, so you'll have to add the -fno-objc-arc compiler flag where appropriate).

gtm-outh: http://code.google.com/p/gtm-oauth/

My fork of aqtoolkit: https://github.com/aufflick/aqtoolkit

02:25 AM, 02 Aug 2012 by Mark Aufflick Permalink | Comments (32)

XML

Loading

www.flickr.com