How to import AndroidViewBinding in jetpack compose - android-jetpack-compose

I'm trying to use some fragments within jetpack compose but I can not import AndroidViewBinding from (androidx.compose.ui.viewinterop) and it is always appearing as an unresolved name
how to import it ??

I just came against the same problem - unresolved. Turns out, we need to import:
implementation "androidx.compose.ui:ui-viewbinding:$compose_uiversion"
See here for more info - (latest stable version is 1.3.2)
Just another example where I wish they really made their documentation explicit about dependencies. This official documentation doesn't help.

Related

Xcode: SPM Package shows as No such module 'AsyncAlgorithms'

I'm trying to add the swift-async-algorithms package to my project using SPM. I add it the package:
I'm tried to import the package to my project:
Any of you knows how can I can fix this error?
I tried almost all the posible solitons in here but none of them work.
I'll really appreciate your help.
Based on your screenshots and your import, it looks like you're looking at two different git repos / SPM's.
The screenshot that you posted is for this repo: (swift-algorithms)
However you're trying to import from this repo: (swift-async-algorithms)
Both are Apple SPM's, but you added the wrong one. So you need to remove the first and use the second, and then you'll need to select which package products you want to use:

I have a Swift Package and I want to know how to get the current version of this package

Similar to how you get your apps version kCFBundleVersionKey how does one get the version of the package you are working in?
I don't think it's possible at the moment to get the value easily.
You can either read the Package.resolved file or you can set up a public constant where you would define the version of your library.
public let version = "0.0.1"
import MyLibrary
print(MyLibrary.version)
There isn't a standard way how to do this, every package could have a different constant (or not have it at all)
You can check package version rules in project package dependencies tab. Check screenshot below. Propably it would be sufficient for most use cases.
Edit: The context has changed, the question was to get the version of MyPackage I'm working on via code. There isn't any documented or recommended method as of now. Though this can be achieved by a hack through reading the Package.resolved file as mentioned by Malcolm.
I'm not deleting this answer for any future users who are looking for answer on how to get the exact latest version of a Package.
You can give the same major version number and give Update to latest package version option on Xcode. eg: If current version is 2.4.5 you just need to provide 2.0.0 and update. There is also an option to provide the exact version of swift package you need.

Adding support for SwiftPM to Swift Library

Last one hour or so I have been looking at how to add SwiftPM support to the open-source library.
I started mimicking Alamofire's Package.swift file.
// swift-tools-version:5.1
import PackageDescription
let package = Package(name: "MASegmentedControl",
platforms: [.iOS(.v10)],
products: [.library(name: "MASegmentedControl",
targets: ["MASegmentedControl"])],
targets: [.target(name: "MASegmentedControl",
path: "MASegmentedControl")],
swiftLanguageVersions: [.v4, .v4_2, .v5])
But when I am trying to add that to a test project as swift package I am getting error as shown below.
When I run swift package tools-version I get the output as 3.1.0. I am running Xcode 11.2.1.
I also tried looking at how to update swift package tool. I couldn't find anything on it.
I am wondering if anyone of you added SwiftPM support to your libraries, can please help me out. I am missing something but I can't put my finger on it.
Any help or pointers would be greatly appreciated.
Thanks a lot for reading my post.
I think that can be appeared due to one of the following:
1- Regarding the documentation, May you need to remove the "swiftLanguageVersions" key.
https://swift.org/blog/swift-package-manager-manifest-api-redesign/
The tools version also determines the default Swift language version
used to compile the package’s sources. Existing Swift 3 packages will
compile in Swift 3 compatibility mode. You can optionally use the
swiftLanguageVersions property in both Swift 3 and Swift 4 manifests
to set the language version used to compile that package, if you don’t
want the default version. This means it is possible to upgrade a
package to use the newer manifest format without upgrading its sources
to Swift 4.
2- Ensure the following format for the commented line, as follows:
// swift-tools-version:5.1
import PackageDescription
// swift-tools-version:. Packages that omit this special
comment will default to tools version 3.1.0.

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.

Resolving a dependency issue with a web app in Dart/Mojito

I recently stumbled across Dart, and got pretty excited about it because it almost feels like that perfect language I've always been looking for. I work with PHP at my job (Yes, I know, ew gross) as a web developer and was excited to try and build a web app using the language. Figured it couldn't be too hard as that's what Dart was originally made for. Turns out it more difficult than I though, and I can't even get off the ground. I was hoping someone else could help point me in the right direction.
So, I really haven't done any real coding in this project at all. I literally downloaded the Dart SDK, used stagehand to create web-simple project, then I added a bin/server.dart file to the project. The code in that file was pretty much taken straight out of the online documentation for the mojito package:
import 'package:mojito/mojito.dart';
main() {
var app = init();
app.router
..addStaticAssetHandler('/static');
app.start();
}
I added the dependency mojito: "^0.6.6" to the pubspec.yaml file as well of course. That's all I've done though, like I say, I haven't even managed to get off the ground yet.
When I run server.dart I get the following error:
'package:convert/src/percent/encoder.dart': malformed type: line 23 pos 13: cannot resolve class 'ChunkedConverter' from 'PercentEncoder'
I get the exact same error message if I try to build a server with the shelf_rest package instead of the mojito package.
A search of that error message doesn't bring up too much helpful info, though I found one forum where someone recommended adding convert: ^2.0.1 to the dependencies. Apparently there was a change made in that package that causes incompatibility with other packages. I tried that suggestion but it doesn't seem to be resolving the issue.
I'm certain the issue is some sort of dependency issue, I'm probably using a mix of dependencies that I guess just aren't meshing right. If someone could help me figure out what I'm doing wrong it would be much appreciated. I want to learn and start using Dart but obviously I'm not having such great luck with it...
Here's what the pubspec.yaml looks like in case it helps:
environment:
sdk: '>=1.24.0 <2.0.0'
dependencies:
shelf: ^0.6.0
mojito: "^0.6.6"
convert: ^2.0.1
dev_dependencies:
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
- dart_to_js_script_rewriter
The last version of mojito was uploaded in October 2016 and it seems abandoned. Since then, Dart has added Strong mode and begun transitioning to Dart 2. This included significant changes to the type system and updates to SDK libraries.
Additionally, transformers have also been removed - any documentation you find referencing them is out of date. And in this case, the dart2js script rewriter is for client side JavaScript, not servers.
If you're looking for Server libraries, I would recommend just starting with the latest version of Shelf

Resources