Skip to content

Commit

Permalink
feat: Support RN 0.74 and Bridgeless (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanjhughes committed Mar 22, 2024
1 parent 85c1c06 commit 3604301
Show file tree
Hide file tree
Showing 47 changed files with 20,079 additions and 25,741 deletions.
92 changes: 92 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
AccessModifierOffset: -1
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ForEachMacros: [ FOR_EACH_RANGE, FOR_EACH, ]
IncludeCategories:
- Regex: '^<.*\.h(pp)?>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
---
Language: ObjC
ColumnLimit: 120
BreakBeforeBraces: WebKit
PointerAlignment: Right
...
11 changes: 9 additions & 2 deletions FabricExample/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
ios/.xcode.env.local
**/.xcode.env.local

# Android/IntelliJ
#
Expand Down Expand Up @@ -56,11 +56,18 @@ yarn-error.log
*.jsbundle

# Ruby / CocoaPods
/ios/Pods/
**/Pods/
/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

# testing
/coverage

.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
6 changes: 3 additions & 3 deletions FabricExample/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function App() {
<View style={styles.rtlSwitchContainer}>
<Switch
value={isRTL}
onValueChange={(newValue) => {
onValueChange={newValue => {
setIsRTL(newValue);
I18nManager.forceRTL(newValue);
}}
Expand All @@ -34,7 +34,7 @@ export default function App() {
</View>
<View style={styles.container}>
<Text style={styles.heading}>Picker Examples</Text>
{PickerExamples.examples.map((element) => (
{PickerExamples.examples.map(element => (
<View style={styles.elementContainer} key={element.title}>
<Text style={styles.title}> {element.title} </Text>
{element.render()}
Expand All @@ -44,7 +44,7 @@ export default function App() {
<Text style={styles.heading}>PickerIOS Examples</Text>
)}
{Platform.OS === 'ios' &&
PickerIOSExamples.examples.map((element) => (
PickerIOSExamples.examples.map(element => (
<View style={styles.elementContainer} key={element.title}>
<Text style={styles.title}> {element.title} </Text>
{element.render()}
Expand Down
1 change: 0 additions & 1 deletion FabricExample/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ android {
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
implementation("com.facebook.react:flipper-integration")

if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ import com.facebook.react.ReactPackage
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.flipper.ReactNativeFlipper
import com.facebook.soloader.SoLoader

class MainApplication : Application(), ReactApplication {

override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> {
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return PackageList(this).packages
}
override fun getPackages(): List<ReactPackage> =
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
}

override fun getJSMainModuleName(): String = "index"

Expand All @@ -31,7 +30,7 @@ class MainApplication : Application(), ReactApplication {
}

override val reactHost: ReactHost
get() = getDefaultReactHost(this.applicationContext, reactNativeHost)
get() = getDefaultReactHost(applicationContext, reactNativeHost)

override fun onCreate() {
super.onCreate()
Expand All @@ -40,6 +39,5 @@ class MainApplication : Application(), ReactApplication {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}
ReactNativeFlipper.initializeFlipper(this, reactNativeHost.reactInstanceManager)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
android:insetLeft="@dimen/abc_edit_text_inset_horizontal_material"
android:insetRight="@dimen/abc_edit_text_inset_horizontal_material"
android:insetTop="@dimen/abc_edit_text_inset_top_material"
android:insetBottom="@dimen/abc_edit_text_inset_bottom_material">
android:insetBottom="@dimen/abc_edit_text_inset_bottom_material"
>

<selector>
<!--
Expand Down
9 changes: 6 additions & 3 deletions FabricExample/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 21
minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "25.1.8937393"
kotlinVersion = "1.8.0"

ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.22"
}
repositories {
google()
Expand All @@ -19,3 +20,5 @@ buildscript {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
}

apply plugin: "com.facebook.react.rootproject"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
8 changes: 6 additions & 2 deletions FabricExample/ios/FabricExample/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
return [self getBundleURL];
return [self bundleURL];
}

- (NSURL *)getBundleURL
- (BOOL)bridgelessEnabled {
return true;
}

- (NSURL *)bundleURL
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
Expand Down
2 changes: 1 addition & 1 deletion FabricExample/ios/FabricExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
Expand Down
23 changes: 3 additions & 20 deletions FabricExample/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@ require Pod::Executable.execute_command('node', ['-p',
platform :ios, min_ios_version_supported
prepare_react_native_project!

ENV['RCT_NEW_ARCH_ENABLED'] = '1'

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# ```js
# module.exports = {
# dependencies: {
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
Expand All @@ -32,11 +19,6 @@ target 'FabricExample' do

use_react_native!(
:path => config[:reactNativePath],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
:flipper_configuration => flipper_config,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
Expand All @@ -51,7 +33,8 @@ target 'FabricExample' do
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false
:mac_catalyst_enabled => false,
# :ccache_enabled => true
)
end
end
end

0 comments on commit 3604301

Please sign in to comment.