I am a newbie learning how to code in Swift on Linux.
Right now I am trying to use Perfect framework so I can create th REST service (or something like that) I am following instructions in this
https://videos.raywenderlich.com/courses/77-server-side-swift-with-perfect/lessons/1
video (I have found a link on perfect.org site) and I did everything just like in the video, but the problem occurs when I have to edit the main.swift file and use include to use the PerfectLib, PerfectHTTP and PerfectHTTPServer libraries/modules(?). When I run it the error shows on the terminal saying:
main.swift:1:8: error: no such module 'PerfectHTTP'
import PerfectHTTP
Same with other modules. Do I have to place downloaded files from Perfect to some special directory within swift directory? Or maybe the files in download link are not complete?
before doing any Server Side Swift, please temporarily forget Xcode and try a new tool chain called Swift Package Manager. Open a terminal in a blank folder and type swift package init then it will setup a blank project which contains a Package.swift, a folder named Sources and a Tests directory as well.
Now you have to edit the Package.swift before import anything into your source code. For example, the starter template Perfect server has such a Package.swift:
import PackageDescription
let package = Package(
name: "PerfectTemplate",
targets: [],
dependencies: [
.Package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", majorVersion: 2)
]
)
Then you can import any Perfect libraries included in the Perfect-HTTPServer.git
Here is the importing part as defined in the main.swift of PerfectTemplate:
import PerfectLib
import PerfectHTTP
import PerfectHTTPServer
So I will suggest that the best practice is to try Perfect Assistant: https://assistant.perfect.org/perfectassistant/Perfect%20Assistant.dmg which can save most tricky operations such as dependency management, building on linux and production server deployment.
For more information about Perfect other than tutorial video, see this link: http://www.perfect.org/docs/
Related
I'm attempting to use a shared library for reusable components and using just 2 out of the box Create react apps. One is called 'shared-lib' the other 'project-example'. I made a super simple component in shared-lib, exported (working when I test). I NPM linked both seemingly correctly (shared-lib is in my project-example node_modules with a special icon).
I built the shared-lib, I also imported the shared component (SharedComponent)
import SharedComponent from 'shared-lib'; <- lib is in my node_modules
../shared-lib/src/index.js
SyntaxError: /Users/bemker/dev/portals-modern/shared-lib/src/index.js: Support for the experimental syntax 'jsx' isn't currently enabled (8:3):
Add #babel/plugin-transform-react-jsx (https://git.io/vb4yd) to the 'plugins' section of your Babel config to enable transformation.
I'm following a vid tutorial and he didn't have to eject his create react app, but I'm guessing this is where the error is coming from.
Here is the vid I'm following if anyone wants to take a look. https://www.youtube.com/watch?v=B7iYJT_ll-U
Anyone know why this is occurring, or how to get past it (preferably without ejecting)?
I couldn't find a solution using the above, but there is a package similar to Create React App for building libraries that made it pretty easy. Its not maintained by FB, but it worked for me.
https://github.com/transitive-bullshit/create-react-library
https://github.com/transitive-bullshit/react-modern-library-boilerplate (multiple exports)
vid tutorial using it: https://www.youtube.com/watch?v=N8d-CLmg3hw
second w/ 'real' usage: https://www.youtube.com/watch?v=6R699AQYH74
Hope this helps someone.
I'm trying to import a file in server.js of a meteor project on Linux. For example:
var temp = require('/home/HaveAGitGat/Documents/test.js');
I get the following error:
Error: Cannot find module '/home/HaveAGitGat/Documents/test.js'
The confusing thing is this works fine on Windows using meteor. It also works fine on Linux when running pure nodejs files without meteor.
Any ideas on a resolution?
You can put your test files inside your meteor project, and it's recommended that you do so. Putting absolute paths in your code means that you are locked to that folder structure, which isn't great for portability.
For example, if you wanted me to collaborate on your project, I would have to modify all the require statements to make it work, and when I commit those changes it would break it for you.
Here's an alternative: Create a folder in imports/test to hold all your test files, so that you can import them with statements like this:
import testCase1 from '/imports/test/test1
Then your code is clean, portable, and your project is self-contained.
See https://guide.meteor.com/testing.html for more info
I am developing a flutter app. I want to let the user select some sounds.
When selected, I want the app to play its mp3 file in the assets folder. I tried with AudioPlayer plugin but I haven't achieved to play local files...
I have been searching for awhile and I haven't found any good answer to my questions, furthermore, the posts were created 2 or 1 year ago, so maybe we need an updated answer.
I have found this post: How to play local mp3 file with audioplayer plugin in Flutter
but my project doesn't find this package import 'package:path_provider/path_provider.dart'; [THIS PART IS SOLVED]
And when flutter will have a built-in audio manager? Are they/you working on it?
Thanks in advance!
EDIT: Also, I would like to play different mp3 at the same time, with different volume. Is it possible?
That import directive you see tells Dart that a particular source file uses classes from a different source file. The package: prefix tells Dart that the imported file is part of an external dependency. So you need to tell your project that you have a dependency. This is done in the pubspec.yaml file.
Dart's pub dependency manager takes care of finding the right version of the dependency for you, and downloading it. Add the path_provider package to your pubspec.yaml file. Each package's installing tab shows how to do this.
You can find a whole library of useful flutter (and Dart) packages here.
path_provider is a special type of package called a plugin which contains some Dart code together with iOS and Android specific code. This is necessary because playing audio or creating local files is platform specific.
I have a Node.js Angular app which I am trying to import babylon.js into.
Current Setup
1) npm install --save babylonjs to get the npm repo installed in my project's node modules.
The following image depicts the folder structure of the npm repo.
2)In my angular component I import the BABYLON declaration from the babylon.module.d.ts and babylon.max.js files in the above picture like so.
import * as BABYLON from 'babylon.js'
Babylonjs now works great, has typings enabled and everything, so I
can use BABYLON as pictured below
Problem
None of the included extensions are hooked up. These extensions are located in the following folders
(Full folder structure is in the first image. I left the gui folder open since that is the specific extension I am >trying to activate at this time)
The main babylon.module.d.ts file defines BABYLON as follows:
declare module BABYLON { //class types are defined in here }
The gui extension (all others follow the same logic) declares itself as a part of BABYLON as follows:
declare module BABYLON.GUI { //extend classes & create new classes in here in here }
Attempted solutions
1) babylon.gui.d.ts declares BABYLON.GUI so I simply tried the following
import * as BABYLON from 'babylonjs';
import * as BABYLON.GUI from 'babylonjs/dist/preview release/gui/babylon.gui';
This generates the following Typescript error: Duplicate identifier 'BABYLON', which is not surprising, however, BABYLON.GUI is how thebabylon.gui.d.ts` file declares its parts.
2) Using the CDN in the index.html file. This works, however, types will not work. Even if I got typings to work,using the CDN is less performant. The resources will be loaded in the document <head> every page. with imports the resources will only be queried when the component is active.
3) Appending the babylon.gui.d.ts file to the babylon.module.d.ts file. BABYLON.GUI` is still undefined.
Modifications to the npm repo are undesireable anyways, since any npm updates, or installs will overwrite the changes.
4) I spoke with a BABYLON developer here, and we kind of hit a dead end.
Does anyone have any input on how to import this extension properly?
PS. once we get this answered I'm going to work with the dev to implement a seamless experience for all node users who wish to incorporate babylon.js into their projects!
I spoke with the lead developer deltakosh about this.
To clear a few things up:
This issue is not with npm
This issue is not with node
This issue is with how Babylon is structured
The developers are actively refactoring to support the import behavior desired in the above question.
If anyone is curious here is the link to the open issue on github pertaining to this question.
In the interim to use Babylon while import support for importing packages is being worked on I have done the following:
Use the CDN for all babylon libraries
To get rid of typescript compilation issues declare the following at the top of your .ts file declare let BABYLON: any; This will make babylon with packages useable, however, we will not have any typings benefits in the interim.
Feel free to chime in if you have found a more elegant interim solution!
i found one example App for creating Rss Reader using lwuit,the example app url is
"https://projects.developer.nokia.com/LWUIT_for_Series_40/browser/IO/src/com/sun/lwuit/io/ui/RSSReader.java"
i have gone through the code ,but in this Example there is no Midlet creation and somme of the classess below classes are not found in lwuit jar file
import com.sun.lwuit.io.NetworkEvent;
import com.sun.lwuit.io.NetworkManager;
importcom.sun.lwuit.io.services.RSSService;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.list.DefaultListModel;
Can any one guide me to execute this example app successfully on my device?
You can obtain all com.sun.lwuit source code from an svn checkout. Url https://svn.java.net/svn/lwuit~svn Take a look at LWUIT_1_5 root folder.
I also went through this problem. For the lwuit.jar you can go two ways: (1) download the source code of the subversion repository (response by Telmo) and compile the files in NetBeans IDE; or (2) get a version of LWUIT already compiled by someone.
To open source code with NetBeans go:
NetBeans IDE menu / Team / Subversion / Checkout /
Access the source code using the following URL:
https://svn.java.net/svn/lwuit~svn (anonymous)
or SSH URL (requires SSH key): svn+ssh://#svn.java.net/lwuit~svn
After import all projects (like UI, IO... and build it). (required WTK 2.5.2 reference - in project property), can use the new libs in their examples.