How set release mode in Dart Editor - dart

With the SDK 1.3, when I use pub build in Dart Editor, it generate a lot of files isntead of a one minify file. If I use pub in console with --mode=release, it make only a file.
How I set default mode in Dart Editor?

Somehow, executing pub build through Dart editor will run on debug mode. So far, my work around is to run it though command line.
This is an open issue, although there seems to be no plan regarding this yet.

New
DartEditor now has two distinct menu items for debug and release mode.
Original
I'm not sure what you are asking for. As far as I know --mode=release is default for pub build.
I also don't get only one file with pub build --mode=release.
You can try to add this to your pubspec.yaml:
transformers:
- $dart2js:
minify: true

Related

How debug Kotlin on iOS with Xcode

Currently I am working on one KMM project. It would be really useful to be able to debug the shared code which is in kotlin in xcode project.
I am aware of this solution but I have problem to tell Xcode that *.kt files are source files
to be more specific in the above github link it is written :
You need to tell Xcode that *.kt files are source files, and run an lldb formatter script when debugging starts. Advanced users may want to do this manually, but if you have Xcode installed in the default place, you can run the setup script.
Unless you're using Xcode 11 (in which case look here for help), the following script will install both debugging and formatting support:
./setup.sh
I do not know where and how I should run the ./setup.sh or if there is another way to do it?
The setup script is included in the github repository: https://github.com/touchlab/xcode-kotlin/blob/main/setup.sh
The above plugin is great if you want to debug on Xcode and I highly recommend it.
Just an FYI, in case you didn't notice, there is also a plugin for debugging shared code on iOS for Android Studio: https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile

Setup of React Native using ndenv on OS X

I'm running into PATH difficulty setting up a new React Native iOS project in Xcode 7.1. I'm trying to use ndenv to manage node versions, which means ~/.ndenv/shims needs to be on PATH. To that end, I have PATH set as a user-defined project setting as $PATH:~/.ndenv/shims. The Xcode settings UI shows the correct expanded PATH value.
Yet the project, generated by react-native init, still fails to build. The custom build script fails to find react-native:
../node_modules/react-native/packager/react-native-xcode.sh: line 36: react-native: command not found
react-native is installed correctly, but the environment variables dump in the build output makes clear that ~/.ndenv/shims isn't on PATH. My PATH settings don't appear in the build environment. However, if I set a random user-defined setting (e.g. FOOBAR=baz), that does correctly show up in the build environment.
That result plus further inspection of PATH in the build environment makes clear that Xcode is overriding PATH somewhere along the line.
So in order of preference:
How do I correctly append to PATH for a custom build script in Xcode 7?
Alternatively, what's the best (least hacky?) way of getting ndenv-managed npm modules on PATH for the build script?
Modifying react-native-xcode.sh is out of the question, since that's a part of the external react-native npm module.
UPDATE 1
As a temporary workaround, I've bailed on ndenv and installed node via homebrew. This puts react-native on the (apparently-hardcoded) Xcode path at /usr/local/bin, and works to get the build running. I'm not going to submit or accept this as a solution, since it doesn't allow the repeatable control of node versions that ndenv does.
The problem seems to be that the react-native-xcode.sh script depends on the react-native-cli package to be in PATH. This issue was reported to the project in these two issues on Github:
https://github.com/facebook/react-native/issues/3974
https://github.com/facebook/react-native/issues/3948
I expect a fix to be implemented quite soon, because this is a major problem for anyone using the react-native cli to create new projects.
There are a few work arounds for this problem, but none of them are perfect. Which one would work for you depends on your node / npm setup:
I myself installed node via nvm and just needed to add export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.shbefore running the react-native-xcode.sh.
For this to work you need to have react-native-cli installed globally.
If you need help finding a solution for your specific setup, please give me some more information about your node setup. ( or you can try one of the other solutions pointed out in the issues I linked above. )
Had the same issue. The work around called out in the link below is working for me. Haven't found a permanent solution.
The XCode $PATH differs from terminal $PATH and it doesn't include path of nvm nodes (~/.nvm/versions/...). This can be temporarily fixed by adding source ~/.bash_profile to the beginig of react-native-xcode.sh
https://github.com/facebook/react-native/issues/3948
This issue was effectively fixed when facebook/react-native#5518 landed. react-native-xcode.sh now respects a NODE_BINARY environment variable that tells it where to find node on the build system. Under your app's target, see Build Phases > Bundle React Native code and images and set the shell script code to:
export NODE_BINARY=$HOME/.ndenv/shims/node
../node_modules/react-native/packager/react-native-xcode.sh
If your node is in a different location, change the value of NODE_BINARY to suit your installation. Here's a screencap from Xcode 7.1 to aid navigation:
It looks like a fix for this was just published as release 0.14.2
https://github.com/facebook/react-native/releases/tag/v0.14.2

Dart: pub build minified dart.js missing

I am very new to Dart so bear with me. I completed the sample pirate badge project and did Pub Build - Minified as instructed. The generated build folder does not contain the packages/browser/dart.js and priatebadge.dart files that are referenced by piratebadge.html.
When I view in the browser there are errors related to those missing files. If I change the html page to reference the generated piratebadge.dart.js file it works.
Is this manual change something that has to be done with dart projects? or am I missing something in the build process?
At first, ensure you build in release mode. (default if you run pub build from command line.
I haven't checked for a while but I assume there is still this Dart script tag which was introduced when it was still planned to integrate Dart into Chrome. This will hopefully fixed soon. In the meantime you can fix this manually or use https://pub.dartlang.org/packages/dart_to_js_script_rewriter to automate this step.

Deploying Angular Dart component with canvas via shadowRoot: what is missing?

I have an angular dart application with a component using canvas via a shadowroot. This runs fine with Dartium, "run as javascript" and pub serve. However when I run pub build and launch the html file in build/web, the component does not appear. The code is at
https://github.com/siddhartha-gadgil/mathlets
Should I be using some special transformers, or do something different to build as against serve?
I tried your project and it appears to be working fine.
What I have done in the past is run pub build and hit the built file in dartium and that will not work. So you have to hit the build file from chrome proper. So if I load .../mathlets/build/web/mathlets.html in chrome it works fine.
The reason for this is because pub build is the release build, which does not copy any of the dart files. However the index file still has the check if dart is enabled than try to use dart files. Well in dartium dart is enabled but the build doesn't have the dart files. In chrome dart is not enabled so then that 'packages/browser/dart.js' file dynamically writes the mathletes.dart.js to index and launches the app that way.
If you want to work around this and improve performance of the release build at the same time you can use this transformer: http://pub.dartlang.org/packages/dart_to_js_script_rewriter
We are using this also. Ensure it's the last transformer run though, if it's before the angular transformer there are problems.

Dart Package Management via dart2js

I'm learning Dart and its dependency manager pub and am having a tough time seeing the "forest through the trees" here.
Say I want to use Polymer.dart in my project. So, in my project root, I create the following pubspec.yaml:
name: test_dart
description: A sample web application
dependencies:
browser: any
polymer: ">=0.9.0 <0.10.0"
I then run pub get, which goes to the pub repo and fetches the browser and polymer dependencies that I've specified. It then creates a packages directory in my project root, which now means I have a project that looks like:
MyDartProject/
pubspec.yaml
myapp.dart
packages/
browser/
...
...all the packages that ship with Polymer
Now I start coding my Dart web app (myapp.dart), which will references various Polymer and browser types/functions/etc. in its source code.
When I'm all done, I want to create a JavaScript file called myapp.js.
According to the dart2js docs, I need to run something like:
dart2js --out=myapp.js --package-root=??? myapp.dart
How do I include all the browser & polymer packages on the buildpath?
There is a "pub build" option now.
http://pub.dartlang.org/doc/pub-build.html
Use pub build when you’re ready to deploy your web app. When you run
pub build, it generates the assets for the current package and all of
its dependencies, putting them into a new directory named build.
$ cd ~/dart/helloworld
$ pub build
Building helloworld......
Built 5 files!
If the build directory already exists, pub build deletes it and then creates it again.
That should do everything you are after here. You can also launch it from the IDE by right clicking on the pubspec.yaml file and choose "pub build"
EDIT: You should also see the links in zoechi's answer.
If you run dart2js from your MyDartProject directory you don't have to provide --package-root parameter.
An alternative way is running pub build. If you use Polymer you need to add a transformers section.
see also
How to deploy a Dart Polymer app to Javascript using dart2js
How do I pass multiple entry_points to polymer transformer in pubspec.yaml?

Resources