Archive for the ‘Mac’ Category

Settings.bundle doesn’t appear in iPhone Settings

Friday, July 2nd, 2010

Hi,

We were working on an iPhone app recently and added a Settings.bundle to allow the user to set their preferences as described here and here.  However whenever we ran the app either on the device or on the simulator the settings simply would not appear in the iPhone’s settings.

After much digging around and many hours banging heads on walls we finally tracked it down.  Settings bundles are only added to the phone the first time the application is installed. If you’ve worked on an application and deployed it to your development device or simulator before adding the settings.bundle to your XCode project then subsequent build and runs won’t add the settings unless you remove the app from the device or simulator in the usual way. i.e by pressing and holding the app icon and removing it when it starts shaking.

The next time you deploy to the device or simulator the settings should be present.

We hope this helps someone.

Solution to crackling and breaking up conversation on iPhone

Tuesday, October 27th, 2009

Hi,

Yesterday one of our iPhones developed an intermittent fault with the call quality.  Often we could hear the other party but they couldn’t hear us, or vice versa.  It didn’t seem to matter who initiated the call or wether it was a mobile to landline call or mobile to mobile.

iPhone

iPhone 3G

We took the following diagnostic steps to try and track down the problem :

1) Made a sound recording with the Voice Memos app and played it back to confirm speaker / mic working.

2) Powered off and on again

3) Reset (pressed Home and Power button simultaneously for 10 seconds)

4) Did a Restore through iTunes.

All to no effect.  A quick call to O2 resulted in a couple more things to try :

1) Remove SIM card and give it a good clean.  It was surprising how much pocket fluff was in there!

2) Try the SIM card in another phone.

With the second option above we actually found that the other phone (a Nokia) started exhibiting the same behaviour so the problem appeared to be with the SIM, not the iPhone (phew!).

A quick trip to the local O2 retail store for a SIM swap (done in the store with no temporary number or delay) and we’re back up and running again.

We hope this helps someone else.

UPDATE : the solution may not have been that simple as the problem resurfaced a few days later.  We’ve just done a complete factory reset and fingers-crossed we’ll be OK.  Just made a 6 minute call which was impossible this morning.

Missing (red) frameworks in iPhone XCode projects after upgrade

Monday, September 28th, 2009

Hi,

We just upgraded XCode to the latest release (3.1.4 as at time of writing) and noticed that after doing so a number of our iPhone projects now had their Frameworks all set to missing (i.e coloured in red) like this :

The problem

The solution wasn’t immediately obvious but just in case anyone else was wondering what was required to fix it here are the steps :

1) Open the settings for your project by right-clicking and choosing ‘Get Info’ :

2) This will display this page, which will display the root of the problem in the ‘Base SDK for all configuration’ drop down :

The problem is that the project was set to ‘iPhone Device 2.2′ which is no longer supplied with XCode.

3) To fix the problem simply change the Base SDK to whatever is appropriate for you, e.g :

and voila, the problem is solved :

Thanks for reading.

Removing £ signs from a file using sed

Tuesday, December 2nd, 2008

Hi

If you’ve ever tried to use ’sed’ to remove the UK pound sign (£) from a file you may have struggled.  We were bashing our head against the wall until we tried this little trick :

 sed -e 's/'`echo -e "\xA3"`'//g' input.txt > output.txt

Note the important difference between the single-quote and the ‘back-tick’ around the echo.

We had been trying to use the pound sign directly in the terminal window but it just wasn’t matching for some reason.  We then used a Hex Editor  to find the raw code that was being used to represent the pound sign in the file and used that instead and voila!, it works.

 

Building an OCCI project using XCode 3.1

Thursday, October 2nd, 2008

With the release of the Instant Client for Mac OS X you can now build OCCI based applications targetting modern Macs using Leopard on Intel.  However, there is very little help available for building these apps using XCode, and if you hit the same problem we did (see below) then perhaps this post may be helpful.

Firstly download the Instant Client.  You will need the ‘Basic’ and ‘SDK’ packages.  We have unzipped them into ‘/instantclient_10_2′ on the root of the hard disk.  The ‘SDK’ should unzip into a folder within this one. The OCCI headers (and others) should then be in this path : ‘/instantclient_10_2/sdk/include’.  You can of course change this to suit your needs but this is what the walkthrough below is based on.

Before getting ’stuck in’ though you will need to create a couple if ‘links’ so that GCC can link to the OCCI libraries.  You can do this using a ‘Run Script’ in the project but I find it easier just to do this as a ‘one off’ now.  

  $ ln /instantclient_10_2/libocci.dylib.10.1 /instantclient_10_2/libocci.dylib
  $ ln /instantclient_10_2/libclntsh.dylib.10.1 /instantclient_10_2/libclntsh.dylib

So let's get started!

Firstly, create a new 'C++ Tool' project using XCode :

and give it a name, in this case, ‘occi’ :

You will then have your project open in XCode :

Next, double click on the item under ‘Targets’, in this case ‘occi’ to bring up the Target Info window.  Switch to the ‘Build’ tab :

Change the following settings (note the ‘Search’ box in the top right to help you find the settings ):

Other Linker Flags : -locci -lclntsh

Header Search Paths : /instantclient_10_2/sdk/include

Library Search Paths : /instantclient_10_2

Next, open your ‘main.cpp’ file and try this sample code :

#include <iostream>

/* Oracle */
#include <occi.h>

/* namespaces */
using namespace std;
using namespace oracle::occi;

/* Globals */
Environment * env;
Connection * conn;
 
int main(int argc, char * argv)
{
  // Connect
  env = Environment::createEnvironment(Environment::OBJECT);
  conn = env->createConnection("scott", "tiger", "//lcoalhost:1521/xe");
  Statement *stmt = conn->createStatement("SELECT COUNT(*) FROM TAB");
  ResultSet *rs=stmt->executeQuery();
  rs->next();
  string ntabs=rs->getString(1);
  cout << "Number of tables " << ntabs << endl;  
  conn->terminateStatement(stmt);
  // Close connection etc
  env->terminateConnection(conn);
  Environment::terminateEnvironment(env);  
  return 0;
}

Don’t forget to change the connection details to the relevant values for your setup.

Next, navigate to the ‘Executables’ folder of your project and double click on ‘occi’ to bring up the Executable Info page.  Change to the ‘Arguments’ tab and add an environment variable for DYLD_LIBRARY_PATH :

Set the value to ‘/instantclient_10_2′.

You should then be able to ‘Build and Go’.   You may want to set a breakpoint or open the Console (’Run -> Console’ from the XCode menu) so you can see the results :

And that should be it!   However…..

If you do something a little more advanced, which in our case meant using ‘ott’ (supplied as part of the ‘SDK’ package for the Instant Client) and building OCCI code based on the Oracle Spatial type (SDO_GEOMETRY) then you will probably get this error at link time :

Undefined symbols:  "oracle::occi::setVector(oracle::occi::AnyData&, 
                    __gnu_debug_def::vector<oracle::occi::Number, 
                    std::allocator<oracle::occi::Number> > const&)", referenced from:
      _main in occi.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

After much digging the problem is with a couple of Preprocessor macros defined by default in XCode, _GLIBCXX_DEBUG=1 and _GLIBCXX_DEBUG_PEDANTIC=1.

Go into the ‘Build Settings’ for the target as described above, find the Preprocessor Macros entry and remove the two macro definitions.  Note that setting them to 0 does not seem to work.

You should then be good to go!  

Things we like about the Mac

Wednesday, September 17th, 2008

As you may have gleaned from other posts we do a lot of development using Macs, specifically MacBooks and iMacs.  We might develop products that run on Linux, Windows or Solaris but that doesn’t stop us using our Macs to actually do the work!  

So why Macs?  Well, we had a laptop in a while back with Vista on it and it was universally loathed.  Everything we tried to do on it, being ‘power users’, was either blocked, slow or just downright cumbersome.  Frequent lock ups and crashes just drove us mad.  As for waking from sleep, it was more like waking the dead!  We’d been tempted to ‘switch‘ for a while and having this laptop just made the decision for us.

Reasons we like the Mac include :

The Operating System, Mac OS X, ‘just works’ and doesn’t get in the way and slow things down.  An O/S, more than any other aspect of the computer, is a tool and we believe that you should hardly know that it is there as it seamlessly let’s you go about your job.  

Leopard

Useful features in the ‘Finder‘ (the Mac OS X equivalent to Windows Explorer) such as ‘Quick Look‘ and ‘Cover Flow’ really help us find the file we’re looking for, particularly office-type documents, without needing to open up the app itself.  From a personal perspective, I love the way I can create commonly used shortcuts in the sidebar that appear everywhere including Open and Save dialogs.  This is a real time saver when working on specific projects and needing frequent access to the folder.

Being developers of course the fact that Mac OS is built on Unix just rocks.  Has Windows got ‘head’ and ‘tail’ yet?!  That’s just laughable that if I have 2 gb text file I want to look at the last line of I need to open the whole thing in Windows.  Plus of course the full complement of tools including ‘vi’, ’sed’, ‘tr’ etc just make us so productive.

Time Machine is also a big boon.  We all know we should do more backups, in fact we frequently preach to friends and family about it, yet are probably the worst culprits!  Time Machine makes it so painless to not only backup, but restore as well.  All built in, and with plenty of USB drives out there for £50 a dirt cheap solution too.

Time Machine

Of course we’d be naive to think that we can leave Windows behind entirely, if only for testing and supporting clients.  Support for the ‘Windows World’ is good and the following add-ons make it a pleasure :

We do a lot of communicating using Skype.  Of course Skype exists for Mac, and I can even use my SkypePhone too!  (click here for the VoIP Driver I used).

We all spend quite a bit of time using ‘office’ products to create documents and spreadsheets. You can use Microsoft Office and get 100% (or near enough!) compatibility with your Windows colleagues but there are other choices.  iWork ‘08 is great (we particularly like Numbers) and it’s very affordable too.  There’s also NeoOffice, a Mac OS port of Open Office that also works well.  We use iWork and NeoOffice and haven’t found anything we can’t open yet.

We do a lot of work with Oracle and the Mac has pretty good support from Oracle too.  SQL Developer is a free download and works as well as it’s Windows cousin.  There’s also the Instant Client so we now have full access to ’sqlplus’ too.  Maybe we’ll even get a version of the database one day as well. ;-)

SQL Developer

Professional development tools such as Zend Studio meant we flawlessly transferred our PHP development effort across with zero downtime, and supporting Open Source products such as uDig and pgAdmin have meant our GIS and PostgreSQL work was uninterrupted also.

Also, from a physical point of view the MacBook is great.  It’s small, light and very well built.  The track-pad works really well and battery life is fantastic.  Doing standard tasks such as browsing, ssh, SQL access etc and it will last for about 5 hours.  The magnetic lid is a surprisingly pleasant change from fiddly catches, and plugging in an external monitor works flawlessly and gives you a a wonderful wide desktop; great for development!

Plus there’s some of the other ‘fun’ stuff such as Google Earth and Real Player too, so it really is a home from home.

And finally, of course, are the little touches that just make a Mac, well, a Mac!  Such things as right-clicking on a piece of text ad choosing ‘Search in Google’, the way Mail automatically picks out addresses and let’s me show them in Google Maps and all the great things in Mac OS such as iPhoto, iTunes and others.

So, if you’re thinking about the ’switch’, then don’t be afraid, go for it!  You’ll be glad you did.

 

 

 

 

 

Mac OS X TextEdit doesn’t display NULLs!

Tuesday, September 16th, 2008

We just had a real hair-puller of a problem so thought we’d blog about it here just in case someone else sees something similar.  We had been sent a text file (.sql) of SQL Server ‘CREATE TABLE’ statements that we were manually converting to Oracle syntax just using TextEdit (OK, I know there are better editors but it was a small job and TextEdit was fine).

Our first problems occurred trying to edit the file when it appeared like the Mac’s keyboard was broken.  We kept having to press the delete and cursor keys repeatedly to move around make the edits.  This seemed weird but we did the normal stuff like rebooting, updating to the latest OS X, swapping USB ports, checking the console etc but nothing looked amiss so kind of ‘lived with it’ as it wasn’t a big deal.

Then we decided to run the script via SQLDeveloper and immediately noticed that our file wasn’t syntax highlighted.  Weird?!   Trying various other editors (BBEdit, TextMate, TextPad on Windows) all showed the same problem – no syntax highlighting.  Then we noticed in TextMate that there were what appeared be spaces between every character.  Further examination using a hex editor showed that there was a NULL character (\0) in between every single character of the file!!

No wonder we had to press delete twice to do anything in TextEdit, and no wonder our syntax wasn’t highlighted!

The next problem was how to remove the NULLs which is not as easy as it sounds.  However a variation on the blog entry below using ‘tr’ saved the day and now it is all much as it should be :

$ tr -d '\0' < tables.sql > tables2.sql

Hope this helps someone! 

UPDATE : we have now switched to TextMate for all text editing.  We love the fact we can run Shell scripts and SQL scripts directly from the environment using ‘bundles’.  For those switching from TextPad on Windows, TextMate is a pretty good choice.

Converting tab delimited data to CSV data

Tuesday, July 29th, 2008

Here’s a little trick we discovered for converting tab delimited text to comma separated (CSV).  You’ll need access to a Unix, Linux or Mac OS X machine as it relies on the ‘tr’ command line not present on Windows. 

To convert the file simply :

$ tr '\t' ',' < file.tab > file.csv

where ‘file.tab’ is your tab-delimited file and ‘file.csv’ is the file to write to.

And you’re done!