when I try to run Dart commands (even simple dart --version) in Codemagic it fails with an error saying dart: command not found.
to overcome the issue you need to update your scripts to run $FLUTTER_ROOT/bin/dart instead.
There is no separate Dart SDK on Codemagic build machines, only Flutter SDK and you can use the Dart version shipped with Flutter.
For instance
#!/bin/sh
$FLUTTER_ROOT/bin/dart --version
Related
The process function show error
I install updated shell out updated package , but i faced the Cannot find type 'Process' in scope. error
Process and shell are not supported in iOS, those are macOS APIs.
I was trying to run flutter and dart using tutorials but I'm stuck with this error:
/bin/sh: dart: command not found
This is my user settings in VS Code:
"dart.flutterSdkPath": "/Users/sam/Desktop/Codeground/App_development/flutter/bin"
And in .bash_profile this is what is written:
export PATH="$PATH:/Users/sam/Desktop/Codeground/App_development/flutter/bin"
I already tried adding another path to the dart-sdk/bin sub-folder as well but to no avail. I'm running MacOS Ventura 13.0.1
I'm trying to run:
dart "/Users/sam/Desktop/Codeground/App_development/Projects/sample_application/lib/main.dart"
You can try with $HOME, make sure rest of the path.
export PATH="$PATH:$HOME/Desktop/Codeground/App_development/flutter/bin"
I can't find answer for this.
My app needs parameters defined --dart-define=ENVIRONMENT="$APP_ENV"
There is no problem building Android, but how to pass those while build ad-hoc in fastlane?
I've prepared build scripts that run:
flutter pub get
flutter build ios --config-only \
--flavor prod \
--dart-define=ENVIRONMENT="$APP_ENV"
cd ios
bundle exec fastlane build_app_prod_ad_hoc
And my lane for fastlane is:
lane :build_app_prod_ad_hoc do
cocoapods
gym(
configuration: "AdHoc-prod",
export_method: "ad-hoc",
scheme: "prod",
export_options: {
provisioningProfiles: {
...
},
},
)
end
But I can see that my result doesn't have ENVIRONMENT set correctly.
Any ideas?
Solution:
Encoding and replacing your dart variable in flutter_export_environment.sh and Generated.xcconfig then running the app from Xcode/Fastlane directly will work fine.
------ Details -------
The issue: The variables passing via --dart-define won't reflect if you run the app from Xcode/ Fastlane directly without first running the flutter run/build command.
Reason: The following generated files are involved but not intended to update manually, but in our case running from Xcode or Fastlane to build the app, the dart variables used won't get updated. When you run the flutter run or build command, these files get updated with the values from --dart-define as Base64.
/ios/Flutter/flutter_export_environment.sh
ios/Flutter/Generated.xcconfig
When you directly build the app from Xcode or use Fastlane, the Generated.xcconfig from the ios folder inside the Flutter project code is being used to run/build the app.
Example:
In my case, we pass the ENV variable using --dart-define, but if you run directly from XCode without running the flutter build or run command first, these arguments won't update.
flutter run/build --flavor dev --dart-define ENV=dev
Dart define variable will store in the flutter_export_environment.sh and Generated.xcconfig in Base64 encoding.
DART_DEFINES=RU5WX1UEU9chZ2luZw==
Note: This is a workaround to avoid running the flutter run/build command followed by a Xcode/Fastlane run to solve the issue. Not the best solution, but I hope it may help someone.
In Dart 1.x, there was a command, that you could trigger e.g. from grinder.dart. But this line works no longer:
Pub.build();
How can I replace it and run build command of my web app from Dart code?
pub build is no longer supported in Dart 2.
You need to run pub run build_runner build.
See https://webdev.dartlang.org/dart-2
I'm not sure if there are new APIs for Grinder, though.
I fixed it by calling webdev build directly
I'm trying to get started and setup to develop Dart.
I'm following the instructions on https://webdev.dartlang.org/guides/get-started to install on Linux. However there seems to be an essential step missing.
On the above link, step 2 is about installing the SDK.
Step 3 is titled:
Get CLI tools or WebStorm (or both)
However step gives examples of using the pub command, and the links it references also use this command, however there are no instructions on where to find the pub utility or how to install it.
I would have assumed that pub was provided as part of the Dart SDK. I can run dart in my terminal, and see that it is installed. For example dart --version returns Dart VM version: 2.0.0 (Unknown timestamp) on "linux_x64". But pub returns zsh: command not found: pub
My question, therefore, is where do I find, and how do I install pub?
You need to add thedart-sdk/bin directory to the system PATH variable.