I'm working on a Web/Windows/Android app and to play a soundbite I am using just_audio. However, just_audio for windows is deprecated.
To work around this I want to use Dart_VLC for windows only. However, if it is imported at all, the app will crash with the following error (full trace https://pastebin.com/qNrW3ghK):
LateInitializationError: Field 'dynamicLibrary' has not been initialized.
I've found that conditional imports resolve this to an extent.
import 'metronome_finder.dart'
if (dart.library.io) 'windows_metronome.dart'
if (dart.library.js) 'generic_metronome.dart';
This (and an abstract, two classes, and a stub) works for Web/Windows. However, on android, it appears dart.library.io is loaded and dart_vlc will be imported as well, crashing the app with the above error. Is there a way to import the windows metronome only on windows (and thus dart_vlc) and generic on all other platforms?
Alternatively is there another cleaner way to resolve this issue?
I've also asked this question on reddit and thanks in part to /u/bsutto there is now a solution (or a workaround).
I've written an example based on my own project. The core revelation here is that the import of dart_vlc breaks compilation on web, but the initialization of dart_vlc crashes during runtime. As a result it is possible to use conditional imports to direct web towards just_audio; and a runtime Platform.isWindows check to redirect android to JustAudio.
The major downside to this is that the entirety of dart_vlc is compiled into the andoird app as well, I think. Please correct me if I am wrong.
Related
My code show this error. I didn't use "flutter_secure_storage" dependency but it shows this error. But the app is working well, What is the reason for this and how to fix this also if didn't fix this, the effect of this error?
flutter_secure_storage is a plugin which uses platform specific APIs to interact with the device.
This warning suggests that it is using a deprecated Java API on the Android device. You can't really fix it unless you know Java and are willing to contribute to the plugin. At the same time, you can safely-ish ignore it for now: even deprecated APIs usually last a long time, and it won't affect any functioning until the underlying API is actually removed.
The best thing to do is regularly check for updates to the package, which might fix this warning.
As the error suggests, the package flutter_secure_storage use the file specified in the error, which in turn use or implements a deprecated API.
You might not use that plugin, but you are using some other plugin that use it.
You are not affected by it now because it is just a warning/information.
You could get affected by it when the depreciation goes to be removed instead. But by that time the package will have been updated. So all you have to do is update the package at a later time when said deprecation has been solved.
I'm trying to import an SPM package in Xcode11. I can fetch the library and see it in the project as Swift Package Dependencies but when trying to import, Xcode doesn't find it.
I read that the problem could be custom configurations and not the standard e.g. Debug.
Does anyone know how to solve this without renaming the configuration names?
The best advice at the moment is this post on the Swift forums where Ankit says:
This is a known issue that Apple folks are tracking internally. Currently, Swift packages default to the "Release" configuration when anything other than Debug and Release is used. In theory, adding $(BUILD_DIR)/Release to SWIFT_INCLUDE_PATHS build setting for the custom configurations should work around this issue but it can lead to some weird errors in case something unexpected gets picked from that directory.
I have recently switch from Android Studio to VS Code to work on my Flutter projects but I have an issue with it.
VS Code keeps adding "prefix0." before all classes as soon as I am using auto-completion and I didn't find a way to get rid of it.
I have seen that some VS extensions for CSS can auto-prefix some parts of code but I do not have any CSS extensions.
Thanks
It's a bug in Dart Code that happened because it failed to understand another import already exported the class used.
A typical example is, flutter/material.dart was already imported. But by typing Widget, it'd import flutter/widget.dart and with a prefix.
https://github.com/Dart-Code/Dart-Code/issues/1847
This has been fixed. Upgrading your Dart Code and flutter SDK should fix the issue.
The issue is caused by there being one or more duplicates of class names. Check that you do not have classes with the same name imported that may conflict with each other.
im using a script in my project and in this script for solve a simple math equation same "1+2-2+1" from string input i use
ExpressionEvaluator.Evaluate
but this is in unityeditor class and when i build my project i reach an error that is say
"The name "ExpressionEvaluator" does not exist in the current context."
i handle this error with using Platform Dependent Compilation https://docs.unity3d.com/Manual/PlatformDependentCompilation.html but when i try to install apk i reach an error on android device and device say the application is not install.
now my question is that,is there any alternative for ExpressionEvaluator.Evaluate or any suggestion that you can helm me with.
thank you so much.
I doubt the installation failure has anything to do with conditional compilation. I can't say much about that, but regarding ExpressionEvaluator, there is a lot of code in UnityEngine. If you were to bundle all that code with your game, you'd get a multi-hundred megabyte apk on your hands; not to mention that most of the code is probably native and they don't/can't build it for all target platforms, only editor platforms (Windows, MacOS).
You really shouldn't use UnityEditor code in your game logic, not even in the editor. If you use UnityEditor it should only be in editor code. If something's in UnityEditor and you need to support it at runtime, you should find a library that does the same, or write it yourself. You can search for one online or on SO. Here's the first result from a Google search:
I need a fast runtime expression parser
I'm exploring Swift with Xcode-6 and so far so good although I think the new collections need a little bit of work as I've managed to break the compiler a few times.
Problem is I'm now stuck trying to create the framework package to then use in another project. The project builds without issue and all tests pass successfully. When I go to create Archive (which I assume is what is required) I receive the error:
:0: error: underlying Objective-C module 'Sample' not found
Now I assume this has something to do with the contents of my Sample.h which tells me
// In this header, you should import all the public headers of your framework using statements like #import <Sample/PublicHeader.h>
which is fine except I have only used swift enums, structs and classes for this framework so therefore no .h files exist.
Can anyone shed some light on this one as I can't find any documentation available yet?
EDIT (7/27/2018)
The information in the answer below may no longer be accurate. Your mileage may vary.
I sat down with an engineer and asked this exact question. This was their response:
Xcode 6 does not support building distributable Swift frameworks at this time and that Apple likely won't build this functionality into Xcode until its advantageous for them to do so. Right now, Frameworks are meant to be embedded in your app's project, rather than distributed. If you watch any of the session videos or see the sample projects, this is always the arrangement. Another reason is that Swift is very new and likely to change. Thus your Swift-based framework is not guaranteed to work on the platform you originally built it on.
Slight Update
The engineer mentioned that it's not impossible to make a framework for distribution, just that it's not supported.
I was able to get past the error by going to the target for the framework and on the Build Phases tab under Headers, remove the MyFramework.h file
However I was getting the "Underlying Objective-C module not found" error when I was using a framework to share code between a containing app and an app extension, both of which were pure Swift.
Assuming you are creating a truly pure Swift module, you must disable the Objective-C Compatibility Header and any generated interface headers so the compiler doesn't go off assuming it can find an Objective-C module for the framework.
Do Not remove your public framework header. You'll get a module-map warning at link time if you do.
You might find this useful: Creation of pure swift module
In short: it's possible to make static framework, but there is one issue: it doesn't work in end user' project if "ProjectName-Swift.h" header included.
But, it works fine if you use only swift.
I think it's a bug in XCode 6, or that Apple does not allow archiving the Framework from XCode while in beta.
If you compile to profile XCode generates the framework correctly. (See the Release folder created in DerivedData)