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

Swift Compiler Error (Xcode): Value of type 'UnityAppController' has no member 'unityMessageHandler' #920

Open
iamtobgay opened this issue Jan 26, 2024 · 3 comments
Labels
duplicate This issue or pull request already exists

Comments

@iamtobgay
Copy link

iamtobgay commented Jan 26, 2024

Describe the bug
Tried to build and run the following example code :

import 'package:flutter/material.dart';
import 'package:flutter_unity_widget/flutter_unity_widget.dart';

void main() {
  runApp(
    const MaterialApp(
      home: UnityDemoScreen(),
    ),
  );
}

class UnityDemoScreen extends StatefulWidget {
  const UnityDemoScreen({Key? key}) : super(key: key);

  @override
  State<UnityDemoScreen> createState() => _UnityDemoScreenState();
}

class _UnityDemoScreenState extends State<UnityDemoScreen> {
  static final GlobalKey<ScaffoldState> _scaffoldKey =
      GlobalKey<ScaffoldState>();
  UnityWidgetController? _unityWidgetController;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _scaffoldKey,
      body: SafeArea(
        bottom: false,
        child: WillPopScope(
          onWillPop: () async {
            // Pop the category page if Android back button is pressed.
            return true;
          },
          child: Container(
            color: Colors.yellow,
            child: UnityWidget(
              onUnityCreated: onUnityCreated,
            ),
          ),
        ),
      ),
    );
  }

  // Callback that connects the created controller to the unity controller
  void onUnityCreated(controller) {
    _unityWidgetController = controller;
  }
}

got the following errors :

Swift Compiler Error (Xcode): Value of type 'UnityAppController' has no member 'unityMessageHandler'
**Swift Compiler Error (Xcode): Value of type 'UnityAppController' has no member 'unitySceneLoadedHandler'
**

Unity (please complete the following information):

  • OS: MacOS 14.2.1 (23C71)
  • Version 2022.3.16f1

Smartphone (please complete the following information):

  • Device: iPhone 13pro
  • OS: iOS17.2
@timbotimbo timbotimbo added the duplicate This issue or pull request already exists label Mar 10, 2024
@timbotimbo
Copy link
Collaborator

During the Unity export, the plugin's build script will add a few lines to the UnityAppController script generated by Unity.

This error indicates that these additions are missing and weren't generated properly.

  • use the latest unitypackage
  • delete any existing ios/unitylibrary folder
  • In unity make sure your buildtarget is set to ios.
    This error will show up if you click export ios while the unity buildtarget is not ios.
  • Make an ios export using the Flutter menu in Unity.

@iamtobgay
Copy link
Author

iamtobgay commented Mar 20, 2024 via email

@liujunqiang29
Copy link

Is the problem solved? I have the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants