Xcode Error: Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibility56 When Building Flutter iOS App

I’m encountering an error when trying to build my Flutter iOS app for the simulator. The build fails with the following error message:

Error (Xcode): Undefined symbol: __swift_FORCE_LOAD_$_swiftCompatibility56

Could not build the application for the simulator.

Environment:

  • Flutter Version: 3.22.2

  • Xcode Version: 14.2.0

  • CocoaPods Version: 1.15.2

  • iOS Deployment Target: 15.0

  • Swift Version: 5.0

    dependencies:
      cupertino_icons: ^1.0.6
      firebase_core: ^3.1.1
      firebase_auth: ^5.1.1
      google_sign_in: ^6.2.1
      another_flutter_splash_screen: ^1.2.0
      google_nav_bar: ^5.0.6
      provider: ^6.1.2
      flutter_splash_screen: ^3.0.0
      sign_in_button: ^3.2.0
      cloud_firestore: ^5.0.2
      intl: ^0.19.0
      image_picker: ^1.1.2
      permission_handler: ^11.3.1
      http: ^1.2.1
      device_preview: ^1.2.0
      firebase_messaging: ^15.0.2
      location: ^7.0.0
      url_launcher: ^6.0.20
      google_maps_flutter: ^2.7.0
    
    
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);

  try {
    await Firebase.initializeApp(
      options: DefaultFirebaseOptions.currentPlatform,
    );
  } catch (e) {
    print("Error initializing Firebase: $e");
    return;
  }

  runApp(MyApp());
}

Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  await Firebase.initializeApp();
  print("Handling a background message: ${message.messageId}");
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  Future<String> getCurrentUserId() async {
    final user = FirebaseAuth.instance.currentUser;
    if (user == null) {
      return '';
    }
    return user.uid;
  }

  @override
  Widget build(BuildContext context) {
    return FutureBuilder<String>(
      future: getCurrentUserId(),
      builder: (context, snapshot) {
        if (snapshot.connectionState == ConnectionState.waiting) {
          return const MaterialApp(
            debugShowCheckedModeBanner: false,
            home: Scaffold(
              body: Center(
                child: CircularProgressIndicator(),
              ),
            ),
          );
        } else if (snapshot.hasError) {
          print("Error getting user ID: ${snapshot.error}");
          return const MaterialApp(
            debugShowCheckedModeBanner: false,
            home: Scaffold(
              body: Center(
                child: Text('Failed to get user ID'),
              ),
            ),
          );
        } else if (!snapshot.hasData || snapshot.data!.isEmpty) {
          print("No user ID available");
          return const MaterialApp(
            debugShowCheckedModeBanner: false,
            home: AuthPage(),
          );
        } else {
          final userId = snapshot.data!;
          return MultiProvider(
            providers: [
              ChangeNotifierProvider<BalanceNotifier>(
                create: (context) => BalanceNotifier(userId),
              ),
              ChangeNotifierProvider<Cart>(
                create: (context) => Cart(),
              ),
              ChangeNotifierProvider<ThemeNotifier>(
                create: (context) => ThemeNotifier(),
              ),
            ],
            child: Consumer<ThemeNotifier>(
              builder: (context, themeNotifier, child) {
                return MaterialApp(
                  debugShowCheckedModeBanner: false,
                  theme: lightMode,
                  darkTheme: darkMode,
                  themeMode: themeNotifier.currentTheme,
                  initialRoute: '/',
                  routes: {
                    '/': (context) => const SplashScreen(),
                    '/ProfilePage': (context) => ProfilePage(),
                  },
                  onGenerateRoute: (settings) {
                    if (settings.name == '/TransfertPage') {
                      final args = settings.arguments as Map<String, dynamic>;
                      return MaterialPageRoute(
                        builder: (context) => TransfertPage(
                          total: args['total'],
                          userId: args['userId'],
                          pinController: args['pinController'],
                        ),
                      );
                    }
                    return null;
                  },
                );
              },
            ),
          );
        }
      },
    );
  }
}
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:firebase_messaging/firebase_messaging.dart';

class AuthService {
  // Google Sign In
  Future<UserCredential> signInWithGoogle() async {
    // Trigger the authentication flow
    final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();

    // Obtain the auth details from the request
    final GoogleSignInAuthentication googleAuth =
        await googleUser!.authentication;

    // Create a new credential
    final credential = GoogleAuthProvider.credential(
      accessToken: googleAuth.accessToken,
      idToken: googleAuth.idToken,
    );

    // Once signed in, return the UserCredential
    return await FirebaseAuth.instance.signInWithCredential(credential);
  }
}

Future<void> _updateDeviceToken(String userId) async {
  String? deviceToken = await FirebaseMessaging.instance.getToken();
  if (deviceToken != null) {
    await FirebaseFirestore.instance.collection('users').doc(userId).update({
      'deviceToken': deviceToken,
    });
  }
}

Steps Taken to Resolve the Issue:

  1. Updated iOS Deployment Target to 15.0:

    • Modified Podfile to set platform :ios, '15.0'.

    • Updated Xcode project settings to set iOS Deployment Target to 15.0.

  2. Cleaned and Reinstalled Dependencies:

    • Ran flutter clean.

    • Deleted Pods and Podfile.lock.

    • Ran pod install.

  3. Verified Compatibility of Dependencies:

    • Checked all dependencies to ensure they are compatible with Swift 5 and iOS 15.0.
  4. Modified Build Settings in Xcode:

    • Ensured Swift Language Version is set to 5.0.

    • Added $(inherited) to Framework Search Paths and Other Linker Flags.

Despite these steps, the issue persists. Any help or suggestions would be greatly appreciated.

Error (Xcode): Undefined symbol: __swift_FORCE_LOAD_$_swiftCompatibility56 Could not build the application for the simulator.

Thank you for your assistance!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật