简体   繁体   中英

xCode error causing app to crash immediately after launch

I am having an issue with my flutter app on iOS. It is working well on android and on web but I am getting this error on iOS. I come from a web dev background and do not have a lot of experience in iOS.

I am getting the error below and have zero idea of where to even begin. It appears to be an issue with one of the plugins... but I honestly have not idea. Any help on a direction would be incredibly helpful.

Error from xCode

This is a fairly large app

Here is my pubspec.


version: 1.6.0+18

environment:
  sdk: ^2.7.0

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2
  http: ^0.13.0
  responsive_builder: ^0.3.0
  bloc: ^7.0.0
  flutter_bloc: ^7.0.0
  equatable: ^2.0.0
  meta: ^1.1.6
  hive: ^2.0.0
  hive_flutter: ^1.0.0
  flutter_appauth: ^0.9.2+6
  intl: ^0.17.0
  table_calendar: ^2.3.3
  js: ^0.6.0
  floating_action_bubble: ^1.1.2
  badges: ^1.1.6
  plaid_flutter:
    git:
      url: https://github.com/cwesterhold/plaid_flutter
      ref: master
  font_awesome_flutter: ^8.11.0
  auth0_spa:
    git:
      url: https://github.com/cwesterhold/auth0-spa-flutter
      ref: master
  multiple_select:
    git:
      url: https://github.com/cwesterhold/multiple_select
      ref: master
  #catcher: ^0.6.2
  flutter_localizations:
    sdk: flutter
  #package_info_plus: ^1.0.0
  purchases_flutter: ^3.0.0
  url_launcher: ^6.0.0
  syncfusion_flutter_charts: ^18.4.47
  progress_indicator: ^0.1.1
  uuid:

dev_dependencies:
  flutter_test:
    sdk: flutter
  hive_generator:
  build_runner: ^1.10.0
  flutter_launcher_icons: ^0.9.0

flutter_icons:
  image_path: 'assets/ic_launcher.png'
  android: false
  ios: true

#flutter pub run flutter_launcher_icons:main

flutter:
  uses-material-design: true
  assets:
    - assets/
  fonts:
    - family: Comfortaa
      fonts:
        - asset: fonts/Comfortaa-VariableFont_wght.ttf

Here is the main


import 'dart:async';

import 'package:clicket/bloc/theme/theme.dart';
import 'package:clicket/models/errorModel.dart';
import 'package:clicket/screens/login/loginMain.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

void main() async {
  bool isInDebugMode = false;
  assert(isInDebugMode = true);

  ErrorModel errorModel = ErrorModel();
  WidgetsFlutterBinding.ensureInitialized();

  bool isDev = false;
  assert(isDev = true);

  if (isDev == true) {
    runApp(Clicket());
  } else {
    runZoned<Future<void>>(
      () async {
        runApp(Clicket());
      },
      onError: (dynamic error, StackTrace stackTrace) {
        errorModel.reportError(error, stackTrace);
        // Send report
      },
    );
  }
}

class Clicket extends StatefulWidget {
  @override
  _ClicketState createState() => _ClicketState();
}

class _ClicketState extends State<Clicket> {
  var s;
  ThemeBloc _themeBloc = ThemeBloc();
  final navigatorKey = GlobalKey<NavigatorState>();

  @override
  Widget build(BuildContext context) {
    // make sure to close out all blocs to prevent memory leaks
    @override
    void dispose() {
      _themeBloc.close();
      super.dispose();
    }

    // Includes all blocs so they are available across the entire application
    return BlocProvider<ThemeBloc>(
      create: (context) => _themeBloc,
      child: BlocBuilder<ThemeBloc, ThemeState>(
        builder: (context, state) {
          if (state is ThemeStart) {
            _themeBloc.add(CheckTheme());
          } else if (state is ThemeLight) {
            s = state.themeData;
          } else if (state is ThemeDark) {
            s = state.themeData;
          }
          return MaterialApp(
            navigatorKey: navigatorKey,
            localizationsDelegates: [
              GlobalMaterialLocalizations.delegate,
              GlobalWidgetsLocalizations.delegate,
            ],
            supportedLocales: [
              const Locale('en', 'US'),
            ],
            debugShowCheckedModeBanner: false,
            title: "Clicket - Personal Budgeting",
            onGenerateRoute: (rt) {
              return MaterialPageRoute(
                builder: (context) {
                  return LoginMain();
                },
              );
            },
            theme: s,
          );
        },
      ),
    );
  }
}

If I remove the LogIn route and rerun it in xCode, I get this.

Second xCode error

Which is just as cryptic....

When I run things through android studio it doesnt give any insights at all...

NOthing in Android Studio

Even if I remove everything except for a basic scaffold, I still get the same second error as above. But if I create a new project with the same pubspec, it works just fine.

Any help would be greatly appreciated.

So I found the issues...

it had to do with a bad line in the info.plist file.

I had this..

<key>NSAppTransportSecurity</key>
    <true/>

and it should be this...

<key>NSAppTransportSecurity</key>
    <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
    </dict>

Lesson learned - dont just blindly copy code you find on the internet:-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM