braze-inc / braze-flutter-sdk

Public repo for the Braze Flutter SDK
Other
16 stars 33 forks source link

[Bug]: Swift Compiler Error (Xcode): Value of optional type '[String : Any]?' must be unwrapped to a value of type '[String : Any]' #91

Open marius-h opened 5 days ago

marius-h commented 5 days ago

Which Platforms?

iOS

Which Flutter Version?

3.24.3

Which Braze Flutter SDK version?

9.0.0-11.1.0

Repro Rate

100% of the time

Steps To Reproduce

Create a new project with braze_plugin dependency of version 9.0.0 or above and build it with Xcode 16.0

Expected Behavior

App builds successfully

Actual Incorrect Behavior

Build fails with Swift Compiler Error (Xcode): Value of optional type '[String : Any]?' must be unwrapped to a value of type '[String : Any]' /Users/marius-h/.pub-cache/hosted/pub.dev/braze_plugin-11.1.0/ios/Classes/BrazePlugin.swift:843:42

Verbose Logs

ePerformance/Sources/FIRPerformance.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'FirebasePerformance' from project 'Pods')
                cd /Users/marius-h/Documents/flutter/app/ios/Pods

                Using response file: /Users/marius-h/Library/Developer/Xcode/DerivedData/Runner-abuxidzqrmtilaczsnarudojjceq/Build/Intermediates.noindex/Pods.build/Debug-staging-iphonesimulator/FirebasePerformance.build/Objects-normal/x86_64/e6072d4f65d7061329687fe24e3d63a7-common-args.resp

                builtin-ScanDependencies -o /Users/marius-h/Library/Developer/Xcode/DerivedData/Runner-abuxidzqrmtilaczsnarudojjceq/Build/Intermediates.noindex/Pods.build/Debug-staging-iphonesimulator/FirebasePerformance.build/Objects-normal/x86_64/FIRPerformance.o.scan -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -ivfsstatcache /Users/marius-h/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphonesimulator18.0-22A3362-db63dc9361471f152f572502bdbfe70a.sdkstatcache -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fno-color-diagnostics -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/Users/marius-h/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wdocumentation -Wunreachable-code -Wno-implicit-atomic-properties -Werror\=deprecated-objc-isa-usage -Wno-objc-interface-ivars -Werror\=objc-root-class -Wno-arc-repeated-use-of-weak -Wimplicit-retain-self -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wdeprecated-implementations -Wno-implicit-fallthrough -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -Wno-sign-conversion -Winfinite-recursion -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wno-semicolon-before-method-body -Wunguarded-availability @/Users/marius-h/Library/Developer/Xcode/DerivedData/Runner-abuxidzqrmtilaczsnarudojjceq/Build/Intermediates.noindex/Pods.build/Debug-staging-iphonesimulator/FirebasePerformance.build/Objects-normal/x86_64/e6072d4f65d7061329687fe24e3d63a7-common-args.resp -MMD -MT dependencies -MF /Users/marius-h/Library/Developer/Xcode/DerivedData/Runner-abuxidzqrmtilaczsnarudojjceq/Build/Intermediates.noindex/Pods.build/Debug-staging-iphonesimulator/FirebasePerformance.build/Objects-normal/x86_64/FIRPerformance.d --serialize-diagnostics /Users/marius-h/Library/Developer/Xcode/DerivedData/Runner-abuxidzqrmtilaczsnarudojjceq/Build/Intermediates.noindex/Pods.build/Debug-staging-iphonesimulator/FirebasePerformance.build/Objects-normal/x86_64/FIRPerformance.dia -c /Users/marius-h/Documents/flutter/app/ios/Pods/FirebasePerformance/FirebasePerformance/Sources/FIRPerformance.m -o /Users/marius-h/Library/Developer/Xcode/DerivedData/Runner-abuxidzqrmtilaczsnarudojjceq/Build/Intermediates.noindex/Pods.build/Debug-staging-iphonesimulator/FirebasePerformance.build/Objects-normal/x86_64/FIRPerformance.o

[ ... ]

[  +21 ms] Failed to build iOS app
[   +1 ms] Swift Compiler Error (Xcode): Value of optional type '[String : Any]?' must be unwrapped to a value of type '[String : Any]'
           /Users/marius-h/.pub-cache/hosted/pub.dev/braze_plugin-11.1.0/ios/Classes/BrazePlugin.swift:843:42

[   +2 ms] Could not build the application for the simulator.
[        ] Error launching application on iPhone 16 Pro.
[   +1 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:790:9)
           <asynchronous suspension>
           #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1408:27)
           <asynchronous suspension>
           #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #4      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
           <asynchronous suspension>
           #5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:420:9)
           <asynchronous suspension>
           #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:364:5)
           <asynchronous suspension>
           #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:130:9)
           <asynchronous suspension>
           #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #10     main (package:flutter_tools/executable.dart:93:3)
           <asynchronous suspension>

[   +4 ms] "flutter run" took 71,223ms.
[        ] Running 2 shutdown hooks
[        ] Shutdown hooks complete
[   +5 ms] exiting with code 1

Additional Information

Xcode version: 16.0

hokstuff commented 4 days ago

Hi @marius-h,

Can you contact support@braze.com with more information around your issue so we can help debug? In the thread, be sure to include:

  1. The specific Flutter version you are testing with along with the line of code that has the error. For 11.1.0, the line associated is a newline so I suspect the error and the source code don't match 1:1
  2. More details on the exact steps to reproduce this issue. Do you need to receive a push notification, IAM, or anything? Does it happen 100% at startup?
  3. Notes if you are using any special customization when selecting a version, such as using a different native iOS/Android version than is pinned in the Flutter SDK version

Also, I would be sure to call flutter clean and remove any ios/Pods folders between runs to ensure that you are building from a clean environment. If you have further issues and the Support team isn't able to resolve your solution, you can look into these Flutter commands.

Thanks!

Yasinilhan61 commented 3 days ago

@hokstuff we also saw this issue after flutter pub cache clean flutter clean

So in our case i fixed it which we have in this PR. Please have a look. https://github.com/braze-inc/braze-flutter-sdk/pull/93