Old angular/material has those two modules. but angular/material 9.1.1 version has not those two module. I got below error. Anyone has any idea how to import those two module
Uncaught (in promise): Error: MatDatepicker: No provider found for DateAdapter. You must import one of the following modules at your application root: MatNativeDateModule, MatMomentDateModule, or provide a custom implementation.
Error: MatDatepicker: No provider found for DateAdapter. You must import one of the following modules at your application root: MatNativeDateModule, MatMomentDateModule, or provide a custom implementation.
Angullar 8,9
import { MatDatepickerModule } from '#angular/material/datepicker';
import { MatNativeDateModule } from '#angular/material/core';
Angular 7 and below
import { MatDatepickerModule, MatNativeDateModule } from '#angular/material';
You need to import both MatDatepickerModule and MatNativeDateModule under imports and add MatDatepickerModule under providers
imports: [
MatDatepickerModule,
MatNativeDateModule
],
providers: [
MatDatepickerModule,
MatNativeDateModule
],
In case you're looking for the MatMomentDateModule, it does not come by default, you will need to install
#angular/material-moment-adapter separately
npm install --save #angular/material-moment-adapter
In case you face the issue that the peer dependency Moment.js is missing, install it with
npm install --save-dev moment
Then go ahead and import the MatMomentDateModule in the module file
import { MatDatepickerModule } from '#angular/material/datepicker';
import { MatMomentDateModule, MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '#angular/material-moment-adapter';
#NgModule({
declarations: [
...
],
imports: [
...
MatDatepickerModule,
MatMomentDateModule
],
providers: [
{provide: MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: {useUtc: true}}
]
})
export class MyModule {}
Read more at Angular Material Datepicker component
Related
I want to create a Swift Package with binary targets which has sub dependencies. As the binary targets not support sub dependencies out of the box, I have created a wrapper target that depends on both the binary framework and other dependencies as described here
Package has a target called Logger.
CocoaLumberjack is a dependency of Logger.
Logger I have generated as XCFramwork and hosted in a server as publicly accessible. Below I have added a screenshot of the Xcode project which I used to generate XCFramwork.
Please refer to the Package manifest file.
import PackageDescription
let package = Package(
name: "spmpoc",
products: [
.library(
name: "Logger",
targets: ["LoggerTarget"]),
],
dependencies: [
.package(
name: "CocoaLumberjack",
url: "https://github.com/CocoaLumberjack/CocoaLumberjack.git",
from: "3.6.1"),
],
targets: [
.target(
name: "LoggerTarget",
dependencies: [.target(name: "LoggerWrapper",
condition: .when(platforms: [.iOS]))]
),
.target(
name: "LoggerWrapper",
dependencies: [
.target(name: "Logger", condition: .when(platforms: [.iOS])),
.product(name: "CocoaLumberjack", package: "CocoaLumberjack")
]
),
.binaryTarget(name: "Logger", url: "https://mypath.com/Logger.xcframework.zip", checksum: "mychecksum")
]
)
I am able to add Swift package via Swift Package Manager, but When I try to import Logger module build error occured as ..../Logger.framework/Modules/Logger.swiftmodule/arm64-apple-ios.swiftinterface:4:8: No such module 'CocoaLumberjack'
Could someone please help me to figure out what could be the issue here?
Error
XCFramwork code snapshot for reference
Update:
I have change import to #_implementationOnly import in Logger.swift. Now in the generated .swiftinterface files does not contains the "import CocoaLumberjack" hence, compile error went away. However, app crashing because it is still looking for CocoaLumberjack.framework but its not available. '.../Library/Developer/Xcode/DerivedData/TestSPMApp-gfbagjtzjrrkjuathrrienvklwxs/Build/Products/Debug-iphonesimulator/CocoaLumberjack.framework/CocoaLumberjack' (no such file)
CocoaLumberJack added to Logger framework as a pod dependency. It seems, inside the Pods-Logger.xcconfig file it is referring to CocoaLumberjack.framework. I believe this causes the issue now.
I think the real issue here is that the dependencies don't need to be a part of your modules's public interface. You would need to replace all instances of import for the dependencies in your code to #_implementationOnly import
E.g.
#_implementationOnly import CocoaLumberjack
You can read more about #_implementationOnly here
I just made a SPM module for iOS, fixed error from xcodebuild output and runned some tests - it's just fine.
But when i added this SPM into a project - my classes, functions, and constants defined in modelue, weren't in module at all! By the way, entire module is empty, except few imports, that i wasn't placing there.
My Package.swift:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "BotComputer",
platforms: [.iOS(.v14),],
products: [
.library(
name: "BotComputer",
targets: ["BotComputer"]),
],
dependencies: [],
targets: [
.target(
name: "BotComputer",
dependencies: []
),
.testTarget(
name: "BotComputerTests",
dependencies: ["BotComputer"]),
]
)
... And the module after import contains just this (cmd+click on import MyModule -> jump to definition):
import class Foundation.Bundle
import MetalKit
import SwiftOnoneSupport
Well, i'm stuck.
Yea, like #francisco.garcia said - i've got no access modifiers at all, but public made all the stuff. Thanx a lot!
Not kinda obvious thing...
I am working on swift cocoa touch framework to create reusable framework from mobile application.
my framework need to use jwt project from https://github.com/vapor/jwt.git
i tried to create Package.swift and then add .package(url:"https://github.com/vapor/jwt.git", from: "3.0.0") and then run swift package resolve
in my code, i import jwt library like this
import JWT
import Foundation
but i got the error No such module 'JWT'
i am newbie on swift, can someone help please?
my Package.swift is here
// swift-tools-version:4.2
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "edoc-sdk-swift",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "edoc-sdk-swift",
targets: ["edoc-sdk-swift"]),
],
dependencies: [
.package(url:"https://github.com/vapor/jwt.git", from: "3.0.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "edoc-sdk-swift",
dependencies: ["JWT"]),
.testTarget(
name: "edoc-sdk-swiftTests",
dependencies: ["edoc-sdk-swift"]),
]
)
You should check two things:
Module name is JWT, not jwt.
Check that your .target in Package.swift contains "JWT" in dependencies
thanks all guys for the feedback.
now i can solve the problem, and i write the solution to this blog
https://piggyman007.blogspot.com/2018/12/create-swift-framework-and-include-some.html
I have these two ways to import version from my package.json file. And it prompts error says Error transforming bundle with 'rollup-plugin-license' plugin: version is not defined. Please see my following code.
import pkg from "./package.json";
import {version} from "./package.json";
import license from 'rollup-plugin-license';
export default {
input: './src/a.js',
output: {
file: 'a.js',
format: 'cjs',
},
plugins: [
license({
banner: `V<%= pkg.version %>`, //this works fine
banner: `V<%= version %>`, //prompts version is not defined
}),
]
};
banner: `V<%= pkg.version %>, //this works fine
This statement works because you're importing your package.json into pkg with: import pkg from "./package.json"; and your package.json is a JSON object so you can use dot notation to reference properties of a JSON object. In this case, the version property of the package.json. However, this fails: banner: <V%= version %>, //prompts version is not defined because you haven't defined a version export in your package.json so when you use: import {version} from "./package.json"; version is undefined. See: https://medium.com/#trekinbami/a-not-so-in-depth-explanation-of-es6-modules-import-and-export-13a80300f2f0 for a quick explanation on ES6 importing/exporting modules.
I'm trying to integrate highcharts to my jhipster Gateway using angular 4.
In the command line I used
>yarn add angular-highcharts#4
> yarn add --dev #types/highcharts#4
but i got this error :
./node_modules/angular-highcharts/angular-highcharts.es5.js
Module not found: Error: Can't resolve 'highcharts' in '/home/vagrant/IdeaProjects/chart/node_modules/angular-highcharts'
When I opened ./node_modules/angular-highchartsangular-highcharts.es5.js:
I got:
this import is not supported by current javascriptversion
import * as Highcharts from 'highcharts';
import { Directive, ElementRef, Inject, Injectable, InjectionToken, Input, NgModule } from '#angular/core';
Am I missing a setting somewhere?