Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[iOS API breaking change] Make splashScreenView of FlutterViewController nullable #34743

Merged
merged 1 commit into from
Jul 27, 2022

Conversation

zhongwuzw
Copy link
Member

Based on the talk of https://github.com/flutter/engine/pull/34496/files#r923640588, we should make splashScreenView nullable, then Swift users can remove splashScreenView if they set nil.

But it lead to an API-breaking change for Swift users, if Swift users use the getter of splashScreenView, the return type changed from UIView to UIView? .

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I'm not familiar with the breaking change process in the engine repro.

@zanderso can you (or someone in the engine team) review for the breaking change process?

@zanderso
Copy link
Member

What will this change break?

@cyanglaz
Copy link
Contributor

What will this change break?

see #34496 (comment)

@jmagman
Copy link
Member

jmagman commented Jul 20, 2022

What will this change break?

@zanderso Specifically it would be a compilation error if the calling code is in Swift and gets the splash screen and stores in a nonnull UIView variable.

error build: Value of optional type 'UIView?' must be unwrapped to a value of type 'UIView'

They would need to update their code to instead store in a UIView?. I imagine this would be very rare, but possible in an add-to-app scenario.

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  var splashScreen = UIView()
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    var flutterEngine = FlutterEngine(name: "my flutter engine")
    let flutterViewController = FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)
    splashScreen = flutterViewController.splashScreenView // compilation error: Value of optional type 'UIView?' must be unwrapped to a value of type 'UIView'

More likely the add-to-app developer is just setting the view. Storing it with let also shouldn't cause issues.

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    var flutterEngine = FlutterEngine(name: "my flutter engine")
    let flutterViewController = FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)
    let splashScreen = flutterViewController.splashScreenView // compiles successfully

@zanderso
Copy link
Member

Thanks @jmagman. It sounds like this would just need a small migration guide.

@zhongwuzw
Copy link
Member Author

@zanderso I'm not familiar with the breaking change process :), I make a migration guide PR, can you help me to review that?

Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'll make sure flutter/website#7385 deprecation notice gets merged.

@jmagman jmagman added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 27, 2022
@auto-submit auto-submit bot merged commit 7159359 into flutter:main Jul 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 27, 2022
a-wallen pushed a commit to a-wallen/engine that referenced this pull request Jul 27, 2022
betrevisan pushed a commit to betrevisan/engine that referenced this pull request Jul 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-ios prod: API break
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants