@datadog/mobile-react-native-webview 3.12.0 → 3.13.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.
@@ -2,6 +2,62 @@ require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
4
 
5
+ # /!\ Remember to keep this version in sync with DatadogSDKReactNative.podspec
6
+ datadog_ios_version = '3.21.0'
7
+ datadog_ios_spm_url = 'https://github.com/DataDog/dd-sdk-ios.git'
8
+
9
+ # The native iOS SDK is resolved through Swift Package Manager, using React Native's
10
+ # `spm_dependency` podspec helper. This requires React Native >= 0.75. Pods can be linked statically
11
+ # or as frameworks (see DatadogSDKReactNative.podspec for how static linkage is handled).
12
+ if !respond_to?(:spm_dependency, true)
13
+ raise "Datadog: the native iOS SDK is resolved through Swift Package Manager, which requires " \
14
+ "React Native >= 0.75 -- the first version to ship the `spm_dependency` podspec helper."
15
+ end
16
+
17
+ # How the app links pods (`use_frameworks!`): React Native's `use_react_native!` records it for the
18
+ # app's target in USE_FRAMEWORKS, which React Native's own podspecs read too.
19
+ uses_frameworks = !ENV['USE_FRAMEWORKS'].nil?
20
+ # Only with dynamic frameworks does Xcode build DatadogInternal as a framework of its own. When pods
21
+ # are linked statically its code is in DatadogSDKReactNative's archive instead, which requests
22
+ # every Datadog product then (see DatadogSDKReactNative.podspec).
23
+ uses_dynamic_frameworks = ENV['USE_FRAMEWORKS'] == 'dynamic'
24
+
25
+ # USE_FRAMEWORKS says how the app asked pods to be linked, not how this pod ends up being built.
26
+ # Expo 57 and later, with precompiled modules (the default), build every pod that depends on
27
+ # React-Core as a static library even under `use_frameworks!` -- this one and react-native-webview
28
+ # included -- and decide it in a pre-install step, after this podspec has been read. Expo 58 keeps
29
+ # pods that use `spm_dependency` as dynamic frameworks, but only for dynamic linkage. When this pod
30
+ # ends up a static library, the react-native-webview dependency declared below for frameworks fails
31
+ # `pod install` ("The Swift pod `DatadogSDKReactNativeWebView` depends upon `react-native-webview`,
32
+ # which does not define modules"), and it is not needed: a static library resolves the headers through
33
+ # HEADER_SEARCH_PATHS and leaves linking to the app, as without `use_frameworks!`. So just before
34
+ # CocoaPods validates the targets, when every pod's build type is final, drop that dependency from
35
+ # this pod if it is built as a static library. A framework keeps it.
36
+ unless Pod::Installer.method_defined?(:datadog_drop_static_webview_dependency)
37
+ Pod::Installer.prepend(Module.new do
38
+ def datadog_drop_static_webview_dependency
39
+ pod_targets.each do |target|
40
+ next unless target.pod_name == 'DatadogSDKReactNativeWebView' && !target.build_as_framework?
41
+
42
+ dependencies = target.dependent_targets_by_config
43
+ next unless dependencies.each_value.any? { |deps| deps.any? { |dep| dep.pod_name == 'react-native-webview' } }
44
+
45
+ target.dependent_targets_by_config = dependencies.transform_values do |deps|
46
+ deps.reject { |dep| dep.pod_name == 'react-native-webview' }
47
+ end
48
+ # CocoaPods caches the transitive dependencies, which later steps read.
49
+ target.remove_instance_variable(:@recursive_dependent_targets) if target.instance_variable_defined?(:@recursive_dependent_targets)
50
+ Pod::UI.puts "[Datadog] #{target.name} is built as a static library, so it does not depend on react-native-webview"
51
+ end
52
+ end
53
+
54
+ def validate_targets
55
+ datadog_drop_static_webview_dependency
56
+ super
57
+ end
58
+ end)
59
+ end
60
+
5
61
  Pod::Spec.new do |s|
6
62
  s.name = "DatadogSDKReactNativeWebView"
7
63
  s.version = package["version"]
@@ -10,34 +66,84 @@ Pod::Spec.new do |s|
10
66
  s.license = package["license"]
11
67
  s.authors = package["author"]
12
68
 
13
- s.platforms = { :ios => "12.0", :tvos => "12.0" }
69
+ s.platforms = { :ios => "15.0", :tvos => "15.0" }
14
70
  s.source = { :git => "https://github.com/DataDog/dd-sdk-reactnative.git", :tag => "#{s.version}" }
15
71
 
16
72
 
17
73
  s.source_files = "ios/Sources/*.{h,m,mm,swift}"
18
74
 
19
75
  s.dependency "React-Core"
76
+ s.dependency 'DatadogSDKReactNative'
20
77
 
21
- if ENV['USE_FRAMEWORKS'] == 'static'
78
+ # Our headers subclass RNCWebViewImpl / RNCWebViewManager. Under framework linkage those headers
79
+ # are only reachable as <react_native_webview/...>, which requires react-native-webview to be a
80
+ # declared dependency so that CocoaPods puts its build directory on this target's
81
+ # FRAMEWORK_SEARCH_PATHS. Static libraries find them through HEADER_SEARCH_PATHS below instead,
82
+ # and declaring it there fails `pod install`: react-native-webview does not define modules, which
83
+ # a Swift static library's dependencies must. Under `use_frameworks!` this pod can still end up a
84
+ # static library (Expo's precompiled modules): see datadog_drop_static_webview_dependency above.
85
+ if uses_frameworks
22
86
  s.dependency "react-native-webview"
23
87
  end
24
88
 
25
- # /!\ Remember to keep the version in sync with DatadogSDKReactNative.podspec
26
- s.dependency 'DatadogWebViewTracking', '3.16.1'
27
- s.dependency 'DatadogInternal', '3.16.1'
28
- s.dependency 'DatadogSDKReactNative'
89
+ # DatadogInternal was previously declared explicitly here, but it is an internal target of
90
+ # dd-sdk-ios rather than an exported SPM product, so it cannot be requested. Making it
91
+ # importable takes an extra search path -- see the FRAMEWORK_SEARCH_PATHS note below. Compiling
92
+ # is not enough to link it, though: unlike DatadogCore and DatadogSessionReplay, the
93
+ # DatadogWebViewTracking product's own autolink metadata does not pull DatadogInternal onto this
94
+ # target's link line, so RCTDatadogWebViewTracking.swift's direct references to
95
+ # DatadogInternal.CoreRegistry and DatadogCoreProtocol are left unresolved at link time
96
+ # ("Undefined symbols ... DatadogInternal.CoreRegistry...") unless we link it explicitly too.
97
+ spm_dependency(s,
98
+ url: datadog_ios_spm_url,
99
+ requirement: { kind: 'exactVersion', version: datadog_ios_version },
100
+ products: ['DatadogWebViewTracking']
101
+ )
29
102
 
30
103
  s.test_spec 'Tests' do |test_spec|
31
104
  test_spec.dependency "react-native-webview"
32
105
  test_spec.dependency "React-RCTText"
33
-
106
+
34
107
  test_spec.source_files = 'ios/Tests/*.swift'
35
- test_spec.platforms = { :ios => "13.4", :tvos => "13.4" }
108
+ test_spec.platforms = { :ios => "15.0", :tvos => "15.0" }
109
+
110
+ # The tests reach DatadogInternal directly, which is not on this target's link line because it
111
+ # is a target of dd-sdk-ios rather than one of the SPM products this pod requests.
112
+ if uses_dynamic_frameworks
113
+ test_spec.pod_target_xcconfig = {
114
+ 'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(SYMROOT)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/PackageFrameworks"',
115
+ 'OTHER_LDFLAGS' => '$(inherited) -framework DatadogInternal'
116
+ }
117
+ end
36
118
  end
37
119
 
120
+ # DatadogInternal is an internal target of dd-sdk-ios rather than an exported product, so
121
+ # SwiftPM builds it into PackageFrameworks/ instead of emitting a bare .swiftmodule alongside
122
+ # the products. React Native's `spm_dependency` helper only appends the products directory to
123
+ # SWIFT_INCLUDE_PATHS, which leaves the module invisible to the compiler. Our sources import it
124
+ # for AnyEncodable, CoreRegistry, DatadogCoreProtocol and FeatureScope, so add the directory
125
+ # holding the package frameworks explicitly.
126
+ #
127
+ # Note this cannot be written against BUILT_PRODUCTS_DIR: CocoaPods gives every pod target its
128
+ # own CONFIGURATION_BUILD_DIR, so for this target BUILT_PRODUCTS_DIR is
129
+ # <symroot>/<config><platform>/DatadogSDKReactNative, one level below where SwiftPM actually
130
+ # writes PackageFrameworks/. Spelling it as SYMROOT/CONFIGURATION+EFFECTIVE_PLATFORM_NAME
131
+ # matches what `spm_dependency` itself uses for SWIFT_INCLUDE_PATHS.
132
+ #
133
+ # Archive builds lay this out differently: PackageFrameworks/ stays empty and the package
134
+ # frameworks are linked straight into the products directory itself, so search that too.
135
+ datadog_spm_xcconfig = {
136
+ 'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(SYMROOT)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/PackageFrameworks" "$(SYMROOT)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"'
137
+ }
138
+
38
139
  xcconfig = {
39
140
  "HEADER_SEARCH_PATHS" => "$(PODS_ROOT)/react-native-webview/**"
40
141
  }
142
+ if uses_dynamic_frameworks
143
+ xcconfig["OTHER_LDFLAGS"] = "$(inherited) -framework DatadogInternal"
144
+ end
145
+
146
+ xcconfig.merge!(datadog_spm_xcconfig)
41
147
 
42
148
  # This guard prevents installing the dependencies when we run `pod install` in the old architecture.
43
149
  # The `install_modules_dependencies` function is only available from RN 0.71, the new architecture is not
@@ -50,8 +156,13 @@ Pod::Spec.new do |s|
50
156
  "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
51
157
  })
52
158
 
159
+ # Assign before install_modules_dependencies: the helper reads the spec's current
160
+ # pod_target_xcconfig, merges React Native's own header search paths and C++ settings into it
161
+ # and assigns the result back, so assigning afterwards would drop everything it added.
162
+ s.pod_target_xcconfig = xcconfig
163
+
53
164
  install_modules_dependencies(s)
165
+ else
166
+ s.pod_target_xcconfig = xcconfig
54
167
  end
55
-
56
- s.pod_target_xcconfig = xcconfig
57
168
  end
package/README.md CHANGED
@@ -20,6 +20,8 @@ Set up the RUM Browser SDK on the web page you want rendered on your mobile Reac
20
20
 
21
21
  Add `react-native-webview` to your application following the [official installation documentation][4].
22
22
 
23
+ **Minimum React Native version**: React Native 0.75 or higher. The native iOS SDK is resolved through Swift Package Manager, which needs React Native 0.75 or higher.
24
+
23
25
  ### Instrument your web views
24
26
 
25
27
  Import `WebView` from `@datadog/mobile-react-native-webview` instead of `react-native-webview`:
@@ -205,7 +205,7 @@ dependencies {
205
205
  implementation "com.facebook.react:react-android:$reactNativeVersion"
206
206
  }
207
207
 
208
- implementation "com.datadoghq:dd-sdk-android-webview:3.15.0"
208
+ implementation "com.datadoghq:dd-sdk-android-webview:3.16.0"
209
209
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
210
210
 
211
211
  implementation project(path: ':datadog_mobile-react-native')
@@ -9,4 +9,13 @@
9
9
 
10
10
  #import "RCTDatadogWebView.h"
11
11
  #import "RCTDatadogWebViewManager.h"
12
+ // react-native-webview is a static library under CocoaPods' default linkage, where its public
13
+ // headers land flat in Pods/Headers/Public and resolve as a quoted import. When the pod is built
14
+ // as a dynamic framework instead -- which is mandatory when the native Datadog iOS SDK is resolved
15
+ // through Swift Package Manager -- the same header is only reachable
16
+ // as <react_native_webview/RNCWebViewImpl.h>. Support both layouts.
17
+ #if __has_include(<react_native_webview/RNCWebViewImpl.h>)
18
+ #import <react_native_webview/RNCWebViewImpl.h>
19
+ #else
12
20
  #import "RNCWebViewImpl.h"
21
+ #endif
@@ -4,7 +4,16 @@
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
6
 
7
+ // react-native-webview is a static library under CocoaPods' default linkage, where its public
8
+ // headers land flat in Pods/Headers/Public and resolve as a quoted import. When the pod is built
9
+ // as a dynamic framework instead -- which is mandatory when the native Datadog iOS SDK is resolved
10
+ // through Swift Package Manager -- the same header is only reachable
11
+ // as <react_native_webview/RNCWebViewImpl.h>. Support both layouts.
12
+ #if __has_include(<react_native_webview/RNCWebViewImpl.h>)
13
+ #import <react_native_webview/RNCWebViewImpl.h>
14
+ #else
7
15
  #import "RNCWebViewImpl.h"
16
+ #endif
8
17
 
9
18
  @class RCTDatadogWebView;
10
19
 
@@ -14,8 +23,8 @@
14
23
 
15
24
  @interface RCTDatadogWebView : RNCWebViewImpl
16
25
 
17
- @property (nonatomic, weak) id<RCTDatadogWebViewDelegate> ddWebViewDelegate;
18
- @property (nonatomic, assign) BOOL isTrackingEnabled;
26
+ @property(nonatomic, weak) id<RCTDatadogWebViewDelegate> ddWebViewDelegate;
27
+ @property(nonatomic, assign) BOOL isTrackingEnabled;
19
28
 
20
- - (WKWebView*) getWKWebView;
29
+ - (WKWebView *)getWKWebView;
21
30
  @end
@@ -4,7 +4,14 @@
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
6
 
7
+ // See the note in RCTDatadogWebView.h: this header resolves as a quoted import under CocoaPods'
8
+ // default static linkage, but only as <react_native_webview/...> when the pod is built as a
9
+ // dynamic framework.
10
+ #if __has_include(<react_native_webview/RNCWebViewManager.h>)
11
+ #import <react_native_webview/RNCWebViewManager.h>
12
+ #else
7
13
  #import "RNCWebViewManager.h"
14
+ #endif
8
15
 
9
16
  @interface RCTDatadogWebViewManager : RNCWebViewManager
10
17
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native-webview",
3
- "version": "3.12.0",
3
+ "version": "3.13.0",
4
4
  "description": "A client-side React Native module to interact with react-native-webview and Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -54,7 +54,7 @@
54
54
  "peerDependencies": {
55
55
  "@datadog/mobile-react-native": "^3.0.0",
56
56
  "react": ">=16.13.1",
57
- "react-native": ">=0.63.4 <1.0",
57
+ "react-native": ">=0.75.0 <1.0",
58
58
  "react-native-webview": ">=11.0.0"
59
59
  },
60
60
  "jest": {
@@ -94,5 +94,5 @@
94
94
  "javaPackageName": "com.datadog.reactnative.webview"
95
95
  }
96
96
  },
97
- "gitHead": "d0e4c26e84cbd0389d1dd564b02a558ec1563f37"
97
+ "gitHead": "2d61c347c3e70597dcfd19d05a6e5473ad3bac13"
98
98
  }