Value of type 'UnityAppController' has no member 'unityMessageHandler'
I can't RUN or Build ios because of this:

Why is everytime a new bug appearing in this project?
if self.ufw?.appController() != nil {
controller = self.ufw?.appController()
controller?.unityMessageHandler = self.unityMessageHandlers
controller?.unitySceneLoadedHandler = self.unitySceneLoadedHandlers
self.ufw?.appController()?.window?.windowLevel = UIWindow.Level(UIWindow.Level.normal.rawValue - CGFloat(globalUILevel))
}
_isUnityLoaded = true
What should I use here?! @juicycleff

what is this other plugin that you speak of?
add:
Classes/UnityAppController.mm
- (void)application:(UIApplication*)application handleEventsForBackgroundURLSession:(nonnull NSString ...
+
// Added by https://github.com/juicycleff/flutter-unity-view-widget
extern "C" void OnUnityMessage(const char* message)
{
if (GetAppController().unityMessageHandler) {
GetAppController().unityMessageHandler(message);
}
}
extern "C" void OnUnitySceneLoaded(const char* name, const int* buildIndex, const bool* isLoaded, const bool* IsValid)
{
if (GetAppController().unitySceneLoadedHandler) {
GetAppController().unitySceneLoadedHandler(name, buildIndex, isLoaded, IsValid);
}
}
Classes/UnityAppController.h
@property (nonatomic, copy) void (^quitHandler)(void);...
+
@property (nonatomic, copy) void(^unitySceneLoadedHandler)(const char* name, const int* buildIndex, const bool* isLoaded, const bool* IsValid);
@property (nonatomic, copy) void(^unityMessageHandler)(const char* message);
add:
Classes/UnityAppController.mm - (void)application:(UIApplication*)application handleEventsForBackgroundURLSession:(nonnull NSString ... + // Added by https://github.com/juicycleff/flutter-unity-view-widget extern "C" void OnUnityMessage(const char* message) { if (GetAppController().unityMessageHandler) { GetAppController().unityMessageHandler(message); } } extern "C" void OnUnitySceneLoaded(const char* name, const int* buildIndex, const bool* isLoaded, const bool* IsValid) { if (GetAppController().unitySceneLoadedHandler) { GetAppController().unitySceneLoadedHandler(name, buildIndex, isLoaded, IsValid); } } Classes/UnityAppController.h @property (nonatomic, copy) void (^quitHandler)(void);... + @property (nonatomic, copy) void(^unitySceneLoadedHandler)(const char* name, const int* buildIndex, const bool* isLoaded, const bool* IsValid); @property (nonatomic, copy) void(^unityMessageHandler)(const char* message);
This helped. Thanks a lot.
Where do I add this exactly? Running in to this issue now
You should add Unity Message Manager to your unity object first, then export. It solves my problem
This actually worked @impayru thanks!!
@rickdijk and for others who need more details :
In ios/UnityLibrary/Classes/UnityAppController.mm after the function handleEventsForBackgroundURLSession add :
extern "C" void OnUnityMessage(const char* message)
{
if (GetAppController().unityMessageHandler) {
GetAppController().unityMessageHandler(message);
}
}
extern "C" void OnUnitySceneLoaded(const char* name, const int* buildIndex, const bool* isLoaded, const bool* IsValid)
{
if (GetAppController().unitySceneLoadedHandler) {
GetAppController().unitySceneLoadedHandler(name, buildIndex, isLoaded, IsValid);
}
}
In ios/UnityLibrary/Classes/UnityAppController.h after :
@property (nonatomic, copy) void (^quitHandler)(void);
Add :
@property (nonatomic, copy) void(^unitySceneLoadedHandler)(const char* name, const int* buildIndex, const bool* isLoaded, const bool* IsValid);
@property (nonatomic, copy) void(^unityMessageHandler)(const char* message);
I just found a reliable way to replicate this error.
Reproduction
- Set the build target in Unity build settings to anything NOT iOS, like Android or Desktop.
- Now click Flutter-> Export iOS.
This results in an incomplete build, because any code in
#if UNITY_IOS blocks is skipped.
However you still see the build successful message.
The build script will change the buildtarget automatically, but somehow the #If UNITY_ keeps the old value.
Current solution
Change the Unity build target before clicking Flutter -> Export.
You don't have to paste any code like in the comments above, that should be done by the export script automatically.
If you use batchmode or command line, make sure to include -buildTarget iOS in your command.
I am facing this exact issue, I have selected ios as the platform before clicking futter-> export the code provided @MarkAlexanderDev did the trick.
I just found a reliable way to replicate this error.
Reproduction
* Set the build target in Unity build settings to anything NOT iOS, like Android or Desktop. * Now click Flutter-> Export iOS.This results in an incomplete build, because any code in
#if UNITY_IOSblocks is skipped. However you still see the build successful message.The build script will change the buildtarget automatically, but somehow the
#If UNITY_keeps the old value.Current solution
Change the Unity build target before clicking Flutter -> Export.
You don't have to paste any code like in the comments above, that should be done by the export script automatically.
If you use batchmode or command line, make sure to include
-buildTarget iOSin your command.
Thank you! This should be in the Troubleshooting section. One thing I would like to add to the solution, that is you need to close & reopen the Unity project first.
Sometime when click Export Ios (Release)
UnityController.h would change like this
And UNityController.mm file like this
After export Export Ios (Release) control this two files if it was changed rollback these