I'm in the process of writing a shell script to inject and change values in the Info.plist file to prepare the app to go to the Mac App Store. From what I can tell, this has to be done outside of the RB compiler. I've got a partial shell script working. It successfully adds the 'LSApplicationCategoryType' to the file.
The problem I'm having is modifying value for the CFBundleVersion that is automatically created by RB.
It looks like this: 188.8.131.52.5 where:
1 = Major version
2 = Minor version
3 = Bug version
4 = StageCode
5 = NonRelease version
However, the Mac App Store only accepts 2-decimal point numbers (i.e. 1.2.3)
So, the goal is to read the existing CFBundleVersion number and manipulate it from 184.108.40.206.5 to 1.2.345 to allow it to be acceptable to the MAS. I also want to take the first part (1.2.3) and set that to the CFBundleShortVersionString value (also a Mac App Store requirement)-- I just need help with how to manipulate the strings to get the values required.
Here is the code I've got working so far:
# The command below successfully gets the current working directory of the script:
# DIR=$(cd "$(dirname "$0")"; pwd)
# The 'Defaults Write' command sets new values to the Info.plist file.
# NOTE: change the 'MyAppName.app' to the name of your application,
# then save this text file with a '*.command' extension to make this work with your system.
# The next line successfully adds the LSApplicationCategoryType to Info.plist
defaults write "$(cd "$(dirname "$0")"; pwd)/MyAppName.app/Contents/Info" LSApplicationCategoryType public.app-category.business
# The CFBundleVersion must be a two decimal point number (1.2.3),
# but RealBasic supplies it as a 4 decimal point number (220.127.116.11.5)
# with 1 = Major ver, 2 = Minor ver, 3 = Bug ver, 4 = StageCode, 5 = NonRelease
# The goal is to extract the string to the left of 3rd 'dot',
# set that string to the CFBundleShortVersionString,
# then remove the 3rd and 4th 'dot' to end up with a modified CFBundleVersion formatted as 1.2.345
# The next line returns the full version number as created by RealBasic:
RBVERSION=(`defaults read "$(cd "$(dirname "$0")"; pwd)/MyAppName.app/Contents/Info" CFBundleVersion`)
# The next link returns the zero-based position of the first 'dot'
FIRSTDOT=`echo $RBVERSION | grep -c "."`
I'm stuck here.
I cannot figure out how to extract and build the strings I need in the shell script.
Any ideas? --- or --- Is there a better way to handle this?