Electron — Can't get custom icon to appear - node.js

I'm having an issue setting the icon for my Electron app in two different ways:
Non-Packaged (Running the app via terminal)
My main.js does specify an 'icon' value, pointing to the icon file, but it does not apply.
Packaged (with electron-packager)
My package.json file specifies the 'icon' key, pointing to the icon file, and I have the .icns (Mac) file in the build directory. I used electron-packager to build the app, but the icon is not applied, the default electron icon is used instead.
Not sure what I'm doing wrong here, everything appears correct.

If you mean the icon on the dock, on MAC can should use:
const app = electron.app;
const image = electron.nativeImage.createFromPath(
app.getAppPath() + "/public/YOUR_APP_IMAGE_NAME"
);
app.dock.setIcon(image);

There is a good tutorial here:
https://www.christianengvall.se/electron-app-icons/
Follow the steps but make sure you don't skip anything.
This is also a relevant issue on GitHub:
https://github.com/electron-userland/electron-builder/issues/289
More links here:
https://discuss.atom.io/t/changing-electron-app-icon-and-information/18631

If you come across this issue on Mac OS, it may be the icon cache that is messing things up. It was the case for me. I used the following command to clear it :
sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3;sudo touch /Applications/* ; killall Dock; killall Finder
Then I built the app again and this time it I had the icon I specified with electron-packager.

You can add this script to package.json and it works perfectly fine. Mostly its because of the path issues.
"package-mac": "electron-packager . --overwrite --platform=darwin --arch=x64 --icon=assets/icons/mac/icon.icns --prune=true --out=release-builds",

Related

How to reset the $PATH?

I confess, I very don't know what I'm talking about.
This morning I wanted to install Javascripting (to learn javascript) on my Mac, so I watch a video to do it:
I downloaded node.js and I installed it;
after that I opened the terminal and I type: npm install -g javascripting and here I've got some errors. I tried to search the solution but I think I created a big problem:
Basically I modified the $PATH several times and now the situation is this.
If I run echo PATH it displays
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
I wanted to clean it all so I tried to type:
brew uninstall --force node
but the terminal says:
zsh: command not found: brew
I can't do anything.
Please, someone help me :(
If you just want to clear this environment variable, just do 'unset PATH'.
But, be aware that PATH is used by a shell (i.e. bash, ksh, zsh...) to look for programs in these directories. clearing it has side effects.
The 'brew' program is somewhere, to find it, you could use the following command :
find / -name 'brew' -print
It can take a little while to find it.
Either use that found path, or add the directory where that program is found to the PATH variable, as in
PATH=$PATH:/location_of_brew_program; export PATH

How can I run a node app from the command line?

On RHEL I have put various executable files in ~/.local/bin eg. nvim.appimage. As ~/.local/bin is in my $PATH variable I can call nvim.appimage from any directory which is great.
I want some node apps to be able to be called from any directory, for example ESLint. These are not binaries but are directories with a lot of files and directories inside. Which directory (presumably in $PATH) should they be in so that I as a user but not other users can call them from any of my directories? Also how should they be invoked.
As an example, I have put the cowsay node app into ~/.local/bin I can invoke it like this from any of my directories:
$ node ~/.local/bin/cowsay/node_modules/cowsay/cli.js moo
(I can actually omit node from that command as cli.js has #!bin/bash/env node at the top.)
I would like to be able to invoke cowsay from any of my directories with a simple command eg cowsay
I know that a lot of node apps are not intended to be run from the command line but some are. In particular I am having great difficulty to get neovim with Ale to recognize some node linters like ESLint. Perhaps if I can sort the cowsay issue out I may be able to move on to ESLint with neovim. I am hoping that if I can get ESLint invokable from a location in $PATH it might be usable by neovim / Ale.
Can this achieve what you expected ?
mkdir ~/.local/nodexe
cd ~/.local/nodexe
ln -fs ../bin/cowsay/node_modules/cowsay/cli.js cowsay
PATH=$PATH:~/.local/nodexe
Assuming you have #!bin/bash/env node in cli.js, then you can run by typing cowsay moo

Bash: app definitely on $path, but not found when run

I'm having a issue with a python app that I installed on a empty server.
The package I installed is invoke using pip3 install invoke
After install if I just run invoke without specifying the abs path, then I
get a error: -bash: /usr/bin/invoke: No such file or directory
Running it with the full path to the app works fine.
So I'm confused why it's ignoring the legit app that is in a location
that is definitely on the $PATH.
See the cli commands below for visual reference:
/# invoke
-bash: /usr/bin/invoke: No such file or directory
/# find -name invoke
./usr/local/bin/invoke
./usr/local/lib/python3.6/dist-packages/invoke
/# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
/# /usr/local/bin/invoke -V
Invoke 1.4.1
Anyone know what's going on here?
As mentioned in the comments of my original post, this was because the command was previously hashed and bash remembered the old path. Running hash -r was suggested, which resets all mappings. I eventually used hash -d invoke which cleared only that single entry. My reasoning was that I wasn't sure if anything else in the mappings were expected to be there by some other app.
Edit: As pointed out in the comments below, there is no harm in using -r since it's just a faster way to look something up and is saved there once it finds it again anyway.

How to fix "IPA processing failed" error in xcode 11?

When I tried to create IPA file using Distribute APP option. It gave "IPA processing failed" error.
I have checked logs file: IDEDistribution.standard.log file.
2019-08-06 18:36:52 +0000 warning: Configuration issue: platform
iPhoneSimulator.platform doesn't have any non-simulator SDKs; ignoring
it Scanning IPA... 2019-08-06 18:36:52 +0000 Assertion failed:
Expected 4 archs in otool output:
/var/folders/4t/rpjk7pd55t16jfrd32y98gf0lb2t68/T/IDEDistributionOptionThinning.~~~a4cZJc/Payload/demo.app/Frameworks/AppAuth.framework/AppAuth:
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags MH_MAGIC_64 X86_64 ALL 0x00 DYLIB 23
3680 NOUNDEFS DYLDLINK TWOLEVEL NO_REEXPORTED_DYLIBS Load command 0
I faced same issue.I have fix this issue used this script.
Please follow the same steps.
Build Phases -> plus button -> to create New Run Script Phase
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
echo $(lipo -info "$FRAMEWORK_EXECUTABLE_PATH")
FRAMEWORK_TMP_PATH="$FRAMEWORK_EXECUTABLE_PATH-tmp"
case "${TARGET_BUILD_DIR}" in
*"iphonesimulator")
echo "No need to remove archs"
;;
*)
if $(lipo "$FRAMEWORK_EXECUTABLE_PATH" -verify_arch "i386") ; then
lipo -output "$FRAMEWORK_TMP_PATH" -remove "i386" "$FRAMEWORK_EXECUTABLE_PATH"
echo "i386 architecture removed"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_TMP_PATH" "$FRAMEWORK_EXECUTABLE_PATH"
fi
if $(lipo "$FRAMEWORK_EXECUTABLE_PATH" -verify_arch "x86_64") ; then
lipo -output "$FRAMEWORK_TMP_PATH" -remove "x86_64" "$FRAMEWORK_EXECUTABLE_PATH"
echo "x86_64 architecture removed"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_TMP_PATH" "$FRAMEWORK_EXECUTABLE_PATH"
fi
;;
esac
echo "Completed for executable $FRAMEWORK_EXECUTABLE_PATH"
echo $(lipo -info "$FRAMEWORK_EXECUTABLE_PATH")
done
1.uncheck "Rebuild from bitcode",
2.click next fast fast fast. (speed is also important.)
if not , it will show IPA processing failed.
You should check the Embed Frameworks under Xcode > build phases.
If your framework is introduced here, you can't use i386\x86_64 in your framework. Because the Embed Frameworks are copied to the application. To control the size of the application, the frameworks in the Embed Frameworks are required to be the most streamlined.
You can use Link Binary With Libraries to introduce your framework, as described here: https://github.com/Carthage/Carthage/issues/1046
Note that you need to add a new Run Script and add your framework to it, or it will crash.
To solve similar problem on my end I used the following:
In app's target I went to the Build Phases
After the Embed Frameworks and Embed App Extensions sections I've added Run script with the following script:
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[#]}"
rm "${EXTRACTED_ARCHS[#]}"
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done
The script I took from here: https://medium.com/#maximbilan/ios-submission-unsupported-architectures-issues-733917a98cc3, credits goes to Daniel Kennet!
Also, be aware that this script could also cause compilation errors. In such case, here's the solution: Errors building Xcode Project after adding in Run Script fatal error: lipo: input file
On my end I also noticed that I have to turn off this script when compiling app locally (on development devices/simulator)
Hope that helps!
It seems that a dynamic library with i386 or x86_64 architecture is not allowed when archive in Xcode 11. And I fixed it by removing those architectures from the mentioned frameworks
I had to uncheck "Rebuild from bitcode"
For those who try with M1 Chip (Silicon)
Quit Xcode completely (Close and Quit From the Menu Bar) and remove existing archived one.
Go to finder -> Applications
Right Click on Xcode and select "Get Info"
Check Rosetta
Try again opening Xcode
We've solved this problem by setting Always Embed Swift Standard Libraries to NO in all frameworks, that are being used in our app.
I had to select "Do not embed" in Frameworks to solve this
Having Bitcode enabled caused the issue in my case. Go to
Build Settings -> Enable Bitcode and set it to NO.
Try archiving again and it should work.
In my case, app thinning was failing and the reason was my internal framework was depending Alamofire and it's binary was embedding and signing. Changing it's Embed option from Embed & Sign -> Do Not Embed solved my issue immediately.
In my opinion, all logic behind this issue is keep app bundle size lower as much as Apple can but embedding your frameworks increase this size. I think that's all App Thinning complains about. So, the general solution to this issue, check every external frameworks that can increase your app bundle. Especially, if you're using Carthage.
I found issue with SDWebImageMapKit framework available with SDWebImage. I just removed it and got success.
My issue was that I had a single embedded binary framework.
I removed it from the project to update it. Which caused Xcode to delete the embed frameworks build phase (because there were no more frameworks to embed).
After adding the new version of our framework, the embed binaries phase was at the bottom of the build phase order. Which ended up being the reason it was failing.
I had to re-order embed frameworks before my run script to fix the problem.
I haven't updated my cocoapods for a while, fixed it by updating and re-installing the pods.
sudo gem install cocoapods
pod update
pod deintegrate
pod install
My solution was to set all frameworks dependencies to "Do Not Embed"
Open Terminal
Open your project drag path of respective framework to Terminal 
For example.
 cd /Users/xxxxx/Desktop/MyProject/ABC.framework
Set your Framework name in below command and run

lipo -remove i386 ABC -o ABC && lipo -remove x86_64 ABC -o ABC

ElementaryOS Freya - Dropbox Icon

I'm having some troubles with dropbox icon on tray with ElementaryOS Freya
Dropbox is synchronizing, the unique problem is the icon on tray that I can't show anyway.
Procedures done:
1 - Instaled dropbox by .deb downloaded from dropbox site using dpkg -i
2 - Instaled by .tar downloaded from dropbox site using this:
$ cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -
$ ~/.dropbox-dist/dropboxd
3 - Instaled by Elementary repository using:
$ sudo apt-get install dropbox
4 - I've deleted the folders ~/.dropbox , ~/.dropbox.dist and executed the daemon again with $ dropbox start -i
5 - I've put the code export DROPBOX_USE_LIBAPPINDICATOR=1 in files: ~/.bashrc, ~/xsessionrc and /etc/profile.
6 - I've instaled the packages: pantheon-files-plugin-dropbox and libappindicator1
Any idea for fix?
A quick fix I go into detail on my blog here, but simply here:
Kill dropbox, and restart it so it shows
dropbox stop && env XDG_CURRENT_DESKTOP=Unity dropbox start
Go to the settings in dropbox after it starts up and select to not start at startup.
Go to system settings -> Applications, from the tab up top select "Startup" and add a command from the + button at the bottom left and there will be an input where you can enter in a command below and press enter to save:
env XDG_CURRENT_DESKTOP=Unity dropbox start
Restart and you should be good to go.
I followed a similar process to the one in this blog comment.
The following script started Dropbox showing the icon on the tray as expected.
#!/bin/sh
sleep 10 && dropbox stop && env XDG_CURRENT_DESKTOP=Unity dropbox start
To make it permanent, simply editing dropbox.desktop like they mention in the blog didn't work for me.
Run the script and go to Dropbox's preferences. Untick "Start Dropbox on system startup". This will get rid of the .desktop file.
Now we create our own in the same place, ~/.config/autostart, we can name it dropbox-fix.desktop:
[Desktop Entry]
Name=Dropbox (fixed)
GenericName=File Synchronizer
Comment=Sync your files across computers and to the web
Exec=/usr/bin/dropbox-fix.sh
Terminal=false
Type=Application
Icon=dropbox
Categories=Network;FileTransfer;
StartupNotify=false
You should change Exec=/usr/bin/dropbox-fix.sh to where you have saved the script and make it executable.
You could try running Dropbox, then click on Options and there should be an option that says show "Icon in tray" or something along those lines. Please let me know if this helps you or if you need more assistance.

Resources