Commit eca556b
committed
Use Objective-C nullability to provide better Swift types in RCTAppDelegate (facebook#42236)
Summary:
This PR adds nullable type annotations + nullability audit regions (`NS_ASSUME_NONNULL_BEGIN`/`NS_ASSUME_NONNULL_END`) to provide better Swift types.
Before:
```swift
class AppDelegate: RCTAppDelegate {
override func sourceURL(for bridge: RCTBridge!) -> URL! {
self.bundleURL()
}
override func bundleURL() -> URL! {
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "js/RNTesterApp.ios")
}
override func customize(_ rootView: RCTRootView!) {
rootView.backgroundColor = .red
}
}
```
After:
```swift
class AppDelegate: RCTAppDelegate {
override func sourceURL(for bridge: RCTBridge) -> URL {
self.bundleURL()
}
override func bundleURL() -> URL {
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "js/RNTesterApp.ios")
}
override func customize(_ rootView: RCTRootView) {
rootView.backgroundColor = .red
}
}
```
## Changelog:
[IOS] [ADDED] - Provide better Swift types for RCTAppDelegate and RCTBridgeDelegate
Pull Request resolved: facebook#42236
Test Plan:
In Xcode click the top left square button and look up the generated interface:

Reviewed By: christophpurrer
Differential Revision: D52660647
Pulled By: cipolleschi
fbshipit-source-id: d4d3c36b3f420b3490145c491cd3781613f4b1111 parent 80461f7 commit eca556b
File tree
2 files changed
+12
-4
lines changed- packages/react-native
- Libraries/AppDelegate
- React/Base
2 files changed
+12
-4
lines changedLines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| |||
146 | 148 | | |
147 | 149 | | |
148 | 150 | | |
| 151 | + | |
| 152 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
| 82 | + | |
| 83 | + | |
0 commit comments