Thursday, May 31, 2012

Apple Frustrations ...

I spent a good couple of hours tearing my hair out over a bug in my iPad app the other day.  The key problem was that I was getting a crash, without detailed error information.  I knew the line in my code that seemed to trigger the issue, a performSegueWithIdentifier call, but the error was an "attempt to insert nil object at 0 on an NSArray, which I wasn't calling.  It seemed like the details of the stack trace were obscured behing the performSegueWithIdentifier call.

I was extremely pleased when the following stack overflow post helped me add some code to the AppDelegate that got the strack trace symbolicated and printed out in the debug window

After that I could see that the problem was related to a NavigationItem in one of my controllers that I hadn't hooked up.  It was perhaps an understandable slip since as described in one of my previous posts I had to replicate one of my viewcontrollers to support a hierarchy browse since currently viewcontrollers can't segue to an instance of themselves - at least not using the storyboard.  So the problem was I had hooked up a navigation item in one controller, but not the replicant ...

I also just renewed by Apple iOS development program.  Interesting to discover that they will pull your apps if you don't renew, so I guess I am on the hook for years now.  Google's one of payment for android app publication seems increasingly good value by comparison.  What's particularly frustrating is that having accidentally upgraded my iPad and iPhone to 5.1 I can no longer deploy apps from Snow Leopard - I must now upgrade to Lion since Apple will not allow me to downgrade to 5.0 on my iOS devices, argh!

Monday, May 28, 2012

Python SVM on OSX 10.6.8

So I finally got some Python SVM love on OSX 10.6.8 by using the Python bindings for libsvm.  However that was after having spent half a day trying to build PyML and Scikit.  I had thought these "pure" python projects would be the simpler route to take.  I got stuck for a bit installing numpy and other supporting packages, but even having got these working I couldn't get PyML or Scikit to build.  The problem was errors like this:

compiling C++ sources
C compiler: c++ -fno-strict-aliasing -fno-common -dynamic -arch ppc -arch i386 -g -O2 -DNDEBUG -g -O3

compile options: '-I/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -c'
c++: sklearn/svm/src/libsvm/libsvm_template.cpp
llvm-g++-4.2: error trying to exec '/usr/bin/../llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-g++-4.2': execvp: No such file or directory
lipo: can't figure out the architecture type of: /var/tmp//ccpSkuud.out
llvm-g++-4.2: error trying to exec '/usr/bin/../llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-g++-4.2': execvp: No such file or directory
lipo: can't figure out the architecture type of: /var/tmp//ccpSkuud.out
error: Command "c++ -fno-strict-aliasing -fno-common -dynamic -arch ppc -arch i386 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -c sklearn/svm/src/libsvm/libsvm_template.cpp -o build/temp.macosx-10.3-fat-2.7/sklearn/svm/src/libsvm/libsvm_template.o" failed with exit status 255


building 'PyML/containers/ext/_csparsedataset' extension
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -arch ppc -arch i386 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c PyML/containers/ext/SparseDataSet_wrap.cpp -o build/temp.macosx-10.3-fat-2.7/PyML/containers/ext/SparseDataSet_wrap.o
In file included from /usr/include/architecture/i386/math.h:626,
                 from /usr/include/math.h:28,
                 from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyport.h:312,
                 from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:58,
                 from PyML/containers/ext/SparseDataSet_wrap.cpp:149:
/usr/include/AvailabilityMacros.h:108:14: warning: #warning Building for Intel with Mac OS X Deployment Target < 10.4 is invalid.
/usr/libexec/gcc/powerpc-apple-darwin10/4.0.1/as: assembler (/usr/bin/../libexec/as/ppc/as or /usr/bin/../local/libexec/as/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/as/x86_64/as for architecture x86_64
/usr/bin/../libexec/as/i386/as for architecture i386
/usr/bin/../libexec/as/arm/as for architecture arm
lipo: can't open input file: /var/tmp//ccyq6iNy.out (No such file or directory)
error: command 'gcc-4.0' failed with exit status 1

I did all the usual searches and played around with gcc settings and so forth, but generally to no joy.  I guess I should have posted the above with details to the relevant mailing lists, but having got libsvm to work I just focused on that.  I'll come back to this if libsvm hosting becomes an issue for an online deployment ...