Cannot build flutter ios after clean up flutter cache - ios

I try to clean up my mobile flutter project: remove Podfile.lock, Podfile, .pub-cache
And then try to run flutter pub get. After than, when run flutter run I get this kind of error below. I still don't know how to fix:
../../../../Software/flutter/.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_pdfviewer-20.2.48-beta/lib/src/common/pdfviewer_plugin.dar
t:88:40: Error: The getter 'Uint8List' isn't defined for the class 'PdfViewerPlugin'.
- 'PdfViewerPlugin' is from 'package:syncfusion_flutter_pdfviewer/src/common/pdfviewer_plugin.dart'
('../../../../Software/flutter/.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_pdfviewer-20.2.48-beta/lib/src/common/pdfviewer_plugin.
dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'Uint8List'.
_renderedPages![pageIndex] = Uint8List.fromList(image);
^^^^^^^^^
../../../../Software/flutter/.pub-cache/hosted/pub.dartlang.org/fl_chart-0.46.0/lib/src/chart/pie_chart/pie_chart.dart:42:20: Warning:
Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart'
('../../../../Software/flutter/packages/flutter/lib/src/widgets/binding.dart').
WidgetsBinding.instance?.addPostFrameCallback((_) {
^
../../../../Software/flutter/.pub-cache/hosted/pub.dartlang.org/syncfusion_pdfviewer_platform_interface-20.2.48-beta/lib/src/method_channel_p
dfviewer.dart:12:7: Error: 'Uint8List' isn't a type.
Uint8List documentBytes, String documentID) async {
^^^^^^^^^
../../../../Software/flutter/.pub-cache/hosted/pub.dartlang.org/syncfusion_pdfviewer_platform_interface-20.2.48-beta/lib/src/method_channel_p
dfviewer.dart:35:34: Error: 'Uint8List' isn't a type.
return _channel.invokeMethod<Uint8List>('getImage', <String, dynamic>{
^^^^^^^^^
Failed to package /Users/hoang/Works/Projects/unikgate/erest/erest_mobile.
Command PhaseScriptExecution failed with a nonzero exit code
Here is my flutter doctor -v
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.1, on macOS 12.1 21C52 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Community Edition (version 2021.1)
[✓] VS Code (version 1.71.0)
Can some one help me to solve this? Many thanks!

Related

XCODE COMPILE ERROR ON SMS_ADVANCED PLUGIN

Hi all,
Trying compile my app, generates an error in Xcode. My app works fine
till I add sms_advanced plugin, I use exactly the code given in sample
example for sending sms via IPHONE (IOS build).
Here are flutter doctor, logs of compile and code used to send an SMS.
Flutter doctor : Flutter doctor log: % flutter doctor Doctor summary
(to see all details, run flutter doctor -v): [✓] Flutter (Channel
master, 2.6.0-12.0.pre.837, on macOS 11.6.1 20G224 darwin-arm, locale
en-FR) [✓] Android toolchain - develop for Android devices (Android
SDK version 31.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.1)
[✓] Chrome - develop for the web [✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.62.3) [✓] Connected device (2 available)
Compile log:
Running Xcode build... Xcode build done. 11.1s Failed to build iOS app
Error output from Xcode build: ↳
** BUILD FAILED **
Xcode's output: ↳
/Users/theUser/.pub-cache/hosted/pub.dartlang.org/sms_advanced-1.0.1/ios/Classes/SmsAdvancedPlugin.m:13:4:
error: unknown receiver 'SwiftSmsAdvancedPlugin'; did you mean
'SmsAdvancedPlugin'? [SwiftSmsAdvancedPlugin
registerWithRegistrar:registrar]; ^~~~~~~~~~~~~~~~~~~~~~
SmsAdvancedPlugin In file included from
/Users/theUser/.pub-cache/hosted/pub.dartlang.org/sms_advanced-1.0.1/ios/Classes/SmsAdvancedPlugin.m:1:
/Users/theUser/.pub-cache/hosted/pub.dartlang.org/sms_advanced-1.0.1/ios/Classes/SmsAdvancedPlugin.h:3:12:
note: 'SmsAdvancedPlugin' declared here #interface SmsAdvancedPlugin :
NSObject ^ 1 error generated. note: Using new build system note:
Planning note: Build preparation complete note: Building targets in
parallel
Could not build the precompiled application for the device.
Error launching application on iPhone.
SAMPLE CODE:
void main() {
SmsSender sender = new SmsSender();
String address = someAddress();
SmsMessage message = new SmsMessage(address, 'Hello flutter world!');
message.onStateChanged.listen((state) {
if (state == SmsMessageState.Sent) {
print("SMS is sent!");
} else if (state == SmsMessageState.Delivered) {
print("SMS is delivered!");
}
});
sender.sendSms(message);
}
Can someone help me how to solve this issue please?

flutter sdk 2.5.3 permission_handler(^8.2.5) status has wrong value

After upgrading flutter version from 2.2 to 2.5.3, permission_handler behaves abnormally.
PermissionStatus status = await Permission.photos.status;
print('## deny: ${status.isDenied}');
print('## grant: ${status.isGranted}');
print('## limit: ${status.isLimited}');
print('## permanently deny: ${status.isPermanentlyDenied}');
print('## restrict: ${status.isRestricted}');
if (!status.isGranted) {
await showDialog(
Even though access to all photos is allowed, the result is as follows.
flutter: ## deny: true
flutter: ## grant: false
flutter: ## limit: false
flutter: ## permanently deny: false
flutter: ## restrict: false
https://pub.dev/packages/permission_handler
I checked the above documentation but couldn't find a solution.
flutter doctor
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.5.3, on macOS 11.6 20G165 darwin-x64, locale ko-KR)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] Connected device (2 available)
! Doctor found issues in 1 category.

I cannot build the .ipa file

I'm developping an app with Flutter.
When I plug my iPhone and run the project, everything is good : I can use my app.
I want to deploy my app on the Apple Store with flutter build ipa.
When I run this command, I got errors :
Error output from Xcode build:
↳
objc[91511]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x20e856c10) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1215802b8). One of the two
will be used. Which one is undefined.
objc[91511]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x20e856c60) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x121580308). One of the two will be
used. Which one is undefined.
** ARCHIVE FAILED **
Xcode's output:
↳
/Users/aymeric/Git/Baggou/mobile/ios/Runner/GeneratedPluginRegistrant.m:12:9: fatal error: module 'cloud_firestore' not found
#import cloud_firestore;
~~~~~~~^~~~~~~~~~~~~~~
1 error generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Analyzing workspace
note: Constructing build description
note: Build preparation complete
Encountered error while archiving for device.
I tried to deintegrate all my pods, update them ... but nothing works.
My flutter doctor :
[✓] Flutter (Channel stable, 2.5.0, on macOS 11.4 20F71 darwin-arm, locale fr-FR)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] Android Studio (version 4.1)
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.2)
[✓] VS Code (version 1.54.1)
[✓] Connected device (2 available)
! Doctor found issues in 1 category.
I don't know if it's relevant, but I use a MacBook Pro with the M1 chip.
Also, I already done this command for another flutter project with the same machine and it was working.
If you want to know my dependencies :
name: baggou
description: Ne restez plus sur la touche.
version: 0.0.40+42
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# GetX
get: "3.26.0"
get_storage: any
# Firebase
firebase_core: "^1.3.0"
firebase_analytics: "^8.1.2"
firebase_auth: "^1.4.1"
google_sign_in: "5.0.4"
cloud_firestore: "^2.2.2"
firebase_storage: "^8.1.3"
firebase_messaging: "^10.0.2"
# Dependencies
fluttertoast: ^7.1.6
loading: ^1.0.2
carousel_slider: "3.0.0"
image_picker: "0.7.4"
flutter_launcher_icons: ^0.9.0
persistent_bottom_nav_bar: "4.0.2"
flutter_localizations:
sdk: flutter
cupertino_icons: ^1.0.2
flutter_phoenix: "1.0.0"
csc_picker: ^0.2.5
url_launcher: any
introduction_screen: "2.1.0"
smooth_star_rating: "1.1.1"
# Google Maps
google_maps_flutter: "2.0.10"
google_maps_place_picker: "2.1.0-nullsafety.3"
flutter_credit_card: ^2.0.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_icons:
image_path: "assets/baggou-icon.png"
android: true
ios: true
I found the solution in Xcode. Need to set the correct version.

FlutterFire Firebase_ml_vision: PlatformException(Error 13, com.firebase.ml, Barcode engine is nil., null)

I've been using the 'firebase_ml_vision' package to scan Qr codes in an Image Stream provided by the 'camera' package. Everything was fine until the update that happened in Nov. 6. In Android, I can still scan qr codes without problems. But in iOS, i'm having the app is throwing the Exception: PlatformException(Error 13, com.firebase.ml, Barcode engine is nil., null)
I've updated my podfile with the line pod 'GoogleMLKit/BarcodeScanning', because the command 'flutter build ios' finished with an error when the Podfile had pod 'Firebase/MLVisionBarcodeModel' instead. I did because the pod update command explained that the package 'Firebase/MLVisionBarcodeModel' was deprecated, and thought it was the source of the problem.
Still the problem keeps happening.
Flutter doctor -v output:
[✓] Flutter (Channel stable, 1.22.4, on Mac OS X 10.15.6 19G73 darwin-x64, locale en-EC)
• Flutter version 1.22.4 at /Applications/flutter_sdk/jaime/flutter
• Framework revision 1aafb3a8b9 (3 weeks ago), 2020-11-13 09:59:28 -0800
• Engine revision 2c956a31c0
• Dart version 2.10.4
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/jvasquez/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.1, Build version 12A7403
• CocoaPods version 1.10.0
[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 46.0.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.51.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.16.0
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
This is the code I use to analyze the CameraImage:
static Future<List<Barcode>> detect({
#required CameraImage image,
// #required BarcodeDetector detector,
#required int imageRotation,
}) async {
var rp = List<Barcode>();
try {
BarcodeDetector detector = FirebaseVision.instance.barcodeDetector(
BarcodeDetectorOptions(
barcodeFormats: BarcodeFormat.qrCode,
)
);
var metadata = _buildMetaData(image, _rotationIntToImageRotation(imageRotation));
FirebaseVisionImage visionImage = FirebaseVisionImage.fromBytes(_concatenatePlanes(image.planes), metadata);
rp = await detector.detectInImage(visionImage);
} catch (ex) {
print("Ocurrió un error: $ex");
// UtilFunctions.escribirEnLog(
// mensaje: "$ex",
// nombreFuncion: "detect",
// tipo: 0,
// );
}
return rp;
}
static Uint8List _concatenatePlanes(List<Plane> planes) {
final WriteBuffer allBytes = WriteBuffer();
for (Plane plane in planes) {
allBytes.putUint8List(plane.bytes);
}
return allBytes.done().buffer.asUint8List();
}
The problem is, that firebase_ml_vision internally uses Firebase/MLVisionBarcodeModel and not GoogleMLKit/BarcodeScanning.
In the issue https://github.com/FirebaseExtended/flutterfire/issues/4625 another user forked the firebase_ml_vision package and adjusted it to work with GoogleMLKit/BarcodeScanning. There is also a PR for this form (https://github.com/FirebaseExtended/flutterfire/pull/5378).
It is important to mention that some functionality, especially cloud functionality, has been removed to make it work.
Therefore, this could break parts of your app where these features are missing and it is yet not a great solution.
To use the forked package include the following in your Pubspec.yaml
firebase_ml_vision:
git:
url: git://github.com/algirdasmac/flutterfire
path: packages/firebase_ml_vision

mDns error on iOS - error 49 Can't assign requested address

I'm using the multicast_dns package for Flutter and get an exception on iOS.
It works as expected on Android. I have tested this with the code example provided with the package, see https://pub.dev/packages/multicast_dns
The error is:
OS Error: Can't assign requested address, errno = 49 in
_NativeSocket.joinMulticast. (socket_patch.dart)
I have tried various multicast addresses, the default 224.0.0.251, 230.180.0.1 and 239.0.180.1.
import 'package:multicast_dns/multicast_dns.dart';
Future<void> main() async {
const String name = '_dartobservatory._tcp.local';
final MDnsClient client = MDnsClient();
await client.start(mDnsAddress: InternetAddress('239.0.180.1'));
await for (PtrResourceRecord ptr in client
.lookup<PtrResourceRecord>(ResourceRecordQuery.serverPointer(name))) {
await for (SrvResourceRecord srv in client.lookup<SrvResourceRecord>(
ResourceRecordQuery.service(ptr.domainName))) {
final String bundleId =
ptr.domainName; //.substring(0, ptr.domainName.indexOf('#'));
print('Dart observatory instance found at '
'${srv.target}:${srv.port} for "$bundleId".');
}
}
client.stop();
print('Done.');
}
Flutter doctor:
mdnstest $ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.9.1+hotfix.4, on Mac OS X 10.14.5 18F203, locale
en)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
✗ Android licenses not accepted. To resolve this, run: flutter doctor
--android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
[✓] Android Studio (version 3.5)
[✓] Connected device (1 available)
! Doctor found issues in 1 category.

Resources