Posted by: Tharindu | June 18, 2010

How to compile Siphon for Non-Jail Broken iPhone-Make VoIP calls on WiFi

I was needed to somehow add VoIP into my Level4 Project. It made me search all over Google for some existing work. And found this project Siphon that enables SIP voice calls. There are few guides on Siphon Wiki, still I was stuck with linking issues for nearly a month. After trying lots of hours I gave up all that trying to compile for iPhone 3.0. Again yesterday, I have been trying to compile free open source project Siphon to run on iPhone Simulator and iPhone all day. It was really difficult task having the Siphon team done lots of effort on making an Open Source project, still just to compile it. My lack of knowledge in C++ or C made this even harder. Finally lots of hours invested, days wasted now I have it running on my iPhone. So may be this will help some newbie on low level coding (C, C++) other than Objective-C to run this amazing app compiled on your iPod or iPhone. Having credits on your SIP account you may convert your iPod into an iPhone on WiFi.

Siphon Project on Google Code

Siphon has wiki pages saying how it could compile to iPhone OS 2.x but still it seems to be not enough and I couldn’t make it success by any means unfortunately.

Steps to follow for Newbie.

1. We need to compile and build required libraries from compiling PJSIP project first. There are few things I did wrong here. I have compiled for Device and tried to run it on Simulator without writing my own configure script. Trying to use same one on PJSIP Then I got so many linking issues that I couldn’t understand WTF is this.

2. Let’s compile PJSIP for iPhone first and build libraries required and then to Simulator as well with a more change to configure script. Before going into Siphon project.

2-1. Download PJSIP source code from here. Now it includes configure script for iPhone that you need to edit once for iPhone again for Simulator.

svn co http://svn.pjsip.org/repos/pjproject/trunk pjproject

2-2. Create a new file pjlib/include/pj/config_site.h.  Add following code into it.

#define PJ_CONFIG_IPHONE 1
#include <pj/config_site_sample.h>

2-3. If you go to pjproject folder, you will see configure-iphone script. Need to edit this to compile for your desired iPhone SDK. Open this with your favorite Text editor, mine was TextWrangler.

$ edit configure-iphone

2-4. Hard code the $DEVPATH and $IPHONESDK. So you don’t need to export those environment variables. If you not specify $IPHONESDK it will be the OS default. ex.

DEVPATH=/Developer/Platforms/iPhoneOS.platform/Developer
IPHONESDK=iPhoneOS3.0.sdk

2-5. Now you can easily build the libraries that will be stored in lib directories of folders, pjlib, pjlib-util, pjmedia, pjnath, pjsip, third_party. Check once again about your configure-iphone script for correct paths and compile and build libraries using following commands simply.

$ cd /path/to/your/pjproject/dir
$ ./configure-iphone
$ make dep && make clean && make

2-6. Now you have libraries for iPhone. Make a copy of pjproject folder and rename it to pjproject_sim. Here we are going to have our iPhone Simulator libraries built

$ cd /path/to/your/pjproject_sim/dir
$ edit configure-iphone

2-7. Hard code the $DEVPATH and $IPHONESDK. This time they should the paths for Simulator SDKs. And one more change here, that I was missing. caused all sorts of problems.

2-8. Search for 'ls -d ${SDKPATH}/usr/lib/gcc/arm-apple-darwin*' in configure script and replace it with following that way you could build correct libraries for simulator.

ls -d ${SDKPATH}/usr/lib/gcc/i686-apple-darwin*

2-9. Great now you have all libraries needed in folders, pjproject and pjproject_sim.

3. Now let’s go and checkout siphon project.

svn checkout http://siphon.googlecode.com/svn/trunk/ siphon

4. There was a compilation issue in Siphon code, that you could ignore by doing a little trick, I don’t know whether its right or wrong. But it works perfect. Otherwise, project didn’t compile for me. Open Siphon2 folder iPhone project on iPhone then go to call.m. Search for PJSIP_CRED_DATA_MJ_DIGEST and replace it with PJSIP_CRED_DATA_DIGEST.

5. Now add all the library .a files in following folders to the project. pjlib, pjlib-util, pjmedia, pjnath, pjsip, third_party.

6. Now follow the screen shots carefully. If you build for simulator use simulator library files (pjproject_sim folder) and include files to library and header search paths, other wise use libraries & include files in pjproject folder.

Make a duplicate of Debug to run in iPhone, let debug to be used by used by simulator libraries.

Let’s add Library Search Paths & Header Search Paths for siphon target. Following are examples of my locations for simulator. For device its the location to pjproject folder we built and stored our library files for Device.

Change CYDIA=0 in Preprocessor Macros

7. Add the Settings Bundle for your project as given in this following link. It works perfect then.

Siphon and Settings Bundles

8. Now you could run it on your iPhone or Simulator. Use a free SIP service to create SIP accounts to test the app. I have used, Sip2Sip

NOTES ABOUT COMPILING “PJSIP”

Following link contains very useful information updated about how to get PJSIP compiled for iOS. Please refer to the pjproject Wiki page below.

Building for Apple iPhone, iPad and iPod Touch

* IMPORTANT: I had to follow additional step to get things done for iOS Simulator. before run ./configure-iphone script

export DEVPATH=/Developer/Platforms/iPhoneSimulator.platform/Developer
export CC=$DEVPATH/usr/bin/gcc
export CFLAGS="-O2 -m32 -miphoneos-version-min=3.0" LDFLAGS="-O2 -m32"

Responses

  1. Great Tharindu !! You have done great thinking others should not suffer in building it.

    Like

  2. wow thats great project, we can have cheap international calling on iPhone apps from VoIP.

    Like

  3. WOW i like this blog and hope it’s works with me wait my feed back 🙂

    Like

  4. Great looking post, Tharindu! I’ve started to venture along the same lines and got stumped while building the pjsip project using the instructions in Siphone’s WIKI. Their instructions seem quite old.

    I’ll try to follow your how-to and see if that helps.

    Like

  5. Please help me. When I build the project, there are a lot of mistakes occurred!

    Warning:3 & error:18

    that is “error:AddressBookUI/ABFavoritesEntry.h:No such file or directiory”

    Please tell me the reasons, Thanks!

    Like

    • You may delete "FavoritesController.h" from Siphon Project and its entry from "SiphonApplication.h".

      This uses few Private APIs that doesn’t come with standard SDK.

      Like

      • Hello Tharindu, I’m glad you can reply me!

        First, I did not make any changes to Siphon Project, except I do according to this article.

        And I can’t find “FavoritesController.h” but “FavoritesListController.h”, is the file you mean?

        Here is my project source code:
        https://www.sugarsync.com/pf/D124661_79_20865547

        Like

  6. Hi, Tharindu.
    I have solved the problem by another way.
    Thank you in advance for your help!

    Like

  7. Hi, Thraindu, tks for your awsome help building this tutorial!
    I want to use the G729 codec, at Siphon project they send a g729 project taht needs to be compiled in a lib, i use the XCode to compile and its build successfully, but nothing is add at /build folder…. How can i compile that?

    Tks!!

    Like

  8. Tks, i already try it… the problem is when i try to build… it build with no errors, but dosent creat the libg729a.a file at build folder… and nowhere else…
    It works with disable g729 option but, g711 is to heavy, consumes to much kbps… g729 is far a better codec at all.

    Tks

    Like

  9. Hi Tharindu, im trying to make a simulator version with of pjsip iphone SDK 4.3, i change the gcc for i686 but it give a error when a make it, can you help me? the error is

    ../src/pj/activesock.c
    ../src/pj/activesock.c: In function ‘activesock_create_iphone_os_stream’:
    ../src/pj/activesock.c:146: error: ‘kCFStreamNetworkServiceType’ is unavailable (declared at /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/CFNetwork.framework/Headers/CFSocketStream.h:256)
    ../src/pj/activesock.c:147: error: ‘kCFStreamNetworkServiceTypeVoIP’ is unavailable (declared at /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/CFNetwork.framework/Headers/CFSocketStream.h:259)
    make[2]: *** [output/pjlib-arm-apple-darwin9/activesock.o] Error 1
    make[1]: *** [pjlib] Error 2
    make: *** [all] Error 1

    Tks

    Like

    • Damilo, for SDK4.3 skip step 2-8 & 2-9.

      Like

  10. Hi,
    http://svn.pjsip.org/repos/pjproject/trunk pjproject
    above link is working now? When i go through the above link it return The requested URL /repos/pjproject/trunk pjproject was not found on this server.

    Like

  11. Thanks,
    Providing me such wonderful information.

    Like

  12. Hi,

    I am newbie to SIPHON. Some problems has been solved after following ur post. But i still can’t compile it. There are many warnings and errors.
    – AddressBookUI/ABFavoritesEntry.h:No such file or directiory (i have solved this error by removing the favorite feature of the SIPHON but i still need other solutions)
    – Undefined symbols for architecture armv7:
    “_pjsua_call_get_count”, referenced from:
    -[SiphonApplication processCallState:] in SiphonApplication.o
    -[SiphonApplication callDisconnecting] in SiphonApplication.o
    -[CallViewController processCall:] in CallViewController.o
    “_pjmedia_tonegen_play_digits”, referenced from:
    _sip_call_play_digits in dtmf.o
    “_pjsua_acc_get_info”, referenced from:
    _on_reg_state in call.o
    “_pjsua_perror”, referenced from:
    _sip_connect in call.o
    _sip_dial_with_uri in call.o
    _call_init_tonegen in dtmf.o

    and much more 😦

    How should we fix it?
    Thanks,

    Like

  13. Thank you for your reply.
    I have followed that link and now i can build and run the ipjsua.xcodeproj with my device. But i still have problems with “Siphon”. I really would like your help. Could u guide me step by step to configure the siphon?

    Thanks you in advance.

    Like

  14. Thank you for this post its really helpful, i can compile sophon, now in sophon settings i have 3 sections:
    1- 1 cell : add account
    2- 3 cells : media, network and phone.
    3- just the version number.

    But if i select one of them, i have an empty view, have you copy the settings files ? i try this (i know is in sophon4 not 2), still not work :
    http://code.google.com/p/siphon/source/browse/trunk/Siphon4/Resources/Settings/Settings.bundle/?r=682

    Like

    • Please read following link. Read info for non-jailbroken iphone.

      Anyway, if you are interested to use Siphon in a non-jailbroken enviroment, I think the simple way is using Settings.bundles method (if you can giveup ipod-iphone conf). Just becouse the migration is very simple but very boring, I’ll attach here the plist files you need.
      For migration, open Siphone project and create a new file (“Resource” -> “Settings bundle”). This will create a Root.plist file in your Settings.bundle dir.
      Then, those are the plist files you needs:
      File:SiphonSettingsBundles.zip
      Simply, extract in your Siphon2 project dir, then add in Resource (using existing file), finally use the terminal to copy those files in Settings.bundle directory.
      Clear, recompile and all will work well.
      I hope this infos will be usefull.

      Like

      • thank you verry much!!
        i copy files but with the finder not using xcode so files are not in ressource liste.

        Like

  15. Hi Tharindu,

    Thank you so much for your guidance, it really helped me. But there are some issues that i faced with and it took me so much time and still couldn’t fix them, i am very stuck with it …. The issues are following
    /Users/hasanabdullaev/Desktop/trunk/pjlib/include/pj/assert.h:28:10: ‘pj/config.h’ file not found
    /Users/hasanabdullaev/Desktop/trunk/pjlib/src/pj/compat/setjmp_i386.S:23:10: ‘pj/compat/setjmp.h’ file not found
    files are in the directory which is specified here and i can’t understand the real issue here. Could you please help to figure it out or if you have full compiled version of Siphon i’d very appreciate if you send it to me, thanks in advance.

    Like

    • Hi,

      It seems like either config_site.h or config.h files moved or removed in the pj/ directory.

      pjlib/include/pj/
      ..
      config_site_sample.h
      config_site.h
      config.h
      ..

      Checkout the latest code from pjproject svn as well.

      Like

  16. Tharindu i double checked the files and i think all the files exist in the directory where they suppose to be, i also repeated all the trick over again but still without success the issue is still the same…

    /Users/hasanabdullaev/Desktop/trunk/pjlib/src/pj/compat/longjmp_i386.S:23:10: ‘pj/compat/setjmp.h’ file not found
    /Users/hasanabdullaev/Desktop/trunk/pjlib/include/pj/assert.h:28:10: ‘pj/config.h’ file not found
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:9:9: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:9:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:8:9: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:8:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:10: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:13:10: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:13:

    if you want i can send you the source code for review… and if you have a full compiled version of Siphon for iOS7..sdk (iphone5 device) i would really appreciate if you share it with me.. Thanks in advance!

    Like


Leave a comment

Categories