CocoaPods 找不到 pod“Firebase/Database”的兼容版本:

时间:2021-05-13 19:47:46

标签: firebase flutter firebase-realtime-database firebase-authentication geofire

我正在开发一个颤振应用程序。我按照 firebase 和 geofire 说明将它们都添加到我的 pubspec.yaml 文件中,并在我的代码中适当地使用它们。下面是我的错误输出,然后是我的 pubspec.yaml 文件、Podfile 和我调用 Geofire 的 hometab.dart 文件。数周以来,我一直试图解决这个问题,但似乎无法弄清楚我做错了什么。任何帮助将非常感激。如果需要更多信息,请告诉我。

    Analyzing dependencies
firebase_auth: Using Firebase SDK version '7.11.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '7.11.0' defined in 'firebase_core'
firebase_database: Using Firebase SDK version '7.11.0' defined in 'firebase_core'
[!] CocoaPods could not find compatible versions for pod "Firebase/Database":
  In Podfile:
    firebase_database (from `.symlinks/plugins/firebase_database/ios`) was resolved to 6.1.2, which depends on
      Firebase/Database (= 7.11.0)

    flutter_geofire (from `.symlinks/plugins/flutter_geofire/ios`) was resolved to 0.0.1, which depends on
      GeoFire (~> 4.0) was resolved to 4.1.0, which depends on
        Firebase/Database (~> 6.0)

pubspec.yaml

name: Driver
description: App

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2
  firebase_core: ^1.1.1
  firebase_auth: ^1.1.4
  firebase_database: ^6.1.2
  google_maps_flutter: ^2.0.3
  geolocator: ^7.0.3
  provider: ^5.0.0
  flutter_polyline_points: ^1.0.0
  font_awesome_flutter: ^9.0.0
  animated_text_kit: ^4.2.0
  connectivity: ^3.0.3
  http: ^0.13.3
  flutter_geofire: ^2.0.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_launcher_icons: ^0.9.0

flutter_icons:
  image_path: "assets/appstore.png"
  ios: true
  android: true

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  assets:
    - images/

  fonts:
    - family: Brand-Bold
      fonts:
        - asset: fonts/bolt-semibold.ttf
    - family: Brand-Regular
      fonts:
        - asset: fonts/bolt-regular.ttf
    - family: Montserrat
      fonts:
        - asset: fonts/Montserrat-Medium.ttf
    - family: Montserrat
      fonts:
        - asset: fonts/Montserrat-Regular.ttf
  

Podfile

# Uncomment this line to define a global platform for your project
platform :ios, '10.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.4'
    end
  end
end

hometab.dart

import 'dart:async';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
import 'package:flutter_geofire/flutter_geofire.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:Driver/BrandColors.dart';
import 'package:Driver/datamodels/driver.dart';
import 'package:Driver/globalvariables.dart';
import 'package:geolocator/geolocator.dart';
import 'package:Driver/main.dart';
import 'package:Driver/widgets/AvailabilityButton.dart';

class HomeTab extends StatefulWidget {
  @override
  _HomeTabState createState() => _HomeTabState();
}

class _HomeTabState extends State<HomeTab> {

  GoogleMapController mapController;
  Completer<GoogleMapController> _controller = Completer();

  Position currentPosition;
  var geoLocator = Geolocator();

  void getCurrentPosition() async {
    Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
    currentPosition = position;
    LatLng pos = LatLng(position.latitude, position.longitude);
    CameraPosition cp = new CameraPosition(target: pos, zoom: 14);
    mapController.animateCamera(CameraUpdate.newCameraPosition(cp));
    getCurrentPosition();
  }

  final CameraPosition _kGooglePlex = CameraPosition(
    target: LatLng(37.42796133580664, -122.085749655962),
    zoom: 14.4746,
  );

  void getCurrentDriverInfo () async {
    currentFirebaseUser = await FirebaseAuth.instance.currentUser;
    DatabaseReference driverRef = FirebaseDatabase.instance.reference().child(
        'skapers/${currentFirebaseUser.uid}');
    driverRef.once().then((DataSnapshot snapshot) {
      if (snapshot.value != null) {
        currentDriverInfo = Landscaper.fromSnapshot(snapshot);
        print(currentDriverInfo.fullName);
      }
    });
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getCurrentDriverInfo();
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        GoogleMap(
          myLocationEnabled: true,
          myLocationButtonEnabled: true,
          zoomControlsEnabled: true,
          zoomGesturesEnabled: true,
          mapType: MapType.satellite,
          initialCameraPosition: _kGooglePlex,
          onMapCreated: (GoogleMapController controller){
            _controller.complete(controller);
            mapController = controller;
            getCurrentPosition();
          },
        ),
        Container(
          height: 135,
          width: double.infinity,
          color: Colors.white,
        ),

        Positioned(
          top: 60,
          left: 0,
          right: 0,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              AvailabilityButton(
                title: 'GO ONLINE',
                color: BrandColors.colorPrimary,
                onPressed: (){
                  goOnline();
                },
              ),
            ],
          ),
        )
      ],
    );
  }

  void goOnline(){
    Geofire.initialize('driversAvailable');
    Geofire.setLocation(currentFirebaseUser.uid, currentPosition.latitude, currentPosition.longitude);

    jobRequestRef = FirebaseDatabase.instance.reference().child('drivers/${currentFirebaseUser.uid}/newjob');
    jobRequestRef.set('waiting');
    jobRequestRef.onValue.listen((event) { });
  }
}

0 个答案:

没有答案