Invalid redeclaration of 'SwiftEntryPlugin' - ios

I developed a flutter app on an Ubuntu machine and it works without problems on Android. Now I am trying to run it on iOS from a Mac but when I start debugging, I get several errors like the following:
/opt/flutter/.pub-cache/hosted/pub.dartlang.org/entry-0.0.2_2/ios/Classes/SwiftAnimateInPlugin.swift:4:14: error: invalid redeclaration of 'SwiftEntryPlugin'
public class SwiftEntryPlugin: NSObject, Flutter Plugin {
^
flutter doctor passes for Flutter, Xcode, and Connected device.
Flutter 2.2.0 - channel stable
Tools - Dart 2.13.0
I have checked this question but they are not using Flutter and the answers are not relevant as far as I can tell. What would cause this error and how might I resolve it?

Taking Nisanth Reddy's advice from the comment above and grepping for SwiftEntryPlugin: NSObject my search was narrowed down to 2 files. The files were ./my-app/ios/.symlinks/plugins/entry/ios/Classes/SwiftEntryPlugin.swift and ./my-app/ios/.symlinks/plugins/entry/ios/Classes/SwiftAnimateInPlugin.swift. After some trial and error, it seems like both files are required (the redundant one being required by a particular Flutter package I'm using, I think) but both had the exact same code in them so I removed all the code from one of the files but left the empty file sitting there in the directory and the problem was resolved.

Related

How to test if flag BUILD_LIBRARY_FOR_DISTRIBUTION = TRUE works

I got a complaint from a client that library i made was throwing an error when they try to import it. Error is saying: "Module compiled with Swift 5.3 cannot be imported by the Swift 5.4 compiler". After some research i found out about ABI, and I understand the cause of this error.
Now I want to test if this solution works before shipping the fix. I downloaded a few older toolchain versions hoping that by switching them I could simulate this kind of situation. Setting the distribution flag for the library, building it with older toolchain and then importing it to a project with newest version of toolchain. However I still get the same error. Im I doing this right? What I am missing?

the Dart compiler exited unexpectedly

I was debugging my project. After some execution, it started showing an error saying that the Dart compiler exited unexpectedly (see screenshot below). I also updated my dart SDK, but nothing happened. I did search on Google, but found nothing that helped.
try this may help
flutter clean
This issue could also happen when you have migrated to Null-Safety. The reason is that when migrating to Null-Safety, all packages need to also be migrated to Null-Safety, thus it will return an error saying:
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
Also, it will give you a link for you to reference:
For solutions, see https://dart.dev/go/unsound-null-safety
Unhandled exception:
Bad state: Unsupported Null Safety mode NonNullableByDefaultCompiledMode.Invalid, in null.
Since this issue results in an error, you won't be able to run your project or package unless all packages in your dependencies are null-safety migrated. The dart compiler will end after this.
the Dart compiler exited unexpectedly.
Failed to compile application.
Exited (sigterm)
If you get the issue and you are sure that all packages are up-to-date and that all support Null-Safety, try running flutter clean. This will clear or packages in your project and reinstall them, cache files will also be removed.
Please leave down a comment if you may have any suggestions, or edit this answer if you wish.
I had this problem after adding package golden_toolkit and one golden test I wrote for it. Removing the test file and the dependency from pubspec.yaml and then running flutter clean, flutter pub get fixed it.
In my case flutter clean cant help. My flutter/bin/cache folder was corrupted. Deleting flutter/bin/cache folder and then running command flutter, downloads dart SDK and then setting up the flutter sdk path by giving your flutter folder path in Android Studio -> Preferences -> Languages and Frameworks -> Flutter , solves my problem.
delete flutter/bin/cache then type in terminal flutter clean then flutter run
that's work for me
My case was really strange and I don't know were it comes from, is it VS or Dart
The point is somewhere here where I set my class as the generic of the base class: class MyClass extends MyBaseClass<MyClass> and add an instance to the VS WATCH and set a beark point after the instance creation.
class MyBaseClass<T> {}
class MyClass extends MyBaseClass<MyClass> {
#override
String toString() => "MyClassObject";
}
main() {
MyClass o = MyClass();
print(o); // If you add 'o' to your WATCH items and add a breakpoint here it will crash
}
if you add any packages it can be the problem.
just use
flutter clean
flutter pub get
flutter run

Why Flutter copies the src of standard libraries to sky_engine?

Since dart:ffi is available from Dart 2.2.0-dev.2.0, I've been trying to use that library. The sample app works fine for me and I also tried to use it for my Flutter app but I couldn't call it with import "dart:ffi", although Flutter on my machine was HEAD of master that used Dart 2.3.0-dev.0.0.
I checked what happened, then I found that sky_engine didn't contain ffi.dart while it contained other libraries (e.g. "dart:core"). Also I noticed that the source files of those libraries were copied from $FLUTTER_ROOT/bin/cache/dart-sdk/lib to $FLUTTER_ROOT/bin/cache/pkg/sky_engine using BUILD.gn or _embedder.yaml and that seemed to be why I couldn't use the dart:ffi in my Flutter app.
However, in the first place, why does Flutter need sky_engine, which is "the interface between Dart and the Flutter Engine"? Why not calling them directly without this glue code?
Flutter has a good documentation for FFI to be able to call native C APIs. Adding import 'dart:ffi' as ffi; on the Flutter app works without issues as of my testing with Flutter 2.5. If you're able to provide a minimal repro of your issue, this will help folks to understand the question better.
As for the question on why sky_engine is used by Flutter, that's just simply because it's the "flutter_engine" - similar to what has been already mentioned in the comments.

Build failed - Check imports - Dart Angular Tutorial - angular_tour_of_heroes - part 2

While following tutorail - Angular-dart tutorial - Tour of Heroes - part 2
with using IntelliJ IDEA in Windows 10 while using chrome, I got following error(s) -
[SEVERE] build_web_compilers|entrypoint on web/main.dart (cached):
Unable to find modules for some sources, this is usually the result of either a
bad import, a missing dependency in a package (or possibly a dev_dependency
needs to move to a real dependency), or a build failure (if importing a
generated file).
Please check the following imports:
import 'package:angular_app/app_component.css.shim.dart' as import0; from angular_app|lib/app_component.template.dart at 12:1
[SEVERE] Failed after 1.3s
Serving web on http://localhost:53323
I have checked multiple times & I have replaced all - 5 files - namely
lib/app_component.css, lib/app_component.dart, lib/app_component.html, lib/src/hero.dart & lib/src/mock_heroes.dart from Review the app structure but I am still getting the above mentioned error & -
I could not find any app_component.template.dart
Nor could found any instance of imported package:angular_app/app_component.css.shim.dart or shim using IntelliJ Find in Path (Ctrl+Shift+F)
I have tried to delete build and rebuild.
I have also re-installed dart 2.1.0 using windows package manager & changed the location of dart-sdk accordingly in IntelliJ IDEA Settings/Dart, as for brief period I was getting dart-sdk error, but that is fixed.
This my first time asking question on stacksoverflow, but I have checked similar questions, could not resolve that issue.
the most likely reason for that build failure is due to the stylesUrls files not being found. This could be because the name in that array doesn't match the name in the file system or is not the expected place in the file system.
To confirm, I started from scratch, downloaded the quickstart-master.zip to get the project structure.
And followed the steps all the way through the step you were stuck on.
The only time I was able to generate that error while following the steps is when I added thestyleUrls: ['app_component.css'], to app_component.dart prior to creating the file.
I got the same:
[SEVERE] build_web_compilers|entrypoint on test/app_test.dart.browser_test.dart:
Unable to find modules for some sources, this is usually the result of either a
bad import, a missing dependency in a package (or possibly a dev_dependency
needs to move to a real dependency), or a build failure (if importing a
generated file).
Please check the following imports:
import 'package:angular_app/app_components.css.shim.dart' as import0; from angular_app|lib/app_component.template.dart at 12:1
Once i created the css file, the error went away and everything worked fine.
I completed the entire step you were up to and my app was working fine.
I then did as you did and copied each file from the step and replaced my work with it, still worked.
So confirm my hunch, i changed the name of the css file, and received the same error.
regarding app_component.template.dart that file is auto generated by dart and can be found in your project under .dart_tool/build/generated/angular_app/lib
I had a very similar problem. I ran webdev build and then webdev serve and it fixed it right up.

Couldn't get Xamarin projects working with Rider-EAP on OSX

I was really excited, when JetBrains launched the Project Rider-EAP. First thing I've tried was to get a Xamarin-iOS project to run in Rider-EAP, but it doesn't work out of the box.
Update 1: This issue is now listed as critical bug with fix in EAP 2: https://youtrack.jetbrains.com/issue/RIDER-618
1. Problem (fixed) Projects didn't load with the exception that Xamarin.iOS.targets could not be found.
I fixed this with a simple Symlink:
ln -s /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/ “/Applications/Rider EAP.app/Contents/lib/ReSharperHost/macos-x64/mono/lib/mono/xbuild/”
2. Problem
References are not loaded correctly. Therefore the whole syntax highlighting and everything beyond is broken.
See screenshot: References are not loaded correctly
I get the following error as well:
Error:null: Error initializing task MakeDir: Could not load file or assembly '/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Tasks.dll' or one of its dependencies
Switching the xbuild to mono 4.2.2 removes the error but not solves the problem.
PS: It seams that the references are loaded correctly for Xamarin Android projects.
Basic Xamarin Support like open and build is added with EAP 8 of Project Rider.
More advanced features will come with the next Builds and are tracked here: https://youtrack.jetbrains.com/issue/RIDER-1533

Resources