Skip to content

Commit af69816

Browse files
authored
bugfix(Android): fixed rnn link for android (#8063)
* fixed rnn link for android * Fixed rnn link for ios
1 parent abf0db9 commit af69816

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

ReactNativeNavigation.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Find.find(start_dir) do |path|
1515
end
1616
end
1717

18-
swift_project = File.exist?(swift_delegate_path)
18+
swift_project = swift_delegate_path && File.exist?(swift_delegate_path)
1919

2020
# Debug output
2121
if swift_project

autolink/postlink/__snapshots__/applicationLinker.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ import com.facebook.react.PackageList
88
import com.reactnativenavigation.NavigationApplication
99
import com.facebook.react.ReactHost
1010
import com.facebook.react.ReactNativeHost
11-
import com.reactnativenavigation.react.NavigationReactNativeHost
1211
import com.facebook.react.ReactPackage
1312
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
1413
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
1514
import com.facebook.react.defaults.DefaultReactNativeHost
15+
import com.reactnativenavigation.react.NavigationReactNativeHost
1616
import com.facebook.react.soloader.OpenSourceMergedSoMapping
1717
import com.facebook.soloader.SoLoader
1818
1919
class MainApplication : NavigationApplication() {
2020
2121
override val reactNativeHost: ReactNativeHost =
22-
object : DefaultNavigationReactNativeHost(this) {
22+
object : NavigationReactNativeHost(this) {
2323
override fun getPackages(): List<ReactPackage> =
2424
PackageList(this).packages.apply {
2525
// Packages that cannot be autolinked yet can be added manually here, for example:

autolink/postlink/applicationLinker.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class ApplicationLinker {
1616
if (!this.applicationPath) {
1717
errorn(
1818
'MainApplication.kt not found! Does the file exist in the correct folder?\n' +
19-
' Please check the manual installation docs:\n' +
20-
' https://wix.github.io/react-native-navigation/docs/installing#3-update-mainapplicationjava'
19+
' Please check the manual installation docs:\n' +
20+
' https://wix.github.io/react-native-navigation/docs/installing#3-update-mainapplicationjava'
2121
);
2222
}
2323

@@ -78,10 +78,7 @@ class ApplicationLinker {
7878
if (this._doesExtendApplication(applicationContent)) {
7979
debugn(' Extending NavigationApplication');
8080
return applicationContent
81-
.replace(
82-
/:\s*Application\(\)\s*,\s*ReactApplication/gi,
83-
': NavigationApplication()'
84-
)
81+
.replace(/:\s*Application\(\)\s*,\s*ReactApplication/gi, ': NavigationApplication()')
8582
.replace(
8683
'import com.facebook.react.ReactApplication',
8784
'import com.reactnativenavigation.NavigationApplication'
@@ -114,21 +111,21 @@ class ApplicationLinker {
114111
return applicationContent;
115112
}
116113

117-
if (this._doesExtendReactNativeHost(applicationContent)) {
114+
if (this._doesExtendDefaultReactNativeHost(applicationContent)) {
118115
debugn(' Changing host implementation to NavigationReactNativeHost');
119116
return applicationContent
120-
.replace('ReactNativeHost(this)', 'NavigationReactNativeHost(this)')
117+
.replace('DefaultReactNativeHost(this)', 'NavigationReactNativeHost(this)')
121118
.replace(
122-
'import com.facebook.react.ReactNativeHost',
123-
'import com.facebook.react.ReactNativeHost\nimport com.reactnativenavigation.react.NavigationReactNativeHost'
119+
'import com.facebook.react.defaults.DefaultReactNativeHost',
120+
'import com.facebook.react.defaults.DefaultReactNativeHost\nimport com.reactnativenavigation.react.NavigationReactNativeHost'
124121
);
125-
} else if (this._doesExtendDefaultReactNativeHost(applicationContent)) {
122+
} else if (this._doesExtendReactNativeHost(applicationContent)) {
126123
debugn(' Changing host implementation to NavigationReactNativeHost');
127124
return applicationContent
128-
.replace('DefaultReactNativeHost(this)', 'NavigationReactNativeHost(this)')
125+
.replace('ReactNativeHost(this)', 'NavigationReactNativeHost(this)')
129126
.replace(
130-
'import com.facebook.react.defaults.DefaultReactNativeHost',
131-
'import com.facebook.react.defaults.DefaultReactNativeHost\nimport com.reactnativenavigation.react.NavigationReactNativeHost'
127+
'import com.facebook.react.ReactNativeHost',
128+
'import com.facebook.react.ReactNativeHost\nimport com.reactnativenavigation.react.NavigationReactNativeHost'
132129
);
133130
}
134131

@@ -160,7 +157,9 @@ class ApplicationLinker {
160157
}
161158

162159
_isSOLoaderInitCalled(applicationContent) {
163-
return /SoLoader\.init\(\s*this\s*,\s*OpenSourceMergedSoMapping\s*\);?/.test(applicationContent);
160+
return /SoLoader\.init\(\s*this\s*,\s*OpenSourceMergedSoMapping\s*\);?/.test(
161+
applicationContent
162+
);
164163
}
165164

166165
_removeNewArchEntryPointLoad(applicationContent) {
@@ -176,7 +175,9 @@ class ApplicationLinker {
176175
}
177176

178177
_isNewArchEntryPointLoadCalled(applicationContent) {
179-
return /if\s*\(\s*BuildConfig\.IS_NEW_ARCHITECTURE_ENABLED\s*\)\s*\{[\s\S]*?load\(\)\s*[\s}]*?\}/.test(applicationContent);
178+
return /if\s*\(\s*BuildConfig\.IS_NEW_ARCHITECTURE_ENABLED\s*\)\s*\{[\s\S]*?load\(\)\s*[\s}]*?\}/.test(
179+
applicationContent
180+
);
180181
}
181182
}
182183

playground/ios/playground/AppDelegate.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ - (BOOL)application:(UIApplication *)application
1414
[super application:application didFinishLaunchingWithOptions:launchOptions];
1515
self.dependencyProvider = [RCTAppDependencyProvider new];
1616

17+
18+
1719
if (self.bridgelessEnabled) {
1820
#ifdef RCT_NEW_ARCH_ENABLED
1921
[ReactNativeNavigation

0 commit comments

Comments
 (0)