1

I’m trying to integrate linphone-sdk-Mac from https://download.linphone.org/releases/macosx/sdk/ to my objective c app. Basically what I’m doing is extracting zip file and import framework files to my project and then change all frameworks to “embed and sign” and then compile. Program runs fine until I try to create the core, even using “ linphone_factory_create_core_with_config_3” or “ linphone_factory_create_core_3”, they all crash with the same error, that is “could not load grammar vcard_grammar because the file could not be located”. Already tried to put grammar files in several places of the project, on different versions, including last one, but with no luck. Anyone know anyway to solve this?

Sample code:

LinphoneFactory *factory = linphone_factory_get();

NSString *linphonecfg = [LinphoneManager bundleFile:@"linphonerc"];
NSString *fileStr = [NSString stringWithContentsOfFile:linphonecfg encoding:NSUTF8StringEncoding error:nil];

configDb = linphone_config_new_from_buffer(fileStr.UTF8String);
theLinphoneCore = linphone_factory_create_core_with_config_3(factory, configDb, NULL);

Already tried to compile linphone-desktop but that is failing in random places every time I try to compile it, so could not solve that way.

Thanks

  • Hey did you end up figuring this out? I've been stuck here for a sec, seems like the belcard framework is having issues loading it. – omar Dec 10 '21 at 16:08
  • I only was able to get it work on iOS, on OSX I just end up using a project from GItHub. I assume the only way is to get it compile through the source code and remove that verification or adding the file on the compilation. – Luís Campos Dec 11 '21 at 20:02
  • Ah I figured I'd have to re-compile for and remove the vCard option from the SDK, thanks a lot! Do you also happen to have a link to that project? – omar Dec 12 '21 at 15:21
  • Nice to know. I used the project: https://github.com/64characters/Telephone. If you can please answer the solution on this question, so others can see how to solve this if they run with the same issue. Cheers. – Luís Campos Dec 14 '21 at 09:59
  • Heyoh, I've added the solution that worked for me, let me know how it ends up for you! – omar Dec 14 '21 at 20:17
  • Worked great. Thanks alot – Luís Campos Dec 15 '21 at 21:04

1 Answers1

1

So after a lot of tinkering with the SDK, I've figured out to fix the vCard issue and compile properly without it on macOS with Swift/Objective-C (for arm64 and x86_x64).

Compiling SDK

  1. Install the following dependencies with homebrew:

    brew install pkg-config cmake doxygen nasm yasm
    
  2. Install pip3/python3 (if you haven't already) and it's dependencies:

    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    python3 get-pip.py
    pip3 install pystache
    pip3 install six
    
  3. Clone the latest Linphone SDK and it's dependencies recursively

    git clone --recursive https://gitlab.linphone.org/BC/public/linphone-sdk
    
  4. Make and set the build directory (-DENABLE_VCARD=OFF is the key here):

    mkdir build && cd build
    cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_VCARD=OFF ..
    cmake --build .
    

Xcode Integration

(if the build succeeded, hopefully)

  1. In your build folder, go into your linphone-sdk/desktop folder
  2. You should see a couple of different folder but the most important ones are Frameworks and share
  3. Add the Frameworks and share folder into your Xcode project with the following options checked: xcode_copy_options
  1. If you're using Swift, you will need to create a Objective-C bridging header with the following lines to avoid a giant list of errors in your LinphoneWrapper.swift in the share/linphonesw folder:
#import "linphone/factory.h"
#import "linphone/types.h"

#import "linphone/core.h"
#import "linphone/call.h"
#import "linphone/tunnel.h"
#import "linphone/wrapper_utils.h"
#import "linphone/core_utils.h"
#import "linphone/vcard.h"

#import "belle-sip/object.h"
#import "bctoolbox/list.h"
#import "mediastreamer2/msfactory.h"
  1. In the Frameworks, Libraries, and Embedded Content section of your apps target, every framework should be "Embed & Sign".

  2. Try compiling and accessing Core, Factory, etc... in a Swift file and it should work, if it doesn't, comment below and I'll try to help you out!

omar
  • 96
  • 1
  • 9