Running PackageMaker from command line - macos

I have a .pmdoc file I want to generate a .pkg from.
I have to do it from command line since its an automatic tool.
I looked at questions such as Create PackageMaker project file on the command line, but I can't find packagemaker command anywhere.
Seems like it should be in /Developer/usr/bin/packagemaker ?
In any case, I have PackageMaker.app installed, so the GUI works fine, but where can I find the command line util?

/Applications/PackageMaker.app/Contents/MacOs/PackageMaker --doc "your.pmdoc" --version BuildVersion --title "Title" --out "/Users/username/Desktop/Installer.pkg"

Apparently its simpler than I thought:
/Applications/PackageMaker.app/Contents/MacOs/PackageMaker

PackageMaker --doc "your.pmdoc" --version buildnumber --title "Test.pkg" --out "/Desktop/Test.pkg"

Related

Xcode Command Line Tool project. Path to the command?

Using Xcode 14.0.1, I am working on a Command Line Tool project.
As long as the command takes no argument it can be run and tested with the Xcode run button.
But I now want to use some arguments, I therefore need to run the command from a terminal.
Here comes my question:
How do I find the path for the command?
Edited because I misread the original question (see comments):
xcodebuild -project yourproj.xcodeproj -showBuildSettings from the location of your project should have that information. Might want to add a | grep TARGET_BUILD_DIR to filter for the output directory. It should be ~/Library/Developer/Xcode/DerivedData/projectname-[random-string]/Build/Products/Debug.
Previous answer about Xcode command line tools:
They should be under /Library/Developer/CommandLineTools/usr/bin, but xcodebuild and xcrun at /usr/bin, so should be in your PATH automatically. You can find out for sure with xcode-select --print-path.

can't run zipalign.exe in mac [duplicate]

When I try to run Zipalign on an apk I get the error "Command not found"
I am not that familiar with using terminal commands on the MAC but I have navigated to the SDK/Tools folder and run the following command:
zipalign -v 4 Project1.apk Project1-aligned.apk
I get Command not found
I have tried placing the apks in the Tools folder and same result.
Can someone help me to understand where the apks should be located and where I should run zipalign from?
Thanks, I am very frustrated about this as it seems so simple.
You can find correct path with this command:
find ~/Library/Android/sdk/build-tools -name "zipalign"
Perhaps the current directory is not in your path?
Try adding "./" before your command so
./zipalign -v 4 Project1.apk Project1-aligned.apk
You will find the zipalign tool at /path/to/sdk/build-tools/<build-tools-version>/zipalign NOT in the tools folder anymore.
~/Library/Android/sdk/build-tools/xxxx/zipalign
Drag this to terminal or save this in your path.
xxxx -> Version
Zipalign is a command that located at $ANDROID_HOME/build-tools/{android-version}/.
Hope it helped.
A simple one-liner:
This adds a line in your profile, to add the directory which contains the zipalign executable to your path
Then reloads the profile
echo "export PATH=\$PATH:~/Library/Android/sdk/build-tools/23.0.1/" >> ~/.bash_profile && . ~/.bash_profile
Make sure to replace 23.0.1 with your installed version
$ ls -l ~/Library/Android/sdk/build-tools/
total 0
drwxr-xr-x 23.0.1 <---
Now you should be able to use zipalign regardless of your current working dir
$ zipalign
on the mac with the zsh console, my solution was
command 1)
find ~/Library/Android/sdk/build-tools -name "zipalign"
----------------------------------------------------------
/Users/macOs/Library/Android/sdk/build-tools/28.0.3/zipalign
/Users/macOs/Library/Android/sdk/build-tools/26.0.2/zipalign
/Users/macOs/Library/Android/sdk/build-tools/25.0.2/zipalign
/Users/macOs/Library/Android/sdk/build-tools/27.0.3/zipalign
command 2)
echo "export PATH=\$PATH:~/Library/Android/sdk/build-tools/28.0.3/" >> ~/.bash_profile && . ~/.bash_profile
command 3)
ls -l ~/Library/Android/sdk/build-tools/
command 4)
zipalign -v 4 app-release-unsigned.apk nameApp.apk
2hours resume for newbies (like me) :
If you type this command :
zipalign -v 4 platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk app-release.apk
Witch gives you :
command not found: zipalign
It's maybe that the path is somewhere wrong.
If you have this :
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/bin/apt" (-1)
It confirms that its not really as it should be. So, to execute zipalign and finally publish your app, you have to go in the correct repository and execute commande.
1. Go to the correct repo to execute command :
The path is cd /Users/xxxyour_user_namexxx/Library/Android/sdk/build-tools/xxxxx/
cd /Users/greg/Library/Android/sdk/build-tools/28.0.3
2. Execute your zipalign command, don't forget to precise the path of apk file :
Obviously, chance "greg" and "myapp" with your user name & app name.
./zipalign -v 4 /Users/greg/Desktop/AppLocal/myapp/platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk /Users/greg/Desktop/AppLocal/myapp/platforms/android/app/build/outputs/apk/release/app-release.apk
Hope it helps.
Search it and reference it... I have it here and reference it like this:
/Users/lioncio/Desktop/adt-bundle-mac-x86_64-20140702/sdk/build-tools/android-4.4W/zipalign bla bla bla (all the options of the command!)
And worked
Relax! , Just Use Locate Command in Terminal WHEREVER it is , it will come out
tom-MacBook-Air:kavform_app tom$ locate zipalign
/Users/tom/Software/android-sdk-macosx/build-tools/24.0.1/zipalign
/Users/tom/Software/android-sdk-macosx/docs/tools/help/zipalign.html
In my case it was burried over here
/Users/tom/Software/android-sdk-macosx/build-tools/24.0.1/zipalign -v 4 /Users/tom/kavwork/kavform/kavform_app/platforms/android/build/outputs/apk/android-release-unsigned.apk BrideToBe.apk
add it to the path
on terminal
find path for zip align
find ~/Library/Android/sdk/build-tools -name "zipalign"
path: /Users/username/Library/Android/sdk/build-tools/26.0.1/zipalign
enter the path found in there
sudo nano /etc/paths
now on new terminal you can see zipalign reco
Solution for Mac
This error basically means that the terminal wasn't able to find the zipalign file.
So you can either type in the full path for your zipalign file with the command (located in your Android build-tools folder)
/Users/username/Library/Android/sdk/build-tools/26.0.1/zipalign -v 4 android-armv7-release-unsigned.apk helloWorld.apk;
If you do not know the location of the zipalign file, then just use this command
find ~/Library/Android/sdk/build-tools -name "zipalign"
If you are working on Windows, change the command prompt to point to the folder containing the zipalign.exe and then run the command. Also, I have found that you are not using the complete command:
zipalign [-f] [-v] 4 Input.apk Output.apk
cd android-sdk/build-tools/22.0.0/ - change directory to android sdk folder, build tools and choose version (I used 22.0.0).
Then at the prompt type:
./zipalign -v 4 /MyApp/android-x86-release-signed.apk ~/MyApp/android-x86-release-signedandzipped.apk
That worked for me. I tried the other solutions above with no success. I just had to run the command withn the proper folder, but that wasn't explained clearly in other resources I checked.
Navigate to the path of the zip align and include that with the command
/Users/ignatiusandrew/Library/Android/sdk/build-tools/25.0.2/zipalign 4 android-release-unsigned.apk igi.apk
Alternatively, if you do not want to add a specific build tools folder to the path, in case it changes in the future, you can use the first result of find command:
$(find ~/Library/Android/sdk/build-tools -name "zipalign" | head -n 1) <your-zipalign-parameters>
It might be especially useful in a CI pipeline.
for me this worked perfectly, I copied the zipalign file from the android path to the folder where I wanted to run command and then typed ./zipalign -v 4 android-release-unsigned.sdk nameofapp.apk
Note: It was on Mac
%ANDROID_HOME%\\build-tools\\25.0.2\\zipalign -v 4 .\\platforms\\android\\build\\outputs\\apk\\input.apk .\\path\\ output.apk
First,
if your android home is set, then you can just
cd $ANDROID_HOME
and
open . (This should be - /Users/username/Library/Android/, you can just cd to that path as well)
Next, navigate to "sdk/build-tools/25.0.3/" (version 25.0.3 in this case, yours may be a different version).
At your terminal (apk prompt), drag zipalign to the terminal and
...../zipalign -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk.
Should work fine.
Hope it helps.
Downloaded zipalign-file from github
zipalign exec copy and paste in your Project1-aligned.apk directory
./zipalign -v 4 Project1.apk Project1-aligned.apk
In my case
I follow below answer
Change directory
/path/to/sdk/build-tools//zipalign
Type
./zipalign instead zipalign
In short ./zipalign is solution for me.
Solution for Jenkins
For Jenkins users using MacOS to build and sign mobile apps who are experiencing this error, the solution could be this:
At the stage where the signature is made:
withEnv(['PATH=/Users/jenkins/Library/Android/sdk/build-tools/29.0.3',
'ANDROID_SDK_ROOT=/Users/jenkins/Library/Android/sdk',
'JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home'])
I am using Windows with git bash/command promt
zipalign.exe needed to be configured in environment variables.
so include sdk folder 'build-tool' with android version folder you are using to build.
e.g. E:\android-sdk\build-tools\22.0.1
it should contain 'zipalign.exe'. now you can user
zipalign -v 4 Project1.apk Project1-aligned.apk
from any location using command line tools.
thumb up for me so i can help more developers.

xcodebuild command line hangs

The following command hangs on my osx:
xcodebuild -scheme myscheme clean archive -archivePath /tmp
This command yields two output lines, and then hangs:
User defaults from command line:
IDEArchivePathOverride = /tmp
Now, this project does NOT have a workspace generated as it was created from a cordova command line (cordova build ios). The only way around it is to open xcode and close it. this generates a workspace and then the above command succeeds.
Did anyone experience something similar and know a way out of this? Any way to generate that workspace from the command line?
I had the same problem and the only way of fixing it was to open the project from the command line, wait, and close it again after a certain time.
open "My Project.xcodeproj"
sleep 10
killall Xcode
xcodebuild -scheme "My Project" clean archive "build/MyProject"
Not nice, but works for me.
Try setting the scheme to be 'shared'.
This can be done by going to the 'Manage Schemes...' and checking the 'Shared' checkbox.
Apple documents this process here: https://developer.apple.com/library/ios/recipes/xcode_help-scheme_editor/Articles/SchemeShare.html
If you're already have, or are willing to make, Ruby available to your build system then you could use this solution.
Install the xcodeproj gem on your build system
sudo gem install xcodeproj
and then integrate the following ruby script into your project (renaming your xcodeproj path).
#!/usr/bin/env ruby
require 'xcodeproj'
xcproj = Xcodeproj::Project.open("platforms/ios/schemedemo.xcodeproj")
xcproj.recreate_user_schemes
xcproj.save
The article explains how to make it part of a cordova hook if you're doing that, I simply called ruby directly from my Jenkins build.
This works because when you recreate the proj files, you destroy the schemes, so you need to recreate them.
I believe xcodebuild hangs because some data is missing from the project. You can make a template for what this data looks like and use a hook to populate it if necessary.
cordova add platform ios
cordova build ...
open platforms/ios/Whatever.xcodeproj in xcode
create xcuserdata_template
cp -R platforms/ios/Whatever.xcodeproj/xcuserdata xcuserdata_template/
replace the unique id in that template with XXXXXXXXXX
update your hook that runs xcodebuild
Step 7 example:
XCODE_PROJ=path/to/Whatever.xcodeproj
# get the mysterious id
ID=`grep "Whatever \*\/ = {" $XCODE_PROJ/project.pbxproj | \
grep -io "[-A-Z0-9]\{24\}"`
mkdir -p $XCODE_PROJ/xcuserdata
XCUSERDATAD=$XCODE_PROJ/xcuserdata/`whoami`.xcuserdatad
if [ ! -d "$XCUSERDATAD" ]; then
cp -R path/to/xcuserdata_template/username.xcuserdatad \
$XCUSERDATAD
find $XCUSERDATAD -type f -exec sed -i '' -e "s/XXXXXXXXXX/$ID/g" {} \;
fi
xcodebuild ...

Can I launch pgAdmin3 from command line?

Is there a way to launch pgAdmin3 from the Unix command line? I installed pgAdmin from pgadmin.org but I don't know where it was installed.
I've searched my /usr tree for pgadmin\* and pgAdmin\* to no avail.
I've also searched for the answer on the Internet but didn't find an answer.
The pgAdmin Command Line Parameters doc page discusses parameters you can use to launch pgAdmin but it doesn't discuss the executable itself.
Graphical utility is optional.
The link you are using describe only the graphical utility.
On linux you can use the psql command line parameters from this link:
https://www.postgresql.org/docs/9.2/static/app-psql.html
This link might be also usefull.
http://suite.opengeo.org/docs/latest/dataadmin/pgGettingStarted/firstconnect.html#dataadmin-pggettingstarted-firstconnect
For pgadmin4 for mac, you can find the location of psql binary.
sudo find / -name psql
In my case, I find it at:
/Applications/pgAdmin\ 4.app/Contents/SharedSupport/
Then you can build symbolic link from /usr/local/bin the above path.
ln -s /Applications/pgAdmin\ 4.app/Contents/SharedSupport/psql /usr/local/bin/psql
Then you can run psql anywhere in your terminal.
Like any program, you can launch it by calling its name:
pgadmin3 &
If it is not in one of the directories in your search path $PATH, you should use the complete pathname:
/path/to/the/program/pgadmin3 &

Remove package identifier file during installation

I'm a newbie in OSx development.
I'm creating an installer package using Packagemaker 3.0.4. Since I want to remove the local settings of my app during installation, I decided to remove the com.identifier.plist. However, I'm not that good in scripting and I'm just starting to explore what Packagemaker is capable of.
Ideally, I want my implementation to be as simple as this:
Check if the .plist file exists
Remove it.
I have tried:
#!/bin/sh
defaults delete ~/Library/Preferences/com.identifier.AppName.plist
Then I saved the delete.sh file to the Desktop. I opened the Packagemaker app and provided the path to my Desktop: /Users/MyName/Desktop/delete.sh in the Scripts Postflight. Then I executed build & run. It didn't work. I thought that it might probably be the script, so I changed it to:
#!/bin/sh
rm ~/Library/Preferences/com.identifier.AppName.plist;
Then I loaded the delete.sh file the same way as I did on the script above. But I received this error:
Mar 29 20:50:54 Mac-mini installd[5425]: PackageKit: Install Failed: PKG: post-flight scripts for "com.testIdentifier.test.AppName.pkg"\nError Domain=PKInstallErrorDomain Code=112 UserInfo=0x100404220 "An error occurred while running scripts from the package “test.pkg”." {\n NSFilePath = "./postflight";\n NSLocalizedDescription = "An error occurred while running scripts from the package \U201ctest.pkg\U201d.";\n NSURL = "./Contents/Packages/test.pkg -- file://localhost/Users/MyName/Desktop/AppName.mpkg/";\n PKInstallPackageIdentifier = "com.testIdentifier.test.AppName.pkg";\n}
If anyone who has a Step-by-Step implementation of creating & adding script to the Packagemaker, and perhaps, my scripts aren't correct, it would be awesome if you could help me out.
Thank you so much in advance! :)
Did you try to launch your delete.sh from terminal? Looks like you have an error in syntax - ';' at the end of the rm command, and you should use -f flag for the rm command (see man rm) in other case script will prompt for confirmation and postflight script can't be interactive.
Edit: as 一二三 mentioned semicolon - is not the point, you should probably look to his answer. And before you'll create your package just try your script in terminal (you can do sudo su before to login as root)
I've got it...
Here's my script:
#!/usr/bin/env bash
file=~/Library/Preferences//com.identifier.AppName.plist
if [ -e "$file" ]
then
# file is found
/usr/bin/defaults delete ~/Library/Preferences//com.identifier.AppName
else
# file not found."
fi
exit 0
I then added it to PackageMaker. I'm not really sure if I'm right but I might have just forgotten to add the script's file into the contents. That's why it never worked earlier. I just put the script's path on the postflight.
Anyway, thanks a lot to everyone for the tips.

Resources