Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed

Conversation

okwasniewski
Copy link
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:

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:

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

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-bot facebook-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
Contributor

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

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 16,769,588 -764
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 20,165,562 +3,740
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 8fd2f12
Branch: main

Copy link

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

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

@github-actions github-actions bot 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
facebook/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
gokul1099 pushed a commit to gokul1099/react-native-visionos that referenced this pull request Jan 17, 2024
…legate (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:
![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 Feb 16, 2024
…legate (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:
![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 (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:
![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 (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:
![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 free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants