Deployed web app still prints all commented out prints statements in Chrome javascript console Flutter - firebase-hosting

Today I started diving into deploying my web app to Firebase Hosting.
I so commented out all the print statements in my code, run flutter clean, then flutter build web and then deployed it to firebase.
Now, it all goes smooth except that in Chrome's Javascript console I still get all the prints.
I tried to deploy with no files in the build folder and effectively I got the 404 screen when refreshed the browser, so I'm guessing it has not to do with firebase cache.
What else should I try?
Thank you very much.
my firebase.json is:
{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"site": "fixit-demo-web",
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
},
"storage": {
"rules": "storage.rules"
}
}

Found the solution here Firebase Hosting Flutter Web App not clearing Cache of first deploy
I was missing to give one and update the version in my index.html file.

Related

Issues embedding Finder Sync extension via electron-builder

I have an Electron application that integrates with OS X Finder via a Finder Sync extension. Overall, the application has three parts:
Electron application
Swift Application
FinderSync extension
The Electron application is the main entry point. On start up, it creates a child process that runs the Swift application. The Swift application has embedded in it, the FinderSync extension. The Swift app and FinderSync extension communicate over ICP so that the FinderSync extension can get the correct information for badges and context menus.
I build everything with electron-builder. It ends up with a structure like:
- MyElectronApp.app
- Contents
- PlugIn
- MyExtension.appex
- MacOS
- MySwiftApp.app
- Contents
- PlugIn
- MyExtension.appdex
- (All the other app contents)
When I install the application and when I run it, I see this in Console.app
rejecting; Ignoring mis-configured plugin at [/Applications/MyElectronApp.app/Contents/MacOS/mySwiftApp.app/Contents/PlugIns/myFinderExtension.appex]: plug-ins must be sandboxed
The plugin is marked as sandboxed, This is for the inner instance of the plugin. I do not get this for upper one.
When I launch the application, I can see that my plugin is running in the Finder Extensions Preference Pane. If I toggle the extension in the Preference Pane, I can see in Console.app that the extension and Swift app are communicating with each other. But I do not see my context menu or badges in Finder.
I do see this in the logs for my Swift application and Finder Extension:
LSExceptions shared instance invalidated for timeout.
The extension is Sandboxed and the Swift app is not. It took me awhile to get those entitlements "correct". I have the plugin listed twice in the Electron app. I found that if I didn't put it in the top level PlugIn directory, then it would not be registered with the OS. When I query pluginkit, I see that the first instance of the extension is running. The extension and the Swift app have the same application group so they can do IPC.
At this point, I'm not really sure what I can do. It seems that the plugin launches with the Electron app and not when I launch Swift app from within Electron.
To get to this point, I worked through code signing issues and sandbox issues. I am not using a provisioning profile. I do have a developer certificate from Apple that I use for signing.
Any help would be greatly appreciated. If there was an article where they published a Finder extension with electron-builder, that would be great as well.
Below are some other files:
electron-builder entitlements file:
...
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.automation.apple-events</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<false/>
</dict>
...
electron-build settings in package.json
"build": {
"appId": "com.myapp",
"productName": "My App",
"copyright": "Copyright © 2020 ${author}",
"files": [
"./index.js",
"./modules/**/*",
"./iconSmallTemplate.ico"
],
"extraResources": [
{
"from": "./resources/",
"to": "./",
"filter": [
"**/*"
]
}
],
"mac": {
"appId": "com.myapp.mac",
"category": "public.app-category.productivity",
"type": "development",
"identity": "Apple Development: ME (#####)",
"extraFiles": [
{
"from": "mySwiftApp.app",
"to": "MacOS/mySwiftApp.app"
},
{
"from": "myFinderExtension.appex",
"to": "PlugIns/myFinderExtension.appex"
}
]
}
}

Running Debug using Flutter Flavor?

I'm trying to run the debug mode on visual studio code (click "run and debug") for my flutter app, but when I do I'm facing the following issue:
The Xcode project defines schemes: release, private.
Exception: You must specify a --flavor option to select one of the available schemes.
So I have these two "flavours" but I'm not sure how to specify which to use. Normally, running the app through the terminal would require me to specify it as such: flutter run --flavor private but I'm not sure how to do the same for debug. Is there an equivalent command for debug mode?
Would appreciate some help, thanks in advance!
This answer will only be what you're looking for if you created your flavors (and schemas) correctly (check this for reference: Flavors in Flutter by Flutter Explained channel) and if you are using android studio, since it is there were I solved it.
After having followed the video or any other correct explanation or set of steps, it is true that you cannot run the debugger nor have any of the DevTools attached if you run your app through a command. For example in my case, one of my flavors is named 'staging' so the command I ran would be:
flutter run --flavor staging -t lib/main_staging.dart
But by doing so, yes, you can run your app, but you won't see any of the previously mentioned tools attached. What I did (and this is the answer) is this:
and then added the additional args (in my case I wanted to run the 'staging' flavor or schema, as you already may have noticed) so:
After that, I got rid of this exception
Exception: You must specify a --flavor option to select one of the available schemes.
That is: the exception did not show again when hitting either one of these two buttons ('Run' or 'Debug'):
And that would be it. After that, I was able to see the debugger working as well as the DevTools.
In your launch.json file configurations, you can use this format for your iOS app to run:
{
"name": "production",
"request": "launch",
"type": "dart",
"args": [
"-t",
"lib/main_prod.dart",
"--flavor",
"prod"
]
}
you have to add
"args":[ "-- flavor", "flavor_name" ]
in your .vscode > launch.json to obtain something like this:
"configurations": [
{
"name": "flutterApp",
"request": "launch",
"type": "dart",
"args": [
"--flavor",
"dev",
]
},
then you need to launch the debugger from here selecting the correct configuration:
otherwise it will not work
I encountered this, and had multiple schemes. In order to resolve it in addition to adding:
--flavor {scheme name}
to my run command, I also had to create a duplicate build configuration named
Debug-{scheme name}
You can do this by navigating to your project Runner in xCode, then
Editor->Add Configuration-> Duplicate Debug (or your desired build),
then name in the format {Configuration}-{scheme name}
Build Config Image
yes , you have to add arguments in launch.json file configurations
"args":[
"-- flavor",
"flavor_name"
]
N.B: you will get this json file in .vscode folder of your project
In Xcode I had to create the missing scheme and go to Manage Schemes and mark as shared.

running same UI5 app locally and in WebIDE, with real and mockdata

What I am trying to achieve: common codebase that can run unmodified on both local installation and in the WebIDE, both with real backend and mockdata. Mostly because I really prefer VSC as editor. The app itself is a plain list of materials and descriptions, single view, nothing fancy.
Where I am at:
local: setup works fine, both mockdata and real backend, using cors-anywhere as proxy.
WebIDE: works only when started as "SAP Fiori Launchpad" pointing directly to Component.js to access the real backend; no luck running it with "Web Application" using index.html or test/mockServer.html (they don't boot, sap-ui-core is not found) and no mockdata (see below).
Digging around, I found that:
as far as WebIDE is concerned, I didn't have to explicitly clone index.html to test/mockServer.html and I could just configure it to provide mockdata with a config option although this doesn't work in my case:
my mockserver rootUri is not relative, because I had to match the proxy url in manifest.json
"dataSources": {
"ProductRemote": {
"uri": "http://localhost:8081/http://10.0.98.194:8017/sap/opu/odata/sap/ZDEMO_FIORI_ABO_SRV/",
"type": "OData",
"settings": {
"odataVersion": "2.0"
}
}
}
to that in uimodule/webapp/localService/mockserver.js:
rootUri: "http://localhost:8081/http://10.0.98.194:8017/sap/opu/odata/sap/ZDEMO_FIORI_ABO_SRV/"
Here are the other relevant snippets:
index.html
test/mockServer.html
neo-app.json
Where I need help: leaving aside why the "web application" start option does not work, I'd like to understand how I could tweak the code in such a way that the cors proxy is correctly invoked on a local installation yet the implicit mockdata option in WebIDE works.

How to protect the source code of Flutter Web deployed to Firebase Hosting?

I made a Flutter Website and I deployed to Firebase Hosting, if I inspect the page on Google Chrome, in "Sources" tab it's possible get the source code of the website.
Is there any way to protect the source code, not having the entire code exposed like this?
If you look at the source file you will see that it is compiled/minified.
// snippet
var r
var q=d
try{if(a[b]===s){r=a[b]=q
r=a[b]=d()}else r=a[b]}finally{if(r===q)a[b]=null
a[c]=function(){return this[b]}}return r}}function lazy(a,b,c,d){var s=a
a[b]=s
What you are seeing are the sourcemaps which show a developer friendly view of the compiled/minified code. I don't see any options for turning sourcemaps off.
Something to keep in mind is that you are shipping a client side app. Once code is on other computers there is not much you can do to prevent them from reverse engineering it.
As described in this page, you need to build your web app using the flutter build web command, then deploy what you find in the ./build/web folder, to Firebase.
It seems that your are hosting your entire app directory.
You need to build your website with 'flutter build web'.
Then 'firebase deploy' the build/web directory.
You need to specify in your firebase.json at the route of the project :
{
"hosting": {
"site": "YOUR_WEBSITE_NAME",
"public": "build/web/",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}

.NET Core App - How to get build number at runtime

I've got a .NET Core MVC app which is built using TFS online, and published to Azure using the Release management stuff in TFS online. All very nice.
What I'd like to do is have my app display the build number somewhere. Doesn't matter where...but for example in a WebAPI endpoint like /api/buildversion.
Can anyone help with how I can get the TFS build number at runtime? When the app is packaged/published is there any file which contains the build number that I can access from the application?
The simple way is that you can store the build number in a file (e.g. appsettings.json), then get this data in app code.
Appsettings.json sample code:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-WebApplication1-ab933d83-8f4b-4024-9f3c-1aef5339a8f3;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
"CodeVersion": {
"Num": "#{MyBuildNumber}#"
}
}
Install Replace Tokens extension
Edit your build definition
Click Variables tab and add a variable. (Name: MyBuildNumber, Value:$(Build.BuildNumber))
Add Replace Tokens build step before build step
There is an easier way than adding more plugins and libraries. If you are using the web/app deploy method, expand the File Transforms & Variables
Assuming you want to update say a build number value in your appsettings.json
Then just update the variables setting in your release definition of VSTS
Super easy. This is more or less the same steps in Octopus IIRC.
You need to save the Build Number in your application at compile time.
You can access the build number with $Build.BuildNumber or $Env:BUILD_BUILDNUMBER depending on your environment. I usually write it as a variable into my ApplicationInfo.* with both the version and build number.