Since Xcode 11 had change Version to $(MARKETING_VERSION) & Build to $(CURRENT_PROJECT_VERSION)
there are new field in build setting
How can I change this value with script due to
xcrun agvtool new-version
xcrun agvtool new-marketing-version
not work perfectly as it on Xcode 10
I tried this one https://stackoverflow.com/a/58164679/7332815 but not working
I can only get correct value from
echo $versionNumber
echo $buildNumber
but how can I set new value to it?
update 2022/08/19
if using fastlane to bumping version
desc "Bump version and build nubmer"
lane :bump_version_and_build_number do |options|
version_number = options[:version]
puts version_number
sh("sed -i '' -e 's/MARKETING_VERSION \\= [^\\;]*\\;/MARKETING_VERSION = #{version_number};/' ../${YOUR_PROJECT_NAME}.xcodeproj/project.pbxproj")
increment_build_number
end
and just type in commend line
bundle exec fastlane bump_version_and_build_number version:1.0.1
okey I find a solution for myself, and thanks to an friend from meetup.
for Version number
I used
sed -i '' -e 's/MARKETING_VERSION \= [^\;]*\;/MARKETING_VERSION = 3.4.5;/' ${YOUR_PROJECT_NAME}.xcodeproj/project.pbxproj
e.g. sed -i '' -e 's/MARKETING_VERSION \= [^\;]*\;/MARKETING_VERSION = 3.4.5;/' DemoProject.xcodeproj/project.pbxproj
note that this can't work in pre-action of scheme setting
As for Build version
I used xcrun agvtool new-version xxx
e.g. xcrun agvtool new-version 3.4.5b
you can write these command in Build Phases
the reason I don't use xcrun agvtool new-marketing-version 3.4.5b is because it will write solid number into plist.
And I agree with Manuel's answer in Post
With these I can manage multi-targets' versioning
p.s. If you want to do that to, for example, notificationService target, remember to change version and build number manual at first to make Xcode 11 change the corresponding value to an variable like this
or you can make that by edit plist in source code of course.
That's the closest method I achieve to manage multi-target versioning so far.
On OS X 10.10 and 10.11 it was possible to use the softwareupdate utility to fetch a list of available software updates programmatically, and in XML/PLIST format. You could write e.g.
softwareupdate -l -f my-updates.plist
and then parse the resulting PLIST-file. On macOS 10.12, this is no longer possible. The utility gives an error message instead, stating that the "-f" option is no longer available:
$ softwareupdate -l -f my-updates.plist
softwareupdate: invalid option -- f
usage: softwareupdate <cmd> [<args> ...]
Is there any way to programmatically do something that is equivalent to softwareupdate -l -f xml-file.plist on macOS 10.12? It doesn't have to be a command line tool, Objective-C or C or Swift-solutions are welcome as well!
(I already tried --file, --xml and similar options, but nothing seems to work. It seems like Apple just dropped this feature. I could of course just parse the output of softwareupdate -l with some regular expressions, but I'd prefer a less hacky solution.)
Under Mac OS 10.10.3, I installed gnu-sed by typing:
brew install gnu-sed --default-names
When I type it again, I get the message:
gnu-sed-4.2.2 already installed
However, even after rebooting the system and restarting Terminal, I still cannot use the GNU version of sed. For example:
echo a | sed ’s_A_X_i’
returns:
bad flag in substitution command 'i'
What should I do to get the GNU version working?
Here are the paths in my $PATH variable.
/Users/WN/-myUnix
/opt/local/bin
/opt/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/Applications/calibre.app/Contents/MacOS
/opt/ImageMagick/bin
/usr/texbin
I'm sorry if my question seems obvious, but I am learning shell scripting on my own and don't quite understand yet how UNIX programs are installed. Any help to use GNU compliant commands (in this case sed, but soon I'll need others as well) on my Mac without causing damage or unnecessary clutter would be greatly appreciated.
Note (2019):
The --with-default-names option is removed since January 2019, so now that option is not available anymore.
When installing, Homebrew instructs on how to adapt the path, if one wants to use sed without the g prefix.
You already have the gnu-sed installed without the --with-default-names option.
With --with-default-names option it installs sed to /usr/local/bin/
Without that option it installs gsed
So in your case what you gotta do is:
$ brew uninstall gnu-sed
$ brew install gnu-sed --with-default-names
Update path if needed...
$ echo $PATH | grep -q '/usr/local/bin'; [ $? -ne 0 ] && export PATH=/usr/local/bin:$PATH
$ echo a | sed 's_A_X_i'
or use gsed as others suggested.
When you install the GNU version of sed for Mac OS X using:
$ brew install gnu-sed
The program that you use is gsed.
So for example:
$ echo "Calimero is a little chicken" > test
$ cat test
Calimero is a little chicken
$ gsed -i "s/little/big/g" test
$ cat test
Calimero is a big chicken
Also, to compliment the use of GNU command tools on Mac OS X, there is a nice blog post here to get the tools from linux:
Install and use GNU command line tools on Mac OS/OS X
$ brew install gnu-sed
$ export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
With these two commands gnu-sed works properly
The sed that ships with OS X is in /usr/bin.
The sed that homebrew installs is in /usr/local/bin.
If you prefer to use the homebrew one, you have two options:
Option 1
Every time you want to use homebrew sed, type
/usr/local/bin/sed
or, preferably
Option 2
Move /usr/local/bin/ ahead (i.e. before) /usr/bin in your PATH in your login profile, like this
export PATH=/usr/local/bin:<other places>
If you need to use gnu-sed command with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc. Just use the following command in your bash or terminal.
export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
--with-default-names didn't work for me on Mac OS X 10.14.2 so I created a symlink named sed to gsed higher in the $PATH
I also created a symlink named sed.1 to the gsed.1 manpage higher in the $MANPATH so man would access the gsed manpage instead of the default sed manpage
this export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
is only valid per terminal SESSIOn as soon as you restart its GONE ( Mojave )
Since the --with-default-names option was removed in Jan. 2019, my hack solution is:
# hack to override mac tools with homebrew versions (ls, sed, etc)
for p in `find "${HOMEBREW_PREFIX}" -type d -name gnubin` ; do
export PATH="${p}:${PATH}"
done
which is a little slow (crawling the dir every login) but works without forcing me to modify my .bashrc for every gnu tool I happen to install with brew.
A slightly faster way to do what #pjz suggests is the following:
for p in $(ls -d ${HOMEBREW_PREFIX:-/usr/local}/Cellar/*/*/libexec/gnubin); do
export PATH="${p}:${PATH}"
done
Of course this assumes every GNU package in brew will always have the same level of directories to get to gnubin.
Alternatively, you can speed up find by adding the -maxdepth 4 flag before -type d to reduce how far it has to do into directories.
When running brew install gnu-sed on latest homebrew it reports at the end:
==> Caveats
GNU "sed" has been installed as "gsed".
If you need to use it as "sed", you can add a "gnubin" directory
to your PATH from your bashrc like:
PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH"
gnu-sed installs by default as gsed. However, if you look in /opt/homebrew/opt/gnu-sed/libexec/gnubi you'll find a sed command. So following the above instructions to update the path should mean sed runs gnu-sed.
Generally I like the -F option - it quickly shows you what is a directory, what is executable etc. But it seems to be permanently on under Mac OS X (using the default ls command under 10.6.8 - I haven't installed GNU or anything). This prevents the output being filtered to another command that expects file names without the appended characters.
How do I change this behaviour?
thanks
I want to list all of the applications and versions installed on my mac. Stuff like perl, php, etc., not the stuff you see in the Applications directory... Is there a unix command for that?
pkgutil --packages
or
cat /Library/Receipts/InstallHistory.plist
Not exactly a unix command but:
system_profiler -detailLevel full > myreport.txt might be a good start.
There's an option to only list software (as there is an option to ouput xml) (read the manpage for the precise syntax).
If you're using macports you could just run port installed.
You can use command for get installed apps list
Json and xml output is available.
system_profiler SPApplicationsDataType -xml
system_profiler SPApplicationsDataType -json