livevoice-sdk-react-native 2.0.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -66
- package/android/build.gradle +5 -4
- package/android/src/main/java/io/livevoice/react/LiveVoiceModule.kt +122 -188
- package/android/src/main/java/io/livevoice/react/__SDK.kt +2 -2
- package/ios/LiveVoiceRNBridge.swift +362 -0
- package/ios/LiveVoiceSdkReactNative.mm +187 -158
- package/ios/__SDK.h +1 -1
- package/ios/livevoice_spm_backport.rb +202 -0
- package/lib/module/components/BrandingView.js +58 -39
- package/lib/module/components/BrandingView.js.map +1 -1
- package/lib/module/components/ChannelView.js +355 -44
- package/lib/module/components/ChannelView.js.map +1 -1
- package/lib/module/components/ErrorView.js +5 -6
- package/lib/module/components/ErrorView.js.map +1 -1
- package/lib/module/components/LiveVoiceSpinner.js +81 -0
- package/lib/module/components/LiveVoiceSpinner.js.map +1 -0
- package/lib/module/components/LiveVoiceView.js +311 -133
- package/lib/module/components/LiveVoiceView.js.map +1 -1
- package/lib/module/components/PasswordPrompt.js +165 -0
- package/lib/module/components/PasswordPrompt.js.map +1 -0
- package/lib/module/components/PlayButtonView.js +180 -244
- package/lib/module/components/PlayButtonView.js.map +1 -1
- package/lib/module/components/ReconnectingView.js +31 -53
- package/lib/module/components/ReconnectingView.js.map +1 -1
- package/lib/module/icons/branding-ios.png +0 -0
- package/lib/module/icons/camera-off-android.png +0 -0
- package/lib/module/icons/camera-off-android@2x.png +0 -0
- package/lib/module/icons/camera-off-android@3x.png +0 -0
- package/lib/module/icons/cpu-android.png +0 -0
- package/lib/module/icons/cpu-android@2x.png +0 -0
- package/lib/module/icons/cpu-android@3x.png +0 -0
- package/lib/module/icons/cpu-ios.png +0 -0
- package/lib/module/icons/cpu-ios@2x.png +0 -0
- package/lib/module/icons/cpu-ios@3x.png +0 -0
- package/lib/module/icons/lock-android.png +0 -0
- package/lib/module/icons/lock-android@2x.png +0 -0
- package/lib/module/icons/lock-android@3x.png +0 -0
- package/lib/module/icons/lock-ios.png +0 -0
- package/lib/module/icons/lock-ios@2x.png +0 -0
- package/lib/module/icons/lock-ios@3x.png +0 -0
- package/lib/module/icons/mic-off-android.png +0 -0
- package/lib/module/icons/mic-off-android@2x.png +0 -0
- package/lib/module/icons/mic-off-android@3x.png +0 -0
- package/lib/module/icons/mic-slash-ios.png +0 -0
- package/lib/module/icons/mic-slash-ios@2x.png +0 -0
- package/lib/module/icons/mic-slash-ios@3x.png +0 -0
- package/lib/module/icons/video-slash-ios.png +0 -0
- package/lib/module/icons/video-slash-ios@2x.png +0 -0
- package/lib/module/icons/video-slash-ios@3x.png +0 -0
- package/lib/module/index.js +11 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/sdk/Bridge.js +236 -0
- package/lib/module/sdk/Bridge.js.map +1 -0
- package/lib/module/sdk/Event.js +160 -0
- package/lib/module/sdk/Event.js.map +1 -0
- package/lib/module/sdk/Lifecycle.js +331 -0
- package/lib/module/sdk/Lifecycle.js.map +1 -0
- package/lib/module/sdk/LiveVoiceSdk.js +262 -268
- package/lib/module/sdk/LiveVoiceSdk.js.map +1 -1
- package/lib/module/sdk/LiveVoiceState.js +208 -40
- package/lib/module/sdk/LiveVoiceState.js.map +1 -1
- package/lib/module/sdk/LogEntries.js +99 -0
- package/lib/module/sdk/LogEntries.js.map +1 -0
- package/lib/module/sdk/Models.js +2 -0
- package/lib/module/{util/UIState.js.map → sdk/Models.js.map} +1 -1
- package/lib/module/{util/PlayingState.js → sdk/NativeSdkVersions.js} +9 -8
- package/lib/module/sdk/NativeSdkVersions.js.map +1 -0
- package/lib/module/sdk/Observables.js +391 -0
- package/lib/module/sdk/Observables.js.map +1 -0
- package/lib/module/sdk/Passwords.js +298 -0
- package/lib/module/sdk/Passwords.js.map +1 -0
- package/lib/module/sdk/Playback.js +35 -0
- package/lib/module/sdk/Playback.js.map +1 -0
- package/lib/module/specs/NativeLiveVoiceSdk.js.map +1 -1
- package/lib/module/util/Colors.js +2 -1
- package/lib/module/util/Colors.js.map +1 -1
- package/lib/module/util/Translations.js +34 -11
- package/lib/module/util/Translations.js.map +1 -1
- package/lib/module/util/freeze.js +26 -0
- package/lib/module/util/freeze.js.map +1 -0
- package/lib/module/util/logger.js +79 -41
- package/lib/module/util/logger.js.map +1 -1
- package/lib/typescript/src/components/BrandingView.d.ts +4 -0
- package/lib/typescript/src/components/BrandingView.d.ts.map +1 -1
- package/lib/typescript/src/components/ChannelView.d.ts +29 -3
- package/lib/typescript/src/components/ChannelView.d.ts.map +1 -1
- package/lib/typescript/src/components/ErrorView.d.ts +5 -3
- package/lib/typescript/src/components/ErrorView.d.ts.map +1 -1
- package/lib/typescript/src/components/LiveVoiceSpinner.d.ts +16 -0
- package/lib/typescript/src/components/LiveVoiceSpinner.d.ts.map +1 -0
- package/lib/typescript/src/components/LiveVoiceView.d.ts +81 -21
- package/lib/typescript/src/components/LiveVoiceView.d.ts.map +1 -1
- package/lib/typescript/src/components/PasswordPrompt.d.ts +13 -0
- package/lib/typescript/src/components/PasswordPrompt.d.ts.map +1 -0
- package/lib/typescript/src/components/PlayButtonView.d.ts +12 -329
- package/lib/typescript/src/components/PlayButtonView.d.ts.map +1 -1
- package/lib/typescript/src/components/ReconnectingView.d.ts +6 -3
- package/lib/typescript/src/components/ReconnectingView.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +15 -6
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/sdk/Bridge.d.ts +36 -0
- package/lib/typescript/src/sdk/Bridge.d.ts.map +1 -0
- package/lib/typescript/src/sdk/Event.d.ts +97 -0
- package/lib/typescript/src/sdk/Event.d.ts.map +1 -0
- package/lib/typescript/src/sdk/Lifecycle.d.ts +191 -0
- package/lib/typescript/src/sdk/Lifecycle.d.ts.map +1 -0
- package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts +195 -190
- package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts.map +1 -1
- package/lib/typescript/src/sdk/LiveVoiceState.d.ts +77 -9
- package/lib/typescript/src/sdk/LiveVoiceState.d.ts.map +1 -1
- package/lib/typescript/src/sdk/LogEntries.d.ts +28 -0
- package/lib/typescript/src/sdk/LogEntries.d.ts.map +1 -0
- package/lib/typescript/src/sdk/Models.d.ts +114 -0
- package/lib/typescript/src/sdk/Models.d.ts.map +1 -0
- package/lib/typescript/src/sdk/NativeSdkVersions.d.ts +6 -0
- package/lib/typescript/src/sdk/NativeSdkVersions.d.ts.map +1 -0
- package/lib/typescript/src/sdk/Observables.d.ts +123 -0
- package/lib/typescript/src/sdk/Observables.d.ts.map +1 -0
- package/lib/typescript/src/sdk/Passwords.d.ts +72 -0
- package/lib/typescript/src/sdk/Passwords.d.ts.map +1 -0
- package/lib/typescript/src/sdk/Playback.d.ts +9 -0
- package/lib/typescript/src/sdk/Playback.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts +34 -31
- package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts.map +1 -1
- package/lib/typescript/src/util/Colors.d.ts.map +1 -1
- package/lib/typescript/src/util/Translations.d.ts +30 -8
- package/lib/typescript/src/util/Translations.d.ts.map +1 -1
- package/lib/typescript/src/util/freeze.d.ts +6 -0
- package/lib/typescript/src/util/freeze.d.ts.map +1 -0
- package/lib/typescript/src/util/logger.d.ts +17 -7
- package/lib/typescript/src/util/logger.d.ts.map +1 -1
- package/livevoice-sdk-react-native.podspec +29 -4
- package/package.json +12 -9
- package/src/components/BrandingView.tsx +42 -55
- package/src/components/ChannelView.tsx +329 -38
- package/src/components/ErrorView.tsx +9 -12
- package/src/components/LiveVoiceSpinner.tsx +87 -0
- package/src/components/LiveVoiceView.tsx +319 -201
- package/src/components/PasswordPrompt.tsx +144 -0
- package/src/components/PlayButtonView.tsx +165 -269
- package/src/components/ReconnectingView.tsx +28 -81
- package/src/icons/branding-ios.png +0 -0
- package/src/icons/camera-off-android.png +0 -0
- package/src/icons/camera-off-android@2x.png +0 -0
- package/src/icons/camera-off-android@3x.png +0 -0
- package/src/icons/cpu-android.png +0 -0
- package/src/icons/cpu-android@2x.png +0 -0
- package/src/icons/cpu-android@3x.png +0 -0
- package/src/icons/cpu-ios.png +0 -0
- package/src/icons/cpu-ios@2x.png +0 -0
- package/src/icons/cpu-ios@3x.png +0 -0
- package/src/icons/lock-android.png +0 -0
- package/src/icons/lock-android@2x.png +0 -0
- package/src/icons/lock-android@3x.png +0 -0
- package/src/icons/lock-ios.png +0 -0
- package/src/icons/lock-ios@2x.png +0 -0
- package/src/icons/lock-ios@3x.png +0 -0
- package/src/icons/mic-off-android.png +0 -0
- package/src/icons/mic-off-android@2x.png +0 -0
- package/src/icons/mic-off-android@3x.png +0 -0
- package/src/icons/mic-slash-ios.png +0 -0
- package/src/icons/mic-slash-ios@2x.png +0 -0
- package/src/icons/mic-slash-ios@3x.png +0 -0
- package/src/icons/video-slash-ios.png +0 -0
- package/src/icons/video-slash-ios@2x.png +0 -0
- package/src/icons/video-slash-ios@3x.png +0 -0
- package/src/index.tsx +92 -6
- package/src/sdk/Bridge.ts +259 -0
- package/src/sdk/Event.ts +187 -0
- package/src/sdk/Lifecycle.ts +366 -0
- package/src/sdk/LiveVoiceSdk.ts +285 -309
- package/src/sdk/LiveVoiceState.ts +230 -60
- package/src/sdk/LogEntries.ts +88 -0
- package/src/sdk/Models.ts +129 -0
- package/src/{util/PlayingState.ts → sdk/NativeSdkVersions.ts} +7 -6
- package/src/sdk/Observables.ts +414 -0
- package/src/sdk/Passwords.ts +286 -0
- package/src/sdk/Playback.ts +30 -0
- package/src/specs/NativeLiveVoiceSdk.ts +42 -38
- package/src/util/Colors.ts +2 -1
- package/src/util/Translations.ts +34 -12
- package/src/util/freeze.ts +23 -0
- package/src/util/logger.ts +79 -52
- package/lib/module/components/AudioOutputSwitchView.js +0 -138
- package/lib/module/components/AudioOutputSwitchView.js.map +0 -1
- package/lib/module/components/index.js +0 -24
- package/lib/module/components/index.js.map +0 -1
- package/lib/module/icons/mic.png +0 -0
- package/lib/module/util/ForegroundServiceConfig.js +0 -38
- package/lib/module/util/ForegroundServiceConfig.js.map +0 -1
- package/lib/module/util/PlayingState.js.map +0 -1
- package/lib/module/util/UIState.js +0 -4
- package/lib/typescript/src/components/AudioOutputSwitchView.d.ts +0 -6
- package/lib/typescript/src/components/AudioOutputSwitchView.d.ts.map +0 -1
- package/lib/typescript/src/components/index.d.ts +0 -9
- package/lib/typescript/src/components/index.d.ts.map +0 -1
- package/lib/typescript/src/util/ForegroundServiceConfig.d.ts +0 -19
- package/lib/typescript/src/util/ForegroundServiceConfig.d.ts.map +0 -1
- package/lib/typescript/src/util/PlayingState.d.ts +0 -7
- package/lib/typescript/src/util/PlayingState.d.ts.map +0 -1
- package/lib/typescript/src/util/UIState.d.ts +0 -86
- package/lib/typescript/src/util/UIState.d.ts.map +0 -1
- package/src/components/AudioOutputSwitchView.tsx +0 -146
- package/src/components/index.tsx +0 -21
- package/src/icons/mic.png +0 -0
- package/src/util/ForegroundServiceConfig.tsx +0 -42
- package/src/util/UIState.ts +0 -106
|
@@ -12,7 +12,12 @@
|
|
|
12
12
|
//===----------------------------------------------------------------------===//
|
|
13
13
|
|
|
14
14
|
#import "LiveVoiceSdkReactNative.h"
|
|
15
|
-
|
|
15
|
+
// The SDK is reached only through LiveVoiceRNBridge.swift.
|
|
16
|
+
#if __has_include(<livevoice_sdk_react_native/livevoice_sdk_react_native-Swift.h>)
|
|
17
|
+
#import <livevoice_sdk_react_native/livevoice_sdk_react_native-Swift.h>
|
|
18
|
+
#else
|
|
19
|
+
#import "livevoice_sdk_react_native-Swift.h"
|
|
20
|
+
#endif
|
|
16
21
|
#import "React/RCTVersion.h"
|
|
17
22
|
#import "__SDK.h"
|
|
18
23
|
#import <os/log.h>
|
|
@@ -50,22 +55,66 @@ static void LiveVoiceLogInfo(NSString *event, NSDictionary<NSString *, id> *fiel
|
|
|
50
55
|
message.UTF8String);
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
@interface LiveVoiceSdkReactNative ()
|
|
59
|
+
// Ownership is protected by @synchronized(self). Never call Swift or a reply
|
|
60
|
+
// while holding it: attaching asynchronously enters the main actor.
|
|
61
|
+
@property(nonatomic, strong, nullable) LiveVoiceRNBridge *liveVoice;
|
|
62
|
+
@property(nonatomic) BOOL runtimeInvalidated;
|
|
63
|
+
@property(nonatomic) BOOL attaching;
|
|
64
|
+
@property(nonatomic, strong) NSMutableArray<void (^)(LiveVoiceRNBridge *_Nullable)> *attachReplies;
|
|
65
|
+
// Events reach JavaScript through the runtime's C++ module, which a reload
|
|
66
|
+
// destroys once `invalidate` returns. The bridge's streams end later, on the
|
|
67
|
+
// main actor, so values still queued must be dropped. This lock makes an
|
|
68
|
+
// emission and `invalidate` exclude each other; nothing else is called under it.
|
|
69
|
+
@property(nonatomic, strong) NSLock *emitLock;
|
|
70
|
+
@property(nonatomic) BOOL emitsStopped;
|
|
55
71
|
@end
|
|
56
72
|
|
|
57
73
|
@implementation LiveVoiceSdkReactNative
|
|
58
74
|
|
|
59
75
|
RCT_EXPORT_MODULE(LiveVoiceModule)
|
|
60
76
|
|
|
77
|
+
- (instancetype)init {
|
|
78
|
+
if ((self = [super init])) _emitLock = [NSLock new];
|
|
79
|
+
return self;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/// Runs `emit` unless the runtime went away; `invalidate` waits for one in progress.
|
|
83
|
+
- (void)emitUnlessInvalidated:(void (NS_NOESCAPE ^)(void))emit {
|
|
84
|
+
[self.emitLock lock];
|
|
85
|
+
if (!self.emitsStopped) emit();
|
|
86
|
+
[self.emitLock unlock];
|
|
87
|
+
}
|
|
88
|
+
|
|
61
89
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
62
90
|
(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
63
91
|
return std::make_shared<facebook::react::NativeLiveVoiceSdkSpecJSI>(params);
|
|
64
92
|
}
|
|
65
93
|
|
|
94
|
+
static void LiveVoiceReject(RCTPromiseRejectBlock reject, NSString *error) {
|
|
95
|
+
NSDictionary *wire = [NSJSONSerialization JSONObjectWithData:[error dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
|
|
96
|
+
NSString *code = [wire isKindOfClass:[NSDictionary class]] ? wire[@"code"] : nil;
|
|
97
|
+
reject([code isKindOfClass:[NSString class]] ? code : @"generic", error, nil);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/// Calls `use` with the attached bridge, attaching it first if needed, or with
|
|
101
|
+
/// nil once the runtime went away.
|
|
102
|
+
- (void)withBridge:(void (^)(LiveVoiceRNBridge *_Nullable))use {
|
|
103
|
+
BOOL invalidated = NO;
|
|
104
|
+
LiveVoiceRNBridge *attached;
|
|
105
|
+
@synchronized(self) {
|
|
106
|
+
invalidated = self.runtimeInvalidated;
|
|
107
|
+
attached = self.liveVoice;
|
|
108
|
+
if (!invalidated && !attached) {
|
|
109
|
+
if (!self.attachReplies) self.attachReplies = [NSMutableArray new];
|
|
110
|
+
[self.attachReplies addObject:use];
|
|
111
|
+
if (self.attaching) return;
|
|
112
|
+
self.attaching = YES;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (invalidated) { use(nil); return; }
|
|
116
|
+
if (attached) { use(attached); return; }
|
|
66
117
|
|
|
67
|
-
|
|
68
|
-
- (void)initialize:(NSString *_Nullable)androidServiceConfig {
|
|
69
118
|
NSDictionary *versionInfo = RCTGetReactNativeVersion();
|
|
70
119
|
NSString *major = versionInfo[RCTVersionMajor];
|
|
71
120
|
NSString *minor = versionInfo[RCTVersionMinor];
|
|
@@ -73,236 +122,216 @@ RCT_EXPORT_MODULE(LiveVoiceModule)
|
|
|
73
122
|
NSString *const PLATFORM_VERSION =
|
|
74
123
|
[NSString stringWithFormat:@"%@.%@.%@", major, minor, patch];
|
|
75
124
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
125
|
+
__weak LiveVoiceSdkReactNative *weakSelf = self;
|
|
126
|
+
[LiveVoiceRNBridge
|
|
127
|
+
startWithReactNativeVersion:PLATFORM_VERSION
|
|
128
|
+
wrapperVersion:SDK_VERSION
|
|
129
|
+
onState:^(NSString *value) {
|
|
130
|
+
LiveVoiceSdkReactNative *module = weakSelf;
|
|
131
|
+
[module emitUnlessInvalidated:^{ [module emitOnState:value]; }];
|
|
132
|
+
}
|
|
133
|
+
onPasswordRequest:^(NSString *value) {
|
|
134
|
+
LiveVoiceSdkReactNative *module = weakSelf;
|
|
135
|
+
[module emitUnlessInvalidated:^{ [module emitOnPasswordRequest:value]; }];
|
|
136
|
+
}
|
|
137
|
+
onPasswordRequestCancelled:^(NSString *value) {
|
|
138
|
+
LiveVoiceSdkReactNative *module = weakSelf;
|
|
139
|
+
[module emitUnlessInvalidated:^{ [module emitOnPasswordRequestCancelled:value]; }];
|
|
140
|
+
}
|
|
141
|
+
onPasswordStoreRequest:^(NSString *value) {
|
|
142
|
+
LiveVoiceSdkReactNative *module = weakSelf;
|
|
143
|
+
[module emitUnlessInvalidated:^{ [module emitOnPasswordStoreRequest:value]; }];
|
|
144
|
+
}
|
|
145
|
+
onLogEntry:^(NSString *value) {
|
|
146
|
+
LiveVoiceSdkReactNative *module = weakSelf;
|
|
147
|
+
[module emitUnlessInvalidated:^{ [module emitOnLogEntry:value]; }];
|
|
148
|
+
}
|
|
149
|
+
completion:^(LiveVoiceRNBridge *created) {
|
|
150
|
+
LiveVoiceSdkReactNative *module = weakSelf;
|
|
151
|
+
if (!module) { [created invalidate]; return; }
|
|
152
|
+
NSArray<void (^)(LiveVoiceRNBridge *_Nullable)> *replies;
|
|
153
|
+
BOOL invalidated;
|
|
154
|
+
@synchronized(module) {
|
|
155
|
+
invalidated = module.runtimeInvalidated;
|
|
156
|
+
if (!invalidated) module.liveVoice = created;
|
|
157
|
+
module.attaching = NO;
|
|
158
|
+
replies = [module.attachReplies copy];
|
|
159
|
+
module.attachReplies = nil;
|
|
160
|
+
}
|
|
161
|
+
if (invalidated) [created invalidate];
|
|
162
|
+
else LiveVoiceLogInfo(@"LV_INIT", @{@"platformVersion" : PLATFORM_VERSION});
|
|
163
|
+
for (void (^pending)(LiveVoiceRNBridge *_Nullable) in replies) pending(invalidated ? nil : created);
|
|
112
164
|
}];
|
|
113
|
-
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
|
|
114
|
-
return result;
|
|
115
165
|
}
|
|
116
166
|
|
|
117
|
-
- (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
167
|
+
- (void)initialize:(NSString *)configuration
|
|
168
|
+
resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
169
|
+
[self withBridge:^(LiveVoiceRNBridge *bridge) {
|
|
170
|
+
if (bridge == nil) { LiveVoiceReject(reject, [LiveVoiceRNBridge errorJSONWithCode:@"cancelled"]); return; }
|
|
171
|
+
[bridge initializeWithConfiguration:configuration completion:^(NSString *snapshot, NSString *error) {
|
|
172
|
+
if (error != nil) LiveVoiceReject(reject, error);
|
|
173
|
+
else resolve(snapshot);
|
|
174
|
+
}];
|
|
123
175
|
}];
|
|
124
|
-
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
|
|
125
|
-
return result;
|
|
126
176
|
}
|
|
127
177
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
178
|
+
- (void)execute:(NSString *)command payload:(NSString *)arguments
|
|
179
|
+
resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
180
|
+
LiveVoiceRNBridge *bridge;
|
|
181
|
+
BOOL invalidated;
|
|
182
|
+
@synchronized(self) { bridge = self.liveVoice; invalidated = self.runtimeInvalidated; }
|
|
183
|
+
if (bridge == nil) {
|
|
184
|
+
LiveVoiceReject(reject, [LiveVoiceRNBridge errorJSONWithCode:invalidated ? @"cancelled" : @"not_initialized"]);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
[bridge executeWithName:command arguments:arguments completion:^(NSString *value, NSString *error) {
|
|
188
|
+
if (error != nil) LiveVoiceReject(reject, error);
|
|
189
|
+
else resolve(value ?: @"null");
|
|
135
190
|
}];
|
|
136
|
-
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
|
|
137
|
-
return [NSNumber numberWithBool:result];
|
|
138
191
|
}
|
|
139
192
|
|
|
140
|
-
- (
|
|
141
|
-
|
|
142
|
-
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
|
|
143
|
-
[LiveVoice currentAvailableSubtitlesWithCompletion:^(NSString *value) {
|
|
144
|
-
result = value;
|
|
145
|
-
dispatch_semaphore_signal(sema);
|
|
146
|
-
}];
|
|
147
|
-
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
|
|
148
|
-
return result;
|
|
193
|
+
- (NSString *)getErrorMessages {
|
|
194
|
+
return LiveVoiceRNBridge.errorMessages;
|
|
149
195
|
}
|
|
150
196
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
197
|
+
// Works before `initialize`: attaches the bridge first if needed, so the
|
|
198
|
+
// preference reaches native and the snapshot later carries it. Ignored once
|
|
199
|
+
// the runtime went away.
|
|
200
|
+
- (void)setAudioOutput:(NSString *)payload {
|
|
201
|
+
[self withBridge:^(LiveVoiceRNBridge *bridge) {
|
|
202
|
+
[bridge setAudioOutput:payload];
|
|
157
203
|
}];
|
|
158
|
-
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
|
|
159
|
-
return result;
|
|
160
204
|
}
|
|
161
205
|
|
|
162
|
-
- (
|
|
163
|
-
|
|
164
|
-
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
|
|
165
|
-
[LiveVoice currentSubtitleStateWithCompletion:^(NSString *value) {
|
|
166
|
-
result = value;
|
|
167
|
-
dispatch_semaphore_signal(sema);
|
|
168
|
-
}];
|
|
169
|
-
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
|
|
170
|
-
return result;
|
|
206
|
+
- (void)writeLogEntry:(NSString *)payload {
|
|
207
|
+
[LiveVoiceRNBridge writeLogEntry:payload];
|
|
171
208
|
}
|
|
172
209
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
- (void)setLiveVoiceUseSpeaker:(BOOL)useSpeaker {
|
|
176
|
-
[LiveVoice setAudioOutputToSpeaker:useSpeaker completion:^{}];
|
|
210
|
+
- (void)answerPasswordRequest:(NSString *)payload {
|
|
211
|
+
[[self bridgeSnapshot] answerPasswordRequest:payload];
|
|
177
212
|
}
|
|
178
213
|
|
|
179
|
-
- (void)
|
|
180
|
-
[
|
|
214
|
+
- (void)answerPasswordStoreRequest:(NSString *)payload {
|
|
215
|
+
[[self bridgeSnapshot] answerPasswordStoreRequest:payload];
|
|
181
216
|
}
|
|
182
217
|
|
|
183
|
-
- (void)
|
|
184
|
-
[
|
|
218
|
+
- (void)setPasswordStore:(NSString *)payload {
|
|
219
|
+
[[self bridgeSnapshot] setPasswordStore:payload];
|
|
185
220
|
}
|
|
186
221
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
- (void)startSubtitles:(double)channelId {
|
|
190
|
-
NSNumber *_Nullable optionalChannelID =
|
|
191
|
-
(channelId == -1) ? nil : [NSNumber numberWithLongLong:channelId];
|
|
192
|
-
[LiveVoice startSubtitlesWithChannelID:optionalChannelID completion:^{}];
|
|
222
|
+
- (LiveVoiceRNBridge *)bridgeSnapshot {
|
|
223
|
+
@synchronized(self) { return self.runtimeInvalidated ? nil : self.liveVoice; }
|
|
193
224
|
}
|
|
194
225
|
|
|
195
|
-
- (void)
|
|
196
|
-
[
|
|
226
|
+
- (void)invalidate {
|
|
227
|
+
[self.emitLock lock];
|
|
228
|
+
self.emitsStopped = YES;
|
|
229
|
+
[self.emitLock unlock];
|
|
230
|
+
LiveVoiceRNBridge *bridge;
|
|
231
|
+
NSArray<void (^)(LiveVoiceRNBridge *_Nullable)> *replies;
|
|
232
|
+
@synchronized(self) {
|
|
233
|
+
self.runtimeInvalidated = YES;
|
|
234
|
+
bridge = self.liveVoice;
|
|
235
|
+
self.liveVoice = nil;
|
|
236
|
+
replies = [self.attachReplies copy];
|
|
237
|
+
self.attachReplies = nil;
|
|
238
|
+
}
|
|
239
|
+
[bridge invalidate];
|
|
240
|
+
for (void (^pending)(LiveVoiceRNBridge *_Nullable) in replies) pending(nil);
|
|
197
241
|
}
|
|
198
242
|
|
|
243
|
+
#pragma mark - Actions
|
|
244
|
+
|
|
199
245
|
- (void)openLiveVoiceWebsite {
|
|
200
|
-
[
|
|
246
|
+
[LiveVoiceRNBridge openLiveVoiceWebsite];
|
|
201
247
|
}
|
|
202
248
|
|
|
203
249
|
- (nonnull NSString *)getSdkVersion {
|
|
204
250
|
return SDK_VERSION;
|
|
205
251
|
}
|
|
206
252
|
|
|
253
|
+
- (nonnull NSString *)getNativeSdkVersion {
|
|
254
|
+
return LiveVoiceRNBridge.nativeSdkVersion;
|
|
255
|
+
}
|
|
256
|
+
|
|
207
257
|
#pragma mark - Translations
|
|
208
258
|
|
|
209
259
|
- (nonnull NSString *)channelStatusOffline {
|
|
210
|
-
return [
|
|
260
|
+
return [LiveVoiceRNBridge translation:@"channel_status_offline" seconds:0];
|
|
211
261
|
}
|
|
212
262
|
|
|
213
263
|
- (nonnull NSString *)errorScreenRetrying {
|
|
214
|
-
return [
|
|
264
|
+
return [LiveVoiceRNBridge translation:@"error_screen_retrying" seconds:0];
|
|
215
265
|
}
|
|
216
266
|
|
|
217
267
|
- (nonnull NSString *)errorScreenRetryingIn:(double)seconds {
|
|
218
|
-
return [
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
- (nonnull NSString *)sdkErrorGeneric {
|
|
222
|
-
return [Translations sdk_error_generic];
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
- (nonnull NSString *)sdkErrorInactive {
|
|
226
|
-
return [Translations sdk_error_inactive];
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
- (nonnull NSString *)sdkErrorInvalidApiKey {
|
|
230
|
-
return [Translations sdk_error_invalid_api_key];
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
- (nonnull NSString *)sdkErrorListenerLimitReached {
|
|
234
|
-
return [Translations sdk_error_listener_limit_reached];
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
- (nonnull NSString *)sdkErrorNoNetwork {
|
|
238
|
-
return [Translations sdk_error_no_network];
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
- (nonnull NSString *)sdkErrorNotFound {
|
|
242
|
-
return [Translations sdk_error_not_found];
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
- (nonnull NSString *)sdkErrorRequestFailed:(double)errorCode {
|
|
246
|
-
return [Translations
|
|
247
|
-
sdk_error_request_failed:[NSString stringWithFormat:@"%1.0f", errorCode]];
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
- (nonnull NSString *)sdkErrorWrongPassword {
|
|
251
|
-
return [Translations sdk_error_wrong_password];
|
|
268
|
+
return [LiveVoiceRNBridge translation:@"error_screen_retrying_in" seconds:(NSInteger)seconds];
|
|
252
269
|
}
|
|
253
270
|
|
|
254
271
|
- (nonnull NSString *)sdkNoMatchingChannels {
|
|
255
|
-
return [
|
|
272
|
+
return [LiveVoiceRNBridge translation:@"sdk_no_matching_channels" seconds:0];
|
|
256
273
|
}
|
|
257
274
|
|
|
258
275
|
- (nonnull NSString *)streamingByTitle {
|
|
259
|
-
return [
|
|
276
|
+
return [LiveVoiceRNBridge translation:@"streaming_by_title" seconds:0];
|
|
260
277
|
}
|
|
261
278
|
|
|
262
279
|
- (nonnull NSString *)accessibilityChannelPlay {
|
|
263
|
-
return [
|
|
280
|
+
return [LiveVoiceRNBridge translation:@"a11y_channel_play" seconds:0];
|
|
264
281
|
}
|
|
265
282
|
|
|
266
283
|
- (nonnull NSString *)accessibilityChannelStatusMuted {
|
|
267
|
-
return [
|
|
284
|
+
return [LiveVoiceRNBridge translation:@"a11y_channel_status_muted" seconds:0];
|
|
268
285
|
}
|
|
269
286
|
|
|
270
287
|
- (nonnull NSString *)accessibilityChannelStop {
|
|
271
|
-
return [
|
|
288
|
+
return [LiveVoiceRNBridge translation:@"a11y_channel_stop" seconds:0];
|
|
272
289
|
}
|
|
273
290
|
|
|
274
291
|
- (nonnull NSString *)isAiChannelStatusMessage {
|
|
275
|
-
return [
|
|
292
|
+
return [LiveVoiceRNBridge translation:@"channel_status_is_ai" seconds:0];
|
|
276
293
|
}
|
|
277
294
|
|
|
278
295
|
- (nonnull NSString *)noChannels {
|
|
279
|
-
return [
|
|
296
|
+
return [LiveVoiceRNBridge translation:@"no_channels" seconds:0];
|
|
280
297
|
}
|
|
281
298
|
|
|
282
299
|
- (nonnull NSString *)errorRetryNowButton {
|
|
283
|
-
return [
|
|
300
|
+
return [LiveVoiceRNBridge translation:@"action_retry_now" seconds:0];
|
|
284
301
|
}
|
|
285
302
|
|
|
286
|
-
#pragma mark -
|
|
303
|
+
#pragma mark - Password prompt
|
|
304
|
+
|
|
305
|
+
- (nonnull NSString *)passwordPromptTitle {
|
|
306
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_title" seconds:0];
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
- (nonnull NSString *)passwordPromptChannelMessage {
|
|
310
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_channel_message" seconds:0];
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
- (nonnull NSString *)passwordPromptEventMessage {
|
|
314
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_event_message" seconds:0];
|
|
315
|
+
}
|
|
287
316
|
|
|
288
|
-
- (
|
|
289
|
-
[
|
|
317
|
+
- (nonnull NSString *)passwordPromptWrongPassword {
|
|
318
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_wrong_password" seconds:0];
|
|
290
319
|
}
|
|
291
320
|
|
|
292
|
-
- (
|
|
293
|
-
[
|
|
321
|
+
- (nonnull NSString *)passwordPromptField {
|
|
322
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_field" seconds:0];
|
|
294
323
|
}
|
|
295
324
|
|
|
296
|
-
- (
|
|
297
|
-
[
|
|
325
|
+
- (nonnull NSString *)passwordPromptCancelButton {
|
|
326
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_cancel_button" seconds:0];
|
|
298
327
|
}
|
|
299
328
|
|
|
300
|
-
- (
|
|
301
|
-
[
|
|
329
|
+
- (nonnull NSString *)passwordPromptChannelConfirmButton {
|
|
330
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_channel_confirm_button" seconds:0];
|
|
302
331
|
}
|
|
303
332
|
|
|
304
|
-
- (
|
|
305
|
-
[
|
|
333
|
+
- (nonnull NSString *)passwordPromptEventConfirmButton {
|
|
334
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_event_confirm_button" seconds:0];
|
|
306
335
|
}
|
|
307
336
|
|
|
308
337
|
@end
|
package/ios/__SDK.h
CHANGED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
#===----------------------------------------------------------------------===#
|
|
2
|
+
#
|
|
3
|
+
# This source file is part of the LiveVoice SDK project
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) LiveVoice GmbH
|
|
6
|
+
# Licensed under the MIT license
|
|
7
|
+
#
|
|
8
|
+
# See LICENSE for license information
|
|
9
|
+
#
|
|
10
|
+
# SPDX-License-Identifier: MIT
|
|
11
|
+
#
|
|
12
|
+
#===----------------------------------------------------------------------===#
|
|
13
|
+
|
|
14
|
+
# React Native before 0.89 attaches a Swift package from `spm_dependency` to
|
|
15
|
+
# the pod only. Two things then go wrong for a package with dynamic binary
|
|
16
|
+
# frameworks, as the native LiveVoice SDK is:
|
|
17
|
+
#
|
|
18
|
+
# - CocoaPods embeds only the frameworks of pods, so the SDK and WebRTC are
|
|
19
|
+
# linked but never copied into the app, which fails at launch with dyld
|
|
20
|
+
# "Library not loaded".
|
|
21
|
+
# - Xcode writes each binary target's signature both to the shared products
|
|
22
|
+
# dir and to the pod's build dir, and archiving fails on the duplicate.
|
|
23
|
+
#
|
|
24
|
+
# React Native 0.87 and 0.88 add a third: they build the pod straight into the
|
|
25
|
+
# shared products dir and rewrite the app's references to its module map, but
|
|
26
|
+
# name the file after the pod (livevoice-sdk-react-native) instead of its
|
|
27
|
+
# module (livevoice_sdk_react_native), so the app's build cannot find it.
|
|
28
|
+
#
|
|
29
|
+
# React Native 0.89 fixes all three (facebook/react-native#58781). This
|
|
30
|
+
# backports that fix for this pod only, from the podspec, so apps need no
|
|
31
|
+
# Podfile change; with Expo, prebuild would discard one anyway. It does
|
|
32
|
+
# nothing when React Native already has the fix.
|
|
33
|
+
|
|
34
|
+
module LiveVoiceSPMBackport
|
|
35
|
+
EMBED_FUNCTION = 'livevoice_install_spm_framework'
|
|
36
|
+
SIGNATURE_PHASE_NAME = '[LV] Remove duplicate Swift package xcframework signatures'
|
|
37
|
+
|
|
38
|
+
# Taken from React Native 0.89's install_spm_framework: embeds framework $1
|
|
39
|
+
# from where Xcode puts binary targets, if it is a dynamic one.
|
|
40
|
+
EMBED_FUNCTION_SOURCE = <<~'SH'
|
|
41
|
+
livevoice_install_spm_framework()
|
|
42
|
+
{
|
|
43
|
+
local dir
|
|
44
|
+
for dir in "${PODS_CONFIGURATION_BUILD_DIR}" "${PODS_CONFIGURATION_BUILD_DIR}/PackageFrameworks" "${OBJROOT}/UninstalledProducts/${PLATFORM_NAME}"; do
|
|
45
|
+
if [ -d "$dir/$1.framework" ]; then
|
|
46
|
+
if file -b "$dir/$1.framework/$1" | grep -q "dynamically linked"; then
|
|
47
|
+
install_framework "$dir/$1.framework"
|
|
48
|
+
fi
|
|
49
|
+
return
|
|
50
|
+
fi
|
|
51
|
+
done
|
|
52
|
+
}
|
|
53
|
+
SH
|
|
54
|
+
|
|
55
|
+
# The installed React Native embeds Swift package frameworks itself.
|
|
56
|
+
def self.native_support?
|
|
57
|
+
defined?(SPMManager) && SPMManager.const_defined?(:EMBED_FUNCTION)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Hooks into React Native's own post-install step for `pod_name`.
|
|
61
|
+
def self.install(pod_name:, frameworks:, requirement_comment:)
|
|
62
|
+
return if native_support? || !defined?(SPMManager)
|
|
63
|
+
|
|
64
|
+
@pods ||= {}
|
|
65
|
+
@pods[pod_name] = { frameworks: frameworks, comment: requirement_comment }
|
|
66
|
+
SPMManager.prepend(Hook) unless SPMManager.ancestors.include?(Hook)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def self.pods
|
|
70
|
+
@pods || {}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
module Hook
|
|
74
|
+
def apply_on_post_install(installer)
|
|
75
|
+
super
|
|
76
|
+
LiveVoiceSPMBackport.pods.each do |pod_name, info|
|
|
77
|
+
LiveVoiceSPMBackport.embed_frameworks(installer, pod_name, info)
|
|
78
|
+
if LiveVoiceSPMBackport.built_into_products_dir?(installer.pods_project, pod_name)
|
|
79
|
+
# One copy of everything, signatures included: nothing to remove.
|
|
80
|
+
LiveVoiceSPMBackport.fix_modulemap_references(installer, pod_name)
|
|
81
|
+
else
|
|
82
|
+
LiveVoiceSPMBackport.remove_duplicate_signatures(installer.pods_project, pod_name)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def self.embed_frameworks(installer, pod_name, info)
|
|
89
|
+
installer.aggregate_targets.each do |aggregate_target|
|
|
90
|
+
next unless aggregate_target.pod_targets.any? { |t| t.name == pod_name }
|
|
91
|
+
|
|
92
|
+
script_path = aggregate_target.embed_frameworks_script_path
|
|
93
|
+
script = File.exist?(script_path) ? File.read(script_path) : nil
|
|
94
|
+
next if script&.include?("#{EMBED_FUNCTION}()")
|
|
95
|
+
|
|
96
|
+
# A project that already gets the frameworks into the app keeps its own
|
|
97
|
+
# way, so nothing is copied twice.
|
|
98
|
+
if embedded_elsewhere?(aggregate_target, script, info[:frameworks])
|
|
99
|
+
::Pod::UI.puts "[LiveVoice] #{aggregate_target.name} already embeds #{info[:frameworks].join(', ')}"
|
|
100
|
+
next
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
anchor = /^if \[ "\$\{COCOAPODS_PARALLEL_CODE_SIGN\}" == "true" \]; then$/
|
|
104
|
+
unless script&.match?(anchor)
|
|
105
|
+
# Failing here beats an app that installs and then crashes at launch.
|
|
106
|
+
raise ::Pod::Informative, <<~MSG
|
|
107
|
+
[LiveVoice] Cannot embed #{info[:frameworks].join(' and ')} in #{aggregate_target.name}:
|
|
108
|
+
#{script.nil? ? "#{script_path} does not exist" : "#{script_path} does not have the expected CocoaPods layout"}.
|
|
109
|
+
Without them the app fails to launch with dyld "Library not loaded".
|
|
110
|
+
Embed them another way, for example by adding the LiveVoiceSDK Swift package
|
|
111
|
+
product to the app target, or move to React Native 0.89 or later, which embeds
|
|
112
|
+
them itself.
|
|
113
|
+
MSG
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# The comment names the version, so a version change rewrites this
|
|
117
|
+
# script, an input of the embed phase, and the phase runs again.
|
|
118
|
+
calls = info[:frameworks].map { |name| "#{EMBED_FUNCTION} \"#{name}\"\n" }.join
|
|
119
|
+
File.write(script_path, script.sub(anchor) { "#{EMBED_FUNCTION_SOURCE}# #{info[:comment]}\n#{calls}#{$&}" })
|
|
120
|
+
::Pod::UI.puts "[LiveVoice] Embedding #{info[:frameworks].join(', ')} in #{aggregate_target.name}"
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# The app target uses the LiveVoiceSDK package product itself, so Xcode
|
|
125
|
+
# embeds its frameworks, or the embed script already installs them.
|
|
126
|
+
def self.embedded_elsewhere?(aggregate_target, script, frameworks)
|
|
127
|
+
by_package = aggregate_target.user_targets.any? do |target|
|
|
128
|
+
target.respond_to?(:package_product_dependencies) &&
|
|
129
|
+
target.package_product_dependencies.any? { |d| d.product_name == 'LiveVoiceSDK' }
|
|
130
|
+
end
|
|
131
|
+
by_script = !script.nil? && frameworks.all? { |name| script.include?("/#{name}.framework\"") }
|
|
132
|
+
by_package || by_script
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# React Native 0.87 and later build a static pod with a Swift package
|
|
136
|
+
# straight into the shared products dir.
|
|
137
|
+
def self.built_into_products_dir?(project, pod_name)
|
|
138
|
+
target = project.targets.find { |t| t.name == pod_name }
|
|
139
|
+
!target.nil? && target.build_configurations.all? do |config|
|
|
140
|
+
config.build_settings['CONFIGURATION_BUILD_DIR'] == '${PODS_CONFIGURATION_BUILD_DIR}'
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Points the app's -fmodule-map-file flags at the module map where the pod
|
|
145
|
+
# now builds it. Like React Native 0.89, this changes the in-memory xcconfig
|
|
146
|
+
# attributes, because later post-install steps save the same objects again.
|
|
147
|
+
def self.fix_modulemap_references(installer, pod_name)
|
|
148
|
+
pod_target = installer.pod_targets.find { |t| t.name == pod_name }
|
|
149
|
+
return if pod_target.nil?
|
|
150
|
+
|
|
151
|
+
module_name = pod_target.product_module_name
|
|
152
|
+
installer.aggregate_targets.each do |aggregate_target|
|
|
153
|
+
next unless aggregate_target.pod_targets.include?(pod_target)
|
|
154
|
+
|
|
155
|
+
aggregate_target.xcconfigs.each do |config_name, config_file|
|
|
156
|
+
changed = false
|
|
157
|
+
%w[OTHER_CFLAGS OTHER_SWIFT_FLAGS].each do |key|
|
|
158
|
+
value = config_file.attributes[key]
|
|
159
|
+
next unless value
|
|
160
|
+
|
|
161
|
+
updated = value
|
|
162
|
+
.gsub("${PODS_CONFIGURATION_BUILD_DIR}/#{pod_name}/#{module_name}.modulemap",
|
|
163
|
+
"${PODS_CONFIGURATION_BUILD_DIR}/#{module_name}.modulemap")
|
|
164
|
+
.gsub("${PODS_CONFIGURATION_BUILD_DIR}/#{pod_name}.modulemap",
|
|
165
|
+
"${PODS_CONFIGURATION_BUILD_DIR}/#{module_name}.modulemap")
|
|
166
|
+
next if updated == value
|
|
167
|
+
|
|
168
|
+
config_file.attributes[key] = updated
|
|
169
|
+
changed = true
|
|
170
|
+
end
|
|
171
|
+
config_file.save_as(aggregate_target.xcconfig_path(config_name)) if changed
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def self.remove_duplicate_signatures(project, pod_name)
|
|
177
|
+
target = project.targets.find { |t| t.name == pod_name }
|
|
178
|
+
return if target.nil? || target.shell_script_build_phases.any? { |p| p.name == SIGNATURE_PHASE_NAME }
|
|
179
|
+
|
|
180
|
+
# A fresh UUID that is really unused: Pod::Project's generator skips the
|
|
181
|
+
# check and can collide during post_install (see React Native's spm.rb).
|
|
182
|
+
uuid = project.generate_uuid
|
|
183
|
+
uuid = project.generate_uuid while project.objects_by_uuid.key?(uuid)
|
|
184
|
+
phase = Xcodeproj::Project::Object::PBXShellScriptBuildPhase.new(project, uuid)
|
|
185
|
+
phase.initialize_defaults
|
|
186
|
+
phase.name = SIGNATURE_PHASE_NAME
|
|
187
|
+
# Removes only copies that also exist in the shared products dir, so the
|
|
188
|
+
# only copy stays if the pod is built there after all (for example by the
|
|
189
|
+
# app's own Podfile, after this ran).
|
|
190
|
+
phase.shell_script = <<~'SH'
|
|
191
|
+
for signature in "${CONFIGURATION_BUILD_DIR}"/*.xcframework-*.signature; do
|
|
192
|
+
[ -e "$signature" ] || continue
|
|
193
|
+
[ "${CONFIGURATION_BUILD_DIR}" != "${PODS_CONFIGURATION_BUILD_DIR}" ] || continue
|
|
194
|
+
if [ -e "${PODS_CONFIGURATION_BUILD_DIR}/$(basename "$signature")" ]; then
|
|
195
|
+
rm -f "$signature"
|
|
196
|
+
fi
|
|
197
|
+
done
|
|
198
|
+
SH
|
|
199
|
+
phase.always_out_of_date = '1'
|
|
200
|
+
target.build_phases << phase
|
|
201
|
+
end
|
|
202
|
+
end
|