System info .
Xcode : 4.3.3
OSX : 10.7.4
I have downloaded phonegap 2.1( incubator-cordova-ios). I have successfully created the project using command line code as mentioned in the docs .
$ ./path/to/cordova-ios/bin/create /path/to/my_new_cordova_project com.example.cordova_project_name CordovaProjectName
I used code like below to build my project.
$ /path/to/my_new_cordova_project/cordova/debug
When i try to debug, i get error following error
/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m:252:14: error: use of undeclared identifier ‘ABAddressBookCreateWithOptions’ [3]
if (&ABAddressBookCreateWithOptions != NULL) {
^
/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m:253:24: warning: implicit declaration of function ‘ABAddressBookCreateWithOptions’ is invalid in C99 [-Wimplicit-function-declaration,3]
addrBook = ABAddressBookCreateWithOptions(NULL, NULL);
^
/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m:253:22:{253:24-253:66}: warning: incompatible integer to pointer conversion assigning to ‘ABAddressBookRef’ (aka ‘const void *’) from ‘int’ [3]
addrBook = ABAddressBookCreateWithOptions(NULL, NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m:326:96:{326:96-326:139}{326:109-326:139}: error: cast of Objective-C pointer type ‘id’ to C pointer type ‘ABRecordRef’ (aka ‘const void ‘) requires a bridged cast [4]
CDVContact xferContact = [[CDVContact alloc] initFromABRecord:(ABRecordRef)[foundRecords objectAtIndex:k]];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m:326:97: note: use __bridge to convert directly (no change in ownership) [4]
CDVContact* xferContact = [[CDVContact alloc] initFromABRecord:(ABRecordRef)[foundRecords objectAtIndex:k]];
^
_bridge
fix-it:”/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m”:{326:97-326:97}:”_bridge ”
/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m:326:97: note: use __bridge_retained to make an ARC object available as a +1 ‘ABRecordRef’ (aka ‘const void ‘) [4]
CDVContact xferContact = [[CDVContact alloc] initFromABRecord:(ABRecordRef)[foundRecords objectAtIndex:k]];
^
__bridge_retained
fix-it:”/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m”:{326:97-326:97}:”__bridge_retained ”
/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m:338:92:{338:92-338:135}{338:105-338:135}: error: cast of Objective-C pointer type ‘id’ to C pointer type ‘ABRecordRef’ (aka ‘const void ‘) requires a bridged cast [4]
CDVContact testContact = [[CDVContact alloc] initFromABRecord:(ABRecordRef)[foundRecords objectAtIndex:j]];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m:338:93: note: use __bridge to convert directly (no change in ownership) [4]
CDVContact* testContact = [[CDVContact alloc] initFromABRecord:(ABRecordRef)[foundRecords objectAtIndex:j]];
^
_bridge
fix-it:”/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m”:{338:93-338:93}:”_bridge ”
/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m:338:93: note: use __bridge_retained to make an ARC object available as a +1 ‘ABRecordRef’ (aka ‘const void ‘) [4]
CDVContact testContact = [[CDVContact alloc] initFromABRecord:(ABRecordRef)[foundRecords objectAtIndex:j]];
^
__bridge_retained
fix-it:”/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m”:{338:93-338:93}:”__bridge_retained ”
/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m:560:21:{560:23-560:67}: warning: incompatible integer to pointer conversion assigning to ‘ABAddressBookRef’ (aka ‘const void *’) from ‘int’ [3]
addressBook = ABAddressBookCreateWithOptions(NULL, &error);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/virtusa3/pgt/myproject1/CordovaLib/Classes/CDVContacts.m:562:9: warning: implicit declaration of function ‘ABAddressBookRequestAccessWithCompletion’ is invalid in C99 [-Wimplicit-function-declaration,3]
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
^
4 warnings and 3 errors generated.
Seems to be related to this issue reported by others building on Snow Leopard with older versions of Xcode:
Running ./cordova/debug / cordova/emulate causes errors”
It seems that there are plans to fix it but updating to Mountain Lion and Xcode 4.51 will fix it. It did for me.