flutter-branch-io
flutter-branch-io copied to clipboard
Compilation errors on iOS (new version of Swift compiler?)
Hi,
I'm using 1.0.1 version of the plugin. After following the tutorial and trying to deploy it on an iPhone XR simulator, I get these errors: "cannot use optional chaining on non-optional value of type 'Branch'"
I'm unsure how nullability and optionals work between Obj-C and Swift, but Branch.getInstance returns a pointer (could be nullable), but obviously Swift thinks it's a non-optional. Any proposed solutions?
See below.
/Users/Mark/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_branch_io_plugin-1.0.1/ios/Classes/SwiftFlutterBranchIoPlugin.swift:103:29: error: cannot use optional chaining on non-optional value of type 'Branch' Branch.getInstance()?.setIdentity(userId) ~~~~~~~~~~~~~~~~~~~~^ /Users/Mark/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_branch_io_plugin-1.0.1/ios/Classes/SwiftFlutterBranchIoPlugin.swift:107:29: error: cannot use optional chaining on non-optional value of type 'Branch' Branch.getInstance()?.logout() ~~~~~~~~~~~~~~~~~~~~^ /Users/Mark/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_branch_io_plugin-1.0.1/ios/Classes/SwiftFlutterBranchIoPlugin.swift:111:48: error: cannot use optional chaining on non-optional value of type 'Branch' let latestParams = Branch.getInstance()?.getLatestReferringParams() ~~~~~~~~~~~~~~~~~~~~^ /Users/Mark/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_branch_io_plugin-1.0.1/ios/Classes/SwiftFlutterBranchIoPlugin.swift:116:47: error: cannot use optional chaining on non-optional value of type 'Branch' let firstParams = Branch.getInstance()?.getFirstReferringParams() ~~~~~~~~~~~~~~~~~~~~^ /Users/Mark/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_branch_io_plugin-1.0.1/ios/Classes/SwiftFlutterBranchIoPlugin.swift:148:29: error: cannot use optional chaining on non-optional value of type 'Branch' Branch.getInstance()?.initSession(launchOptions: launchOptions) { params, error in ~~~~~~~~~~~~~~~~~~~~^ /Users/Mark/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_branch_io_plugin-1.0.1/ios/Classes/SwiftFlutterBranchIoPlugin.swift:169:49: error: cannot use optional chaining on non-optional value of type 'Branch' let branchHandled = Branch.getInstance()?.application(app, open: url, options: options) ?? false ~~~~~~~~~~~~~~~~~~~~^ /Users/Mark/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_branch_io_plugin-1.0.1/ios/Classes/SwiftFlutterBranchIoPlugin.swift:175:29: error: cannot use optional chaining on non-optional value of type 'Branch' Branch.getInstance()?.handlePushNotification(userInfo) ~~~~~~~~~~~~~~~~~~~~^ /Users/Mark/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_branch_io_plugin-1.0.1/ios/Classes/SwiftFlutterBranchIoPlugin.swift:180:51: error: cannot use optional chaining on non-optional value of type 'Branch'
Thanks,
made a quick fix: https://github.com/fuseio/flutter-branch-io/tree/optional_branch_bug_fix
@bejavu Thanks! I did the same and added some logic for search ad/Facebook deep linking for Branch here:
https://github.com/alexg313/flutter-branch-io/commit/e5ba10438d51f73bd483cd0fe9ec4887bad21e33
Although it may not be the best because now flutter-branch-io depends on an external library like Facebook now.
@blackmenthor feel free to close this. thank you