Skip to content

Commit 530573a

Browse files
authored
feat: drop SDWebImage, implement svg decoder (#427)
* feat: drop sdwebimage, implement svg decoder * fix: properly retrive RCTImageLoader * fix: simplify the svg decoder * fix: remove static frameworks from expo template * fix: retain cycle
1 parent 6f87ff1 commit 530573a

22 files changed

+478
-162
lines changed

.changeset/sour-cases-appear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-native-bottom-tabs': minor
3+
---
4+
5+
feat: drop SDWebImage, resolve bunch of build issues

CONTRIBUTING.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,7 @@ To run the React Native example app on Android:
3939
yarn workspace react-native-bottom-tabs-example android
4040
```
4141

42-
To run the React Native example app on iOS:
43-
44-
Make sure to install [`cocoapods-swift-modular-headers`](https://github.com/callstack/cocoapods-swift-modular-headers) gem, otherwise `pod install` will fail.
45-
46-
```sh
47-
gem install cocoapods-swift-modular-headers
48-
```
49-
50-
Next you can install cocoapods.
42+
To run the React Native example app on iOS, you need to install cocoapods.
5143

5244
```sh
5345
cd apps/example/ios

apps/example/ios/Podfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
plugin 'cocoapods-swift-modular-headers'
1+
ENV['RCT_NEW_ARCH_ENABLED'] = '1'
22

33
ws_dir = Pathname.new(__dir__)
44
ws_dir = ws_dir.parent until
@@ -8,6 +8,4 @@ require "#{ws_dir}/node_modules/react-native-test-app/test_app.rb"
88

99
workspace 'ReactNativeBottomTabsExample.xcworkspace'
1010

11-
apply_modular_headers_for_swift_dependencies()
12-
1311
use_test_app! :hermes_enabled => true, :fabric_enabled => true

apps/example/ios/Podfile.lock

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,37 @@ PODS:
17481748
- React-RCTFBReactNativeSpec
17491749
- ReactCommon/turbomodule/core
17501750
- SocketRocket
1751-
- react-native-bottom-tabs (0.11.1):
1751+
- react-native-bottom-tabs (0.11.2):
1752+
- boost
1753+
- DoubleConversion
1754+
- fast_float
1755+
- fmt
1756+
- glog
1757+
- hermes-engine
1758+
- RCT-Folly
1759+
- RCT-Folly/Fabric
1760+
- RCTRequired
1761+
- RCTTypeSafety
1762+
- React-Core
1763+
- React-debug
1764+
- React-Fabric
1765+
- React-featureflags
1766+
- React-graphics
1767+
- React-ImageManager
1768+
- React-jsi
1769+
- react-native-bottom-tabs/common (= 0.11.2)
1770+
- React-NativeModulesApple
1771+
- React-RCTFabric
1772+
- React-renderercss
1773+
- React-rendererdebug
1774+
- React-utils
1775+
- ReactCodegen
1776+
- ReactCommon/turbomodule/bridging
1777+
- ReactCommon/turbomodule/core
1778+
- SocketRocket
1779+
- SwiftUIIntrospect (~> 1.0)
1780+
- Yoga
1781+
- react-native-bottom-tabs/common (0.11.2):
17521782
- boost
17531783
- DoubleConversion
17541784
- fast_float
@@ -1774,8 +1804,6 @@ PODS:
17741804
- ReactCodegen
17751805
- ReactCommon/turbomodule/bridging
17761806
- ReactCommon/turbomodule/core
1777-
- SDWebImage (>= 5.19.1)
1778-
- SDWebImageSVGCoder (>= 1.7.0)
17791807
- SocketRocket
17801808
- SwiftUIIntrospect (~> 1.0)
17811809
- Yoga
@@ -2520,11 +2548,6 @@ PODS:
25202548
- ReactCommon/turbomodule/core
25212549
- SocketRocket
25222550
- Yoga
2523-
- SDWebImage (5.21.1):
2524-
- SDWebImage/Core (= 5.21.1)
2525-
- SDWebImage/Core (5.21.1)
2526-
- SDWebImageSVGCoder (1.8.0):
2527-
- SDWebImage/Core (~> 5.6)
25282551
- SocketRocket (0.7.1)
25292552
- SwiftUIIntrospect (1.3.0)
25302553
- Yoga (0.0.0)
@@ -2614,8 +2637,6 @@ DEPENDENCIES:
26142637

26152638
SPEC REPOS:
26162639
trunk:
2617-
- SDWebImage
2618-
- SDWebImageSVGCoder
26192640
- SocketRocket
26202641
- SwiftUIIntrospect
26212642

@@ -2821,7 +2842,7 @@ SPEC CHECKSUMS:
28212842
React-logger: a3cb5b29c32b8e447b5a96919340e89334062b48
28222843
React-Mapbuffer: 9d2434a42701d6144ca18f0ca1c4507808ca7696
28232844
React-microtasksnativemodule: 75b6604b667d297292345302cc5bfb6b6aeccc1b
2824-
react-native-bottom-tabs: fa973f009e321d7d11dbdb761192ce185948a05a
2845+
react-native-bottom-tabs: d71dd2e1b69f11d3ed2da2db23016ebdc77f4ba1
28252846
react-native-safe-area-context: c6e2edd1c1da07bdce287fa9d9e60c5f7b514616
28262847
React-NativeModulesApple: 879fbdc5dcff7136abceb7880fe8a2022a1bd7c3
28272848
React-oscompat: 93b5535ea7f7dff46aaee4f78309a70979bdde9d
@@ -2859,12 +2880,10 @@ SPEC CHECKSUMS:
28592880
RNGestureHandler: 3a73f098d74712952870e948b3d9cf7b6cae9961
28602881
RNScreens: 0bbf16c074ae6bb1058a7bf2d1ae017f4306797c
28612882
RNVectorIcons: c13cc1db346e960ecd0aafcdd5d0bb458133b9c1
2862-
SDWebImage: f29024626962457f3470184232766516dee8dfea
2863-
SDWebImageSVGCoder: 8e10c8f6cc879c7dfb317b284e13dd589379f01c
28642883
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
28652884
SwiftUIIntrospect: fee9aa07293ee280373a591e1824e8ddc869ba5d
28662885
Yoga: a3ed390a19db0459bd6839823a6ac6d9c6db198d
28672886

2868-
PODFILE CHECKSUM: e4dd5fac8fa6e00534aac80dc857efbb13ef2723
2887+
PODFILE CHECKSUM: d61a3255405492afdb755f6ddd335fd0f5a84cd3
28692888

28702889
COCOAPODS: 1.16.2

docs/docs/docs/getting-started/quick-start.mdx

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,6 @@ If you are going to use [React Navigation / Expo Router Integration](/docs/guide
1919

2020
<PackageManagerTabs command="install @bottom-tabs/react-navigation" />
2121

22-
<details>
23-
<summary>If you use React Native <b>version 0.75 or lower</b></summary>
24-
25-
- For `@react-native-community/cli` users, open Podfile in ios folder and change minimum iOS version to `14.0` before `pod install`
26-
27-
```diff
28-
- platform :ios, min_ios_version_supported
29-
+ platform :ios, '14.0'
30-
```
31-
32-
- For Expo users, install `expo-build-properties`, open app.json file and update `deploymentTarget` for `ios` as below
33-
34-
```json
35-
{
36-
"expo": {
37-
"plugins": [
38-
[
39-
"expo-build-properties",
40-
{
41-
"ios": {
42-
"deploymentTarget": "14.0"
43-
}
44-
}
45-
]
46-
],
47-
}
48-
}
49-
```
50-
51-
</details>
52-
53-
5422

5523
### Expo
5624

@@ -64,53 +32,6 @@ Add the library plugin in your `app.json` config file and [create a new build](h
6432
}
6533
```
6634

67-
Then install `expo-build-properties` to enable static linking for iOS by adding `"useFrameworks": "static"` in the plugin.
68-
69-
```sh
70-
npx expo install expo-build-properties
71-
```
72-
73-
```diff
74-
{
75-
"expo": {
76-
"plugins": [
77-
"react-native-bottom-tabs",
78-
+ [
79-
+ "expo-build-properties",
80-
+ {
81-
+ "ios": {
82-
+ "useFrameworks": "static"
83-
+ }
84-
+ }
85-
+ ]
86-
+ ]
87-
}
88-
}
89-
```
90-
91-
Alternatively, you can avoid enabling static linking (which can cause problems with your existing packages) by adding the following in the `expo-build-properties` plugin.
92-
93-
```diff
94-
{
95-
"expo": {
96-
"plugins": [
97-
"react-native-bottom-tabs",
98-
+ [
99-
+ "expo-build-properties",
100-
+ {
101-
+ "ios": {
102-
+ "extraPods": [
103-
+ { name: "SDWebImage", modular_headers: true }, // Work around for not enabling static framework, required for react-native-bottom-tabs
104-
+ { name: "SDWebImageSVGCoder", modular_headers: true }
105-
+ ]
106-
+ }
107-
+ }
108-
+ ]
109-
+ ]
110-
}
111-
}
112-
```
113-
11435
:::warning
11536

11637
This library is not supported in [Expo Go](https://expo.dev/go).
@@ -133,12 +54,6 @@ Edit `android/app/src/main/res/values/styles.xml` to inherit from provided theme
13354

13455
Here you can read more about [Android Native Styling](/docs/guides/android-native-styling).
13556

136-
To enable static linking for iOS, Open the `./ios/Podfile` file and add the following:
137-
138-
```ruby
139-
use_frameworks! :linkage => :static
140-
```
141-
14257

14358
## Example usage
14459

packages/expo-template/app.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@
3333
"resizeMode": "contain",
3434
"backgroundColor": "#ffffff"
3535
}
36-
],
37-
[
38-
"expo-build-properties",
39-
{
40-
"ios": {
41-
"useFrameworks": "static"
42-
}
43-
}
4436
]
4537
],
4638
"experiments": {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#ifdef __cplusplus
2+
3+
#pragma once
4+
5+
#include <react/renderer/components/RNCTabView/RNCTabViewShadowNode.h>
6+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
7+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
8+
9+
namespace facebook::react {
10+
11+
class RNCTabViewComponentDescriptor final
12+
: public ConcreteComponentDescriptor<RNCTabViewShadowNode> {
13+
public:
14+
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
15+
16+
void adopt(ShadowNode& shadowNode) const override {
17+
ConcreteComponentDescriptor::adopt(shadowNode);
18+
19+
#if !defined(ANDROID)
20+
auto &tabViewShadowNode =
21+
static_cast<RNCTabViewShadowNode&>(shadowNode);
22+
23+
std::weak_ptr<void> imageLoader =
24+
contextContainer_->at<std::shared_ptr<void>>("RCTImageLoader");
25+
tabViewShadowNode.setImageLoader(imageLoader);
26+
#endif
27+
}
28+
};
29+
30+
31+
} // namespace facebook::react
32+
33+
#endif
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <react/renderer/components/RNCTabView/RNCTabViewShadowNode.h>
2+
3+
namespace facebook::react {
4+
5+
extern const char RNCTabViewComponentName[] = "RNCTabView";
6+
7+
void RNCTabViewShadowNode::setImageLoader(
8+
std::weak_ptr<void> imageLoader) {
9+
getStateDataMutable().setImageLoader(imageLoader);
10+
}
11+
12+
RNCTabViewShadowNode::StateData &
13+
RNCTabViewShadowNode::getStateDataMutable() {
14+
ensureUnsealed();
15+
return const_cast<RNCTabViewShadowNode::StateData &>(getStateData());
16+
}
17+
18+
19+
} // namespace facebook::react
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#ifdef __cplusplus
2+
3+
#pragma once
4+
5+
#include <react/renderer/components/RNCTabView/EventEmitters.h>
6+
#include <react/renderer/components/RNCTabView/Props.h>
7+
#include <react/renderer/components/RNCTabView/RNCTabViewState.h>
8+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
9+
#include <jsi/jsi.h>
10+
11+
namespace facebook::react {
12+
13+
JSI_EXPORT extern const char RNCTabViewComponentName[];
14+
15+
/*
16+
* `ShadowNode` for <RNCTabView> component.
17+
*/
18+
class JSI_EXPORT RNCTabViewShadowNode final: public ConcreteViewShadowNode<
19+
RNCTabViewComponentName,
20+
RNCTabViewProps,
21+
RNCTabViewEventEmitter,
22+
RNCTabViewState> {
23+
24+
public:
25+
using ConcreteViewShadowNode::ConcreteViewShadowNode;
26+
using StateData = ConcreteViewShadowNode::ConcreteStateData;
27+
28+
void setImageLoader(std::weak_ptr<void> imageLoader);
29+
30+
StateData &getStateDataMutable();
31+
};
32+
33+
}
34+
35+
#endif
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <react/renderer/components/RNCTabView/RNCTabViewState.h>
2+
3+
namespace facebook::react {
4+
5+
void RNCTabViewState::setImageLoader(
6+
std::weak_ptr<void> imageLoader) {
7+
imageLoader_ = imageLoader;
8+
}
9+
10+
std::weak_ptr<void> RNCTabViewState::getImageLoader()
11+
const noexcept {
12+
return imageLoader_;
13+
}
14+
15+
} // namespace facebook::react

0 commit comments

Comments
 (0)