-1

I'm trying to archive my flutter app in distributing it to testers first. I have made and added schemas in Xcode for different flavours of the app. I also use amplify_core plugin. First when I try to clean build it gave me an error saying

"Compiling for iOS 11.0, but module 'amplify_core' has a minimum deployment target of iOS 16.0:"

After a little bit of researching I've made the apmlify_core min deployment target to 11 under runner in Xcode pods. Then the build was successful. but when I try to do an archive it gives me this error

"package:/main.dart: Error: No 'main' method found. Try adding a method named 'main' to your program."

I will paste my main.dart and one flavour dart file for reference. anyone can help me with his. ?

main.dart file

class MyApp extends StatelessWidget {
  MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  final appRouter = AppRouter().router;

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        StreamProvider<EInternetStatus>(
          create: (context) =>
              ConnectionCheck().internetStatusController.stream,
          initialData: EInternetStatus.iLoading,
        ),
      ],
      child: MaterialApp.router(
        debugShowCheckedModeBanner: AppEnvironment.flavour == EFlavour.fDev ||
                AppEnvironment.flavour == EFlavour.fQa
            ? true
            : false,
        theme: FPTheme.lightTheme,
        routerConfig: appRouter,
      ),
    );
  }
}

main_dev.dart file

Future<void> main() async {
  AppEnvironment.setupEnv(EFlavour.fDev);
  WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
  await AmplifyServices().configureAmplify();
  SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
  ]);
  SystemChrome.setEnabledSystemUIMode(SystemUiMode.leanBack);
  FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
  setUp();
  runApp(MyApp());
}

im not sure what I do here wrong? if anyone can help me out with this it would be amazing

  • 1
    Does this answer your question? [Flutter : Target file "lib/main.dart" not found](https://stackoverflow.com/questions/50522153/flutter-target-file-lib-main-dart-not-found) – Stanly Dec 04 '22 at 06:00

1 Answers1

0

How are you running your app?
i think you haven't configured build using flavours correctly in your editor try using
flutter run -t lib/main_dev.dart


To configure your vs code to run with flavours try changing launch.json file.
 "configurations": [

{
  "name": "Flutter",
  "request": "launch",
  "type": "dart",
  "program": "${workspaceFolder}/lib/main_dev.dart"
}].

You can also refer This stackoverflow answer

  • I was not using vscode though, was using android studio. android build for flavour works fine, im trying to archive an app in Xcode. this is where it gives me the error main.dart is not found – AlfaBetaGamma Dec 04 '22 at 06:09