Show last authors
1 (% class="row" %)
2 (((
3 (% class="col-xs-12 col-sm-8" %)
4 (((
5 = Getting started with our tutorials =
6
7 With the release of the linphone SDK 5.0, you will also find a set of [[Swift liblinphone tutorials for IOS>>https://gitlab.linphone.org/BC/public/tutorials/-/tree/master/ios]]. Use them to experiment with simple applications that covers the most common usages : call, chat, push notifications..
8
9 = Adding the liblinphone dependency to your iOS project =
10
11 Liblinphone for iOS is available using [[Cocoapods>>https://cocoapods.org]], the de-facto standard in the Apple developer world for "dependency management for Swift and Objective-C". Liblinphone can also be compiled from the sources.
12
13 Using Cocoapods
14
15 For a project named "Myproject"
16
17 open Myproject/, use commands:
18
19 {{code}}
20 pod init
21 {{/code}}
22
23 Modify the generated Podfile according to your project:
24
25 {{code}}
26 # Uncomment the next line to define a global platform for your project
27
28 ##For macosx
29 # platform :osx, '10.9'
30 #source "https://gitlab.linphone.org/BC/public/podspec-macos.git"
31
32 #For iOS
33 platform :ios, '9.0'
34 source "https://gitlab.linphone.org/BC/public/podspec.git"
35
36 target 'Myproject' do
37 use_frameworks!
38
39 # Pods for Myproject
40 pod 'linphone-sdk' , '5.0.50'
41 end
42
43 {{/code}}
44
45 To install or update the liblinphone version, do the following command
46
47 {{code}}
48 pod repo update
49 pod install
50 {{/code}}
51
52 == ==
53
54 And you're done.
55
56 Some alpha (development versions) of liblinphone may also be available. To get them, replace the line:
57
58 {{box}}
59 pod 'linphone-sdk' , '5.0.50'
60 {{/box}}
61
62 by
63
64 {{code}}
65 pod 'linphone-sdk', '> 5.1.0-alpha'
66 {{/code}}
67
68 followed by:
69
70 {{code}}
71 pod install
72 {{/code}}
73
74 == Compiling linphone-sdk ==
75
76 Linphone-sdk is the name of the git project that contains liblinphone and all its dependencies.
77
78 Compilation instructions of the SDK are available at: [[linphone-sdk/README.md>>https://gitlab.linphone.org/BC/public/linphone-sdk/blob/master/README.md]]
79
80 Once done, cocoapods needs to be invoked to update the Xcode workspace to use your locally built linphone-sdk, as follows:
81
82 {{code language="sh"}}
83 PODFILE_PATH=<path to linphone-sdk-ios> pod install
84 {{/code}}
85
86 {{{where <path to linphone-sdk-ios> is your build directory of the linphone-sdk project, containing the linphone-sdk.podspec file and a linphone-sdk output directory comprising built frameworks and resources.
87 }}}
88
89 = Using liblinphone =
90
91 Liblinphone has a C API, suitable to be used with Objective-C, and a modern Swift API. To use in swift, import the liblinphone swift module in your source file using
92
93 {{code}}
94 import linphonesw
95 {{/code}}
96
97 == API documentation ==
98
99 You can find the liblinphone C API documentation [[here>>https://linphone.org/releases/docs/liblinphone/5.0/c/]].
100
101 For Swift, online documentation is available [[here>>https://linphone.org/releases/docs/liblinphone/5.0/swift/]] . In addition, this [[iOS sample app>>https://gitlab.linphone.org/BC/public/tutorials/-/tree/master/ios]] shows how to use liblinphone in a Swift project.
102
103 = Integrating push notifications =
104
105 Push notifications integrations are a more advanced features, and you will find explanations in great details [[here>>doc:Lib.Features.IOS push notification management.WebHome]]. It is heavily recommended that you have a look at the [[CallKit tutorial>>https://gitlab.linphone.org/BC/public/tutorials/-/tree/master/ios/swift/4-CallKitTutorial]] and the [[Remote Notifications tutorial>>https://gitlab.linphone.org/BC/public/tutorials/-/tree/master/ios/swift/8-RemoteNotification]] if you wish for a simple integration of these features in your app.
106
107 = Handling liblinphone log =
108
109 In order to see liblinphone logs in your IOS app (for example in your Xcode console) follow these steps :
110
111 Put in your code at the launching of the app :
112
113 {{code language="Objective-C"}}
114 linphone_core_set_log_handler(your_log_handler);
115 {{/code}}
116
117 This will make the liblinphone logs to call your_log_handler and so be processed as a log from your app.
118
119 You can set the liblinphone log level by using the functions documented [[here>>http://linphone.org/docs/liblinphone/group__initializing.html#ga685b79d92af0184dbeac46df14bf4705]].
120
121 == IOS log handler for liblinphone ==
122
123 Once you have set your log handler, you need to process liblinphone log in order to incorporate them into your app logs.
124
125 Here is a short example of how to manage liblinphone log into an IOS app :
126
127 {{code language="Objective-C"}}
128 void linphone_iphone_log_handler(const char *domain, OrtpLogLevel lev, const char *fmt, va_list args) {
129 NSString *format = [[NSString alloc] initWithUTF8String:fmt];
130 NSString *formatedString = [[NSString alloc] initWithFormat:format arguments:args];
131 NSString *lvl;
132
133 if (!domain)
134 domain = "lib";
135 // since \r are interpreted like \n, avoid double new lines when logging network packets (belle-sip)
136 // output format is like: I/ios/some logs. We truncate domain to **exactly** DOMAIN_SIZE characters to have
137 // fixed-length aligned logs
138 switch (lev) {
139 case ORTP_FATAL:
140 lvl = @"Fatal";
141 break;
142 case ORTP_ERROR:
143 lvl = @"Error";
144 break;
145 case ORTP_WARNING:
146 lvl = @"Warning";
147 break;
148 case ORTP_MESSAGE:
149 lvl = @"Message";
150 break;
151 case ORTP_DEBUG:
152 lvl = @"Debug";
153 break;
154 case ORTP_TRACE:
155 lvl = @"Trace";
156 break;
157 case ORTP_LOGLEV_END:
158 return;
159 }
160 if ([formatedString containsString:@"\n"]) {
161 NSArray *myWords = [[formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"]
162 componentsSeparatedByString:@"\n"];
163 for (int i = 0; i < myWords.count; i++) {
164 NSString *tab = i > 0 ? @"\t" : @"";
165 if (((NSString *)myWords[i]).length > 0) {
166 NSLog(@"[%@] %@%@", lvl, tab, (NSString *)myWords[i]);
167 }
168 }
169 } else {
170 NSLog(@"[%@] %@", lvl, [formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"]);
171 }
172 }
173 {{/code}}
174
175
176
177 )))
178
179 (% class="col-xs-12 col-sm-4" %)
180 (((
181 {{box title="**Contents**"}}
182 {{toc/}}
183 {{/box}}
184 )))
185 )))