Build flutter app for desktops - dart

I saw a few peoples managed to build flutter apps for other OS than the usual Android/IOS
My question here is simple : How ? What is the current process to build a flutter app for mac/windows ? There's no need for it to be production ready. Something experimental is enough

For those wondering how to :
https://github.com/google/flutter-desktop-embedding
There's an example using openGL to render a flutter app

Run a Flutter project in Desktop
Step 1:
For Flutter to run on Desktop, we must be on the master channel, with the latest release. So run from cmd,
flutter channel master
and
flutter upgrade
Step 2:
Then we have to enable flutter desktop support.
set ENABLE_FLUTTER_DESKTOP=true
Step 3:
Then clone this repo and cd example directory.
Step 4:
Then replace the lib folder inside the example directory with our existing code, and replace the pubspec.yaml file, with our existing one.
Step 5:
Then run from terminal
flutter packages get
and
flutter run
You can find more info here.

You can check this link out
https://github.com/google/flutter-desktop-embedding
Still not stable but does a good job of rendering flutter apps on desktop

Here's something I found useful, it is currently in alpha version but does the job by enabling us to develop Mac and Windows apps in Flutter :
https://feather-apps.com/

For those who want to know the current state(2021), here is the startup project to help you test It for MacOS, Linux, Windows. The project heavily modified from official ci to build cross-platform easily. You might want to check the ci.yml If you want to build on certain platform without github-action.
In additional, go-flutter is also a valid option, that used go-lang and openGL to achieve cross-platform features.
If you want to know the difference between official and go-flutter, here is the issue about the details.

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

Alternative for hybrid web app without knowledge in app/server

i used to upload my ZIP (with HTML5/CSS web app) in phonegap since 4, 5 years and create cool mobile apps. But since some months it's look like Adobe dismiss the project, no more answer on forum etc.
Is there a good solution, when you don't know everything about shift/cocoa/java and server things, to simply upload your webapp (basically a website in a zip) and get IPA/APK ?
I heard about monaco or voltbuilder. Thanks
Not really. Although I can confirm https://build.phonegap.com works for me. If you have an error related to a malformed xml, you can try to delete the project on the website and re-uplading the zip file onto a new project. That's a bug I have experienced in the past.
Otherwise, you can install Cordova and Phonegap on your pc to build it using npm on the terminal (Linux/MacOs).
$ sudo npm install -g cordova
or for windows (CMD):
C:\> npm install -g cordova
then navigate with the command line using cd to go to a folder
eg. cd myfolder.
You can see the files in your current directory with ls (Linux/MacOs) or lsdir (windows)
Once you are in your project's folder and that you can see with lsdir or ls your config.xml file of your project, then you can run those commands to add the platform you want to build:
cordova platform add ios
cordova platform add android
Finally to build the app, you need to:
cordova build
Note: To build an Ipa, you will need to use a device running MacOs since it requires XCode. I highly recommand you to get familiar with Cmd or the terminal if you are building an app.
I hope I have answered your question well

How can i change my dart-sdk on VSCode

i have been using flutter recently and i really wanted to use Jaguar for my project. But here is the catch, the flutter sdk brought dart with version 2.0.0-dev-58.0 but jaguar said they need dart sdk with version 2.0.0-dev-65.0
Okay, so i get myself dart with sdk version of 2.1.0-dev.1.0, but my vscode can't seem to recognize that i have installed the sdk.
Any ideas on how to change that?
The Dart Code plugin has a setting dart.sdkPath
The location of the Dart SDK to use for analyzing and executing code.
If blank, Dart Code will attempt to find it from the PATH environment
variable. When editing a Flutter project, the version of Dart included
in the Flutter SDK is used in preference.
There's also dart.sdkPaths which allows quick switching between alternatives.
For Flutter projects, use dart.flutterSdkPath(s)
It's quite easy if you use VSCode:
Clone flutter repo to a new folder:
mkdir ~/flutter_dev
cd ~/flutter_dev
git clone https://github.com/flutter/flutter.git .
Open your workspace preferences and update dart.flutterSdkPath setting:
"settings": {
"dart.flutterSdkPath": "/Users/youruser/flutter_dev"
}
Restart VSCode and you're good to go.
See more info in Dart Code - Quickly Switching Between SDK Versions
I want to add one more things to #Andrey, you can use FVM to install as much as you want versions and channels, it's easy to install and manage versions. It hold all versions on your home directory, I think it's easier than managing with Git.

Automated Unity iOS build on Mac

I am doing the iOS builds for a group of Unity (Unity3d) game developers.
After pulling the latest git updates, I start up the Unity editor on my Mac and choose "Build Settings", select the iOS target platform, press Build, specify a destination folder and that is it.
Can this exact process be done automatically via the terminal prompt?
What you would need to do is create an editor method in Unity that does the iOS building:
http://docs.unity3d.com/Documentation/ScriptReference/BuildPipeline.BuildPlayer.html
And then call that method via the Unity command line arguments.
http://docs.unity3d.com/Documentation/Manual/CommandLineArguments.html
/Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -executeMethod MyEditorScript.MyMethod
As Calvin said, you can use the executeMethod switch of Unity's command line to call your own C# command and have some build logic executed. I have written a small article about how to do this. There is also a cheat sheet showing the Unity API to use for specific tasks.

Building WebRtc on iOS

I was successfully able to build WebRTC on MAC following these instructions: http://www.webrtc.org/reference/getting-started
Has anyone successfully built it on iOS? I understand that someone (arik) has successfully built it on iOS: https://groups.google.com/forum/#!msg/discuss-webrtc/VJg-fk2-i_0/dtG200DOzsgJ But the steps are not clear.
Can someone (who built on ios) summarize the steps so that it will be useful for everyone trying it in the future?
I wrote a detailed blog post with all of the instructions on how to build the WebRTC example iOS application, as well as how to run it on the iOS simulator or an actual iOS device. You can take a look here to read the details, it's a pretty lengthy process.
Yes, compiling for iOS was a very painful task... especially getting it work in Xcode.
Here's my attempt to get AppRTC Demo for ios
Clone/Pull: https://github.com/pristineio/webrtc-build-scripts
After getting the repo, then open the xcode project within the ios directory. Set the target to WebRTC Dance, then execute. At this point the scripts will update depot_tools and do all the dirty work (pull, modify, build) so that your target for AppRTCDemo will able to resolve the missing files and execute.
Once that completes, you can change the target to AppRTC Demo with a simulator or a real device, click run and it should execute. There's more detailed information in the guide linked in there and updates in the readme.
If you are wondering what gets ran under the hood, check out the build.sh file in the ios directory of the git repo. The dance function is what's actually getting executed for you when you select WebRTC Dance.
Its not really easy to describe the build process (way too much going on) but the build scripts repo should definitely point you in the right direction and help you get AppRTCDemo on ios 'just work'
There's also a google developers video posted here, where they try and break down the build process so you can build for ios (the youtube title is misleading).
Also, I just added cocoapods support for ios webrtc, add this to your Podfile,
pod "libjingle_peerconnection"
# Add this to the bottom so it won't have issues with active architecture
post_install do |installer_representation|
installer_representation.project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
config.build_settings['VALID_ARCHS'] = ['armv7', 'i386']
end
end
end
Not all the revisions are built, so check out the the cocoadocs for which revisions are available
I have been working in this space for the past few months now - webrtc on iOS is not easy. To help this problem I have added a github repo with a working example of and iOS app using webrtc.
https://github.com/gandg/webrtc-ios
The site references the google code site as well, so it should be a helpful starting point.
Well, it's been a long time to answer this post. But, I hope someone might
get better intuition from it.
I have been dealing with webrtc compilation processes for iOS and Android platforms. This process is really simple if you follow each step efficiently. To compile the library for iOS, follow the below-given commands and make sure you're using the same(only-1) tab of Mac terminal for WebRTC Native Compilation Setup as follows:
Prerequisites
Link Xcode with Command line
Setup depot_tools
Fetch Code for Development
Selection of Branch
Compile Library (iOS Framework)
1. Prerequisites:
First of all, make sure of the following things that you have already installed, if not then use these commands to do that:
- sudo add-apt-repository ppa:openjdk-r/ppa
- sudo apt-get install openjdk-8-jdk
- sudo apt-get install pkg-config
- sudo apt-get update
Please also install python==2.7, if it's not already installed.
2. Link Xcode with Command line:
- sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
- sudo xcode-select --switch /Library/Developer/CommandLineTools
3. Setup the Depot_tools:
- git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
- export PATH="$PATH:${HOME}/depot_tools"
After that, start the following steps one by one. Every step takes its own time based on the machine specs and internet speed, so make sure every step is completed without interruption.
4. Fetch Code:
- mkdir webrtc_ios
- cd webrtc_ios
- fetch --nohooks webrtc_ios
- gclient sync
5. Select Branch-head:
- cd src
- ./build/install-build-deps.sh
- git checkout origin/master
- git branch
6. To compile every time:
Make sure you are in the webrtc_ios/src/ directory, then simply run this command:
- ./tools_webrtc/ios/build_ios_libs.sh
It turns out that you will end up with the compilation and building of WebRtc Framework holding Webrtc Header Files. You can simply drag and drop this framework into your Xcode production environment or simply import it.
As you have set up your compilation environment, now every time you make changes into your native stack, you can simply run this command ./tools_webrtc/ios/build_ios_libs.sh to generate an updated framework.
If you end up with an issue regarding the compilation of webrtc framework. Please follow these steps. Make sure you're in this directory webrtc_ios/src/:
- git checkout origin/master
# To make sure you're using origin/master
- git branch
- gclient revert
- gclient sync
- ./tools_webrtc/ios/build_ios_libs.sh
And hopefully, you will have your issues sorted. I always recommend you guys that You can check out a branch that would be behind the origin/master and doesn't have all dependencies and modules over there which are necessary to build webrtc framework for iOS. So, Please always checkout to branch/head of webrtc native stack
Now, if you tried with these both procedures to build the WebRTC such as:
1- Using Bash Build Tools (./tools_webrtc/ios/build_ios_libs.sh)
2- Using Manual Compilation
Examples
$ # debug build for 64-bit iOS
$ gn gen out/ios_64 --args='target_os="ios" target_cpu="arm64"'
$ # debug build for simulator
$ gn gen out/ios_sim --args='target_os="ios" target_cpu="x64"'
2.1- Compiling (ninja -C out/Debug)
Both procedures will work.
This seems to build some of the modules: https://code.google.com/p/webrtc/issues/detail?id=1421#makechanges

Resources