xcode build version number in shell script - iphone

I have an user-defined Project setting (KEY/VALUE) like this:
LATEST_BUILD_NUMBER 2.2.2.2
In my Info.plist, I have set the bundle version (CFBundleVersion) key/value pair like this
Bundle version ${LATEST_BUILD_NUMBER}
I am creating a shell script to do the builds for my all of my targets. I want to fetch the value "2.2.2.2" in my script. This is what I tried:
INFO_PLIST_FULL_PATH="${PROJDIR}/${TARGET_NAME}-Info.plist"
echo plist path ${INFO_PLIST_FULL_PATH}
TARGET_BUILD_VERSION_NUMBER=$(/usr/libexec/PlistBuddy -c "Print ${BUILD_NUMBER}" $INFO_PLIST_FULL_PATH)
echo version_number ${TARGET_BUILD_VERSION_NUMBER}
When I do this, the output for plist path is correct but TARGET_BUILD_VERSION_NUMBER output is "${LATEST_BUILD_NUMBER}" instead of "2.2.2.2"
How can I get the value instead of the variable name?

Xcode doesn't substitute the value till it copies over the file into the built product. So, go to the source: Grab the value out of the *.xcodeproj/project.pbxproj file. You should be able to find the current value in there with a quick search. Then you just have to devise a regex to strip it out.

Related

Stale file is located outside of the allowed root path when using Cuckoo

I wanted to mock some of my files, so I used Cuckoo framework. I am using Swift Package Manager, so I did every step that is shown in README of framework.
I tried to use this script
# Define output file. Change "${PROJECT_DIR}/${PROJECT_NAME}Tests" to your test's
root source folder, if it's not the default name.
OUTPUT_FILE="${PROJECT_DIR}/${PROJECT_NAME}Tests/GeneratedMocks.swift"
echo "Generated Mocks File = ${OUTPUT_FILE}"
# Define input directory. Change "${PROJECT_DIR}/${PROJECT_NAME}" to your project's root source folder, if it's not the default name.
INPUT_DIR="${PROJECT_DIR}/${PROJECT_NAME}"
echo "Mocks Input Directory = ${INPUT_DIR}"
# Generate mock files, include as many input files as you'd like to create mocks for.
"${PROJECT_DIR}/run" --download generate --testable "${PROJECT_NAME}" \
--output "${OUTPUT_FILE}" \
"${INPUT_DIR}/Common/Repository/LatestNewsRepository/LatestNewsRepositoryImpl.swift" \
# ... and so forth, the last line should never end with a backslash
# After running once, locate `GeneratedMocks.swift` and drag it into your Xcode test target group.
I also downloaded the latest run script and I had to check For install builds only.
When app is launched I am getting this error -
Stale file '.../LibraryTests/GeneratedMocks.swift' is located outside of the allowed root paths.
Things I tried -
Clean Xcode derived data
Clean build folder
Reset Xcode
Reset Packages Cache
and I am still not getting output file. Is there anything else I should try?

Using Regex in install4j Compiler Variable

During installation, install4J looks for a certain file format to load (and later extract). The file format is the following:
server_${compiler:component_name}_${compiler:modality_version}_${compiler:modality_os}_BN${compiler:timestamp}.tar.gz
Everything works except for the last compiler variable which is the timestamp. I would like that variable to be a regex:
([0-9]{4})(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])(2[0-3]|[01][0-9])([0-5][0-9])
However, install4j is unable to figure out that what I'm giving it is a regex and not hard-coded variable.
How can I resolve this?
Currently, I'm getting this during the build:
[INFO] [WARNING] The path "..\..\target\resources\archives\server_merch_4.1_SP1_win-x86-64_BN([0-9]{4})(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])(2[0-3]|[01][0-9])([0-5][0-9]).tar.gz" does not exist.
If this is not possible, is there a way I can use the wildcard "*"?
There is no ad-hoc regex pattern matching like that in install4j.
Use a "Set a variable" action where you list files yourself and write the matching file to an installer variable. In the action that reads the file you can then use the expression ${installer:myVariable} where myVariable is the variable name configured in the "Set a variable" action.

downloading lastfinished build from teamcity

I'm using Perl's File::Fetch to download a file from the lastfinished build in Teamcity. This is working fine except the file is versioned, but I'm not getting the version number.
sub GetTeamcityFiles {
my $latest_version = "C:/dowloads"
my $uri = "http://<teamcity>/guestAuth/repository/download/bt11/.lastFinished/MyApp.{build.number}.zip";
# fetch the uri to extract directory
my $ff = File::Fetch->new(uri => "$uri");
my $where = $ff->fetch( to => "$latest_version" );
This gives me a file:
C:\downloads\MyApp.{build.number}.zip.
However, the name of the file downloaded has a build number in the name. Unfortunately there is no version file within the zip, so this is the only way I have of telling what file i've downloaded. Is there any way to get this build number?
c:\downloads\MyApp.12345.zip
With build configs modification
If you have the ability to modify the build configs in TeamCity, you can easily embed the build number into the zip file.
Create a new build step - choose command line
For the script, do something like: echo %build.number% > version.txt
That will put version.txt at the root directory of your build folder in TeamCity, which you can include in your zip later when you create it.
You can later read that file in.
I'm not able to access my servers right now so I don't have the exact name of the parameter, but typing %build will pull up a list of TeamCity parameters to choose from, and I think it is %build.number% that you're after.
Without build configs modification
If you're not able to modify the configs, you're going to need something like egrep:
$ echo MyApp.12.3.4.zip | egrep -o '([0-9]+.){2}[0-9]+'
> 12.3.4
$ echo MyApp.1234.zip | egrep -o '[0-9]+'
> 1234
It looks like you're running on Windows; in those cases I use UnxUtils & UnxUpdates to get access to utilities like this. They're very lightweight and do not install to the registry, just add them to your system PATH.

shell-write command problem - How to add a "key" to a plist file via terminal? (iphone,mobileterminal)

I wanted to run this command in mobileterminal (iphone):
write "/myPlist.plist" TestKey "TestStringForKey"
but it says: 'write' command not found
The plist EXISTS!
What am I doing wrong?
Is there any other way?
EDIT: TestKey does not exist in the plist. I want to create it.
EDIT: Some infos: iPod Touch with iOS 4.2.1 and with the newest mobileterminal from googlecode.
EDIT: Now I installed "write".
If I run the command i get this: usage: write user [tty]
I think you want the defaults command:
defaults write "myPlist.plist" TestKey "TestStringForKey"
I use this to write to a plist file with iPhone terminal. Just make sure you have ericautilities installed from Cydia.
plutil -key ShowedAlert -value nope /dir/ect/ory/to/playlist.plist
/myPlist.plist means, that myPlist.plist is in your root directory. I think, it's in your current working directory, so just use
write "myPlist.plist" TestKey "TestStringForKey"

diffstrings.py : how do you specify path arguments?

I am trying to use diffstrings.py from Three20 on my iPhone project, and I can't find the proper format for the path arguments (as in "Usage: diffstrings.py [options] path1 path2 ...").
For example, when I run the script in my Xcode project directory like this
~/py/diffstrings.py -b
it analyzes just the main.m and finds 0 strings to localize,
then it diffs against existing fr.lproj and others, and finds that thes contain "obsolete strings".
Can anyone post examples of successful comand line invocations of diffstrings.py, for options -b, -d and -m?
Taking a quick look at the code here http://github.com/facebook/three20/blob/master/diffstrings.py I see that if you don't specify any command line options, it assumes you mean the directory wherever the script lives in. So the option is to either copy .py file to where your .m files are, or simple use the command
~py/diffstrings.py -b .
That is, give the current directory (.) as the path argument.