Skip to content

Commit 6b9072d

Browse files
committed
feat: version 4 with react native 71 upgrade on ios
1 parent 24c4f82 commit 6b9072d

File tree

7 files changed

+54
-131
lines changed

7 files changed

+54
-131
lines changed

ios/Podfile

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
require_relative '../node_modules/react-native/scripts/react_native_pods'
22
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
33

4-
platform :ios, '12.4'
5-
install! 'cocoapods', :deterministic_uuids => false
4+
platform :ios, min_ios_version_supported
5+
prepare_react_native_project!
66

7-
production = ENV["PRODUCTION"] == "1"
7+
# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
8+
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
9+
#
10+
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
11+
# ```js
12+
# module.exports = {
13+
# dependencies: {
14+
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
15+
# ```
16+
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
17+
18+
linkage = ENV['USE_FRAMEWORKS']
19+
if linkage != nil
20+
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
21+
use_frameworks! :linkage => linkage.to_sym
22+
end
823

924
target 'RNTypescriptBoilerplate' do
1025
config = use_native_modules!
@@ -13,12 +28,17 @@ target 'RNTypescriptBoilerplate' do
1328
flags = get_default_flags()
1429

1530
use_react_native!(
16-
:production => production,
1731
:path => config[:reactNativePath],
18-
# to enable hermes on iOS, change `false` to `true` and then install pods
32+
# Hermes is now enabled by default. Disable by setting this flag to false.
33+
# Upcoming versions of React Native may rely on get_default_flags(), but
34+
# we make it explicit here to aid in the React Native upgrade process.
1935
:hermes_enabled => flags[:hermes_enabled],
2036
:fabric_enabled => flags[:fabric_enabled],
21-
:flipper_configuration => FlipperConfiguration.enabled,
37+
# Enables Flipper.
38+
#
39+
# Note that if you have use_frameworks! enabled, Flipper will not work and
40+
# you should disable the next line.
41+
:flipper_configuration => flipper_config,
2242
# An absolute path to your application root.
2343
:app_path => "#{Pod::Config.instance.installation_root}/.."
2444
)
@@ -29,7 +49,12 @@ target 'RNTypescriptBoilerplate' do
2949
end
3050

3151
post_install do |installer|
32-
react_native_post_install(installer)
52+
react_native_post_install(
53+
installer,
54+
# Set `mac_catalyst_enabled` to `true` in order to apply patches
55+
# necessary for Mac Catalyst builds
56+
:mac_catalyst_enabled => false
57+
)
3358
__apply_Xcode_12_5_M1_post_install_workaround(installer)
3459
end
3560
end

ios/RNTypescriptBoilerplate.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@
573573
"$(inherited)",
574574
"@executable_path/Frameworks",
575575
);
576+
MARKETING_VERSION = 1.0;
576577
OTHER_LDFLAGS = (
577578
"$(inherited)",
578579
"-ObjC",
@@ -598,6 +599,7 @@
598599
"$(inherited)",
599600
"@executable_path/Frameworks",
600601
);
602+
MARKETING_VERSION = 1.0;
601603
OTHER_LDFLAGS = (
602604
"$(inherited)",
603605
"-ObjC",
@@ -677,7 +679,6 @@
677679
"-DFOLLY_MOBILE=1",
678680
"-DFOLLY_USE_LIBCPP=1",
679681
);
680-
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
681682
SDKROOT = iphoneos;
682683
};
683684
name = Debug;
@@ -741,7 +742,6 @@
741742
"-DFOLLY_MOBILE=1",
742743
"-DFOLLY_USE_LIBCPP=1",
743744
);
744-
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
745745
SDKROOT = iphoneos;
746746
VALIDATE_PRODUCT = YES;
747747
};

ios/RNTypescriptBoilerplate.xcworkspace/contents.xcworkspacedata

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
#import <React/RCTBridgeDelegate.h>
1+
#import <RCTAppDelegate.h>
22
#import <UIKit/UIKit.h>
33

4-
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
5-
6-
@property (nonatomic, strong) UIWindow *window;
4+
@interface AppDelegate : RCTAppDelegate
75

86
@end
Lines changed: 15 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,22 @@
11
#import "AppDelegate.h"
22

3-
#import <React/RCTBridge.h>
43
#import <React/RCTBundleURLProvider.h>
5-
#import <React/RCTRootView.h>
6-
#import <React/RCTAppSetupUtils.h>
74
#import "RNSplashScreen.h"
85

9-
#if RCT_NEW_ARCH_ENABLED
10-
#import <React/CoreModulesPlugins.h>
11-
#import <React/RCTCxxBridgeDelegate.h>
12-
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
13-
#import <React/RCTSurfacePresenter.h>
14-
#import <React/RCTSurfacePresenterBridgeAdapter.h>
15-
#import <ReactCommon/RCTTurboModuleManager.h>
16-
#import <react/config/ReactNativeConfig.h>
17-
18-
static NSString *const kRNConcurrentRoot = @"concurrentRoot";
19-
20-
@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
21-
RCTTurboModuleManager *_turboModuleManager;
22-
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
23-
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
24-
facebook::react::ContextContainer::Shared _contextContainer;
25-
}
26-
@end
27-
#endif
28-
296
@implementation AppDelegate
307

8+
319
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
3210
{
33-
RCTAppSetupPrepareApp(application);
34-
35-
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
36-
37-
#if RCT_NEW_ARCH_ENABLED
38-
_contextContainer = std::make_shared<facebook::react::ContextContainer const>();
39-
_reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
40-
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
41-
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
42-
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
43-
#endif
44-
45-
NSDictionary *initProps = [self prepareInitialProps];
46-
UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"RNTypescriptBoilerplate", initProps);
47-
48-
if (@available(iOS 13.0, *)) {
49-
rootView.backgroundColor = [UIColor systemBackgroundColor];
50-
} else {
51-
rootView.backgroundColor = [UIColor whiteColor];
52-
}
11+
self.moduleName = @"RNTypescriptBoilerplate";
12+
// You can add your custom initial props in the dictionary below.
13+
// They will be passed down to the ViewController used by React Native.
14+
self.initialProps = @{};
5315

54-
// SplashScreen Initialization
55-
[RNSplashScreen show];
16+
bool didFinish=[super application:application didFinishLaunchingWithOptions:launchOptions];
5617

57-
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
58-
UIViewController *rootViewController = [UIViewController new];
59-
rootViewController.view = rootView;
60-
self.window.rootViewController = rootViewController;
61-
[self.window makeKeyAndVisible];
62-
return YES;
63-
}
64-
65-
/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
66-
///
67-
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
68-
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
69-
/// @return: `true` if the `concurrentRoot` feture is enabled. Otherwise, it returns `false`.
70-
- (BOOL)concurrentRootEnabled
71-
{
72-
// Switch this bool to turn on and off the concurrent root
73-
return true;
74-
}
75-
- (NSDictionary *)prepareInitialProps
76-
{
77-
NSMutableDictionary *initProps = [NSMutableDictionary new];
78-
#ifdef RCT_NEW_ARCH_ENABLED
79-
initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]);
80-
#endif
81-
return initProps;
18+
[RNSplashScreen show]; // here
19+
return didFinish;
8220
}
8321

8422
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
@@ -90,43 +28,14 @@ - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
9028
#endif
9129
}
9230

93-
#if RCT_NEW_ARCH_ENABLED
94-
95-
#pragma mark - RCTCxxBridgeDelegate
96-
97-
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
98-
{
99-
_turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
100-
delegate:self
101-
jsInvoker:bridge.jsCallInvoker];
102-
return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
103-
}
104-
105-
#pragma mark RCTTurboModuleManagerDelegate
106-
107-
- (Class)getModuleClassFromName:(const char *)name
108-
{
109-
return RCTCoreModulesClassProvider(name);
110-
}
111-
112-
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
113-
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
114-
{
115-
return nullptr;
116-
}
117-
118-
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
119-
initParams:
120-
(const facebook::react::ObjCTurboModule::InitParams &)params
121-
{
122-
return nullptr;
123-
}
124-
125-
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
31+
/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
32+
///
33+
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
34+
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
35+
/// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`.
36+
- (BOOL)concurrentRootEnabled
12637
{
127-
return RCTAppSetupDefaultModuleFromClass(moduleClass);
38+
return true;
12839
}
12940

130-
#endif
131-
13241
@end

ios/RNTypescriptBoilerplate/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.0</string>
20+
<string>$(MARKETING_VERSION)</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>1</string>
24+
<string>$(CURRENT_PROJECT_VERSION)</string>
2525
<key>LSRequiresIPhoneOS</key>
2626
<true/>
2727
<key>NSAppTransportSecurity</key>

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"@zustand": ["./services/zustand/store"]
4444
}
4545
},
46+
"extends": "@tsconfig/react-native/tsconfig.json",
4647
"exclude": [
4748
"node_modules",
4849
"babel.config.js",

0 commit comments

Comments
 (0)