Skip to content

Use Objective-C nullability to provide better Swift types in RCTAppDelegate - #42236

Closed
okwasniewski wants to merge 1 commit into
react:mainfrom
okwasniewski:feat/swift-nullability
Closed

Use Objective-C nullability to provide better Swift types in RCTAppDelegate#42236
okwasniewski wants to merge 1 commit into
react:mainfrom
okwasniewski:feat/swift-nullability

Conversation

@okwasniewski

Copy link
Copy Markdown
Contributor

Summary:

This PR adds nullable type annotations + nullability audit regions (NS_ASSUME_NONNULL_BEGIN/NS_ASSUME_NONNULL_END) to provide better Swift types.

Before:

classAppDelegate:RCTAppDelegate{overridefunc sourceURL(for bridge:RCTBridge!)->URL!{self.bundleURL()}overridefunc bundleURL()->URL!{RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot:"js/RNTesterApp.ios")}overridefunc customize(_ rootView:RCTRootView!){
rootView.backgroundColor =.red
}}

After:

classAppDelegate:RCTAppDelegate{overridefunc sourceURL(for bridge:RCTBridge)->URL{self.bundleURL()}overridefunc bundleURL()->URL{RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot:"js/RNTesterApp.ios")}overridefunc customize(_ rootView:RCTRootView){
rootView.backgroundColor =.red
}}

Changelog:

[IOS] [ADDED] - Provide better Swift types for RCTAppDelegate and RCTBridgeDelegate

Test Plan:

In Xcode click the top left square button and look up the generated interface:
CleanShot 2024-01-10 at 16 40 51@2x

@facebook-github-botfacebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Jan 10, 2024
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@analysis-bot

Copy link
Copy Markdown
PlatformEngineArchSize (bytes)Diff
androidhermesarm64-v8a16,769,588-764
androidhermesarmeabi-v7an/a--
androidhermesx86n/a--
androidhermesx86_64n/a--
androidjscarm64-v8a20,165,562+3,740
androidjscarmeabi-v7an/a--
androidjscx86n/a--
androidjscx86_64n/a--

Base commit: 8fd2f12
Branch: main

@github-actions

Copy link
Copy Markdown

This pull request was successfully merged by @okwasniewski in a7c5c28.

When will my fix make it into a release? | Upcoming Releases

@github-actionsgithub-actionsBot added the Merged This PR has been merged. label Jan 11, 2024
Kudo added a commit to expo/expo that referenced this pull request Jan 16, 2024
…26357)
# Why
fix react-native nightlies support for 0.74
# How
summarize here, please check each commit messages for details
- [BREAKING CHANGE] remove `unstable_useRuntimeSchedulerAlways` or
`REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS` support
- [BREAKING CHANGE] remove
`ReactNativeHostHandler.onRegisterJSIModules()` interface
- [expo][dev-menu][dev-launcher] fixed for
`ReactNativeHost.getJSIModulePackage()` removal and adding
`ReactNativeHost.getUIManagerProvider()`
- [dev-client] add compatible methods to address
react/react-native#42236 changes
To be resolved and currently workarounded by SetupReactNativeNightly
- `import com.facebook.react.turbomodule.core.CallInvokerHolderImpl` ->
``import
com.facebook.react.internal.turbomodule.core.CallInvokerHolderImpl`
# Test Plan
ci passed
okwasniewski added a commit to callstack/react-native-visionos that referenced this pull request Feb 16, 2024
…legate (react#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: react#42236
Test Plan:
In Xcode click the top left square button and look up the generated interface:
![CleanShot 2024-01-10 at 16 40 51@2x](https://github.com/facebook/react-native/assets/52801365/ad2ac9ed-9d9a-4c5e-a200-1d7a2802e701)
Reviewed By: christophpurrer
Differential Revision: D52660647
Pulled By: cipolleschi
fbshipit-source-id: d4d3c36b3f420b3490145c491cd3781613f4b111
okwasniewski added a commit to callstack/react-native-visionos that referenced this pull request Apr 5, 2024
…legate (react#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: react#42236
Test Plan:
In Xcode click the top left square button and look up the generated interface:
![CleanShot 2024-01-10 at 16 40 51@2x](https://github.com/facebook/react-native/assets/52801365/ad2ac9ed-9d9a-4c5e-a200-1d7a2802e701)
Reviewed By: christophpurrer
Differential Revision: D52660647
Pulled By: cipolleschi
fbshipit-source-id: d4d3c36b3f420b3490145c491cd3781613f4b111
okwasniewski added a commit to callstack/react-native-visionos that referenced this pull request Jun 24, 2024
…legate (react#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: react#42236
Test Plan:
In Xcode click the top left square button and look up the generated interface:
![CleanShot 2024-01-10 at 16 40 51@2x](https://github.com/facebook/react-native/assets/52801365/ad2ac9ed-9d9a-4c5e-a200-1d7a2802e701)
Reviewed By: christophpurrer
Differential Revision: D52660647
Pulled By: cipolleschi
fbshipit-source-id: d4d3c36b3f420b3490145c491cd3781613f4b111
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.MergedThis PR has been merged.p: CallstackPartner: CallstackPartnerShared with MetaApplied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@okwasniewski@facebook-github-bot@analysis-bot