Script to generate Xcode empty project - ios

I always need some empty Xcode projects for testing purposes. (I cannot use coderunner or other stuff, I really need an Xcode project).
I tried different approaches but I didn't find a real solution:
Created a basic, empty project and created a script for copying the entire folder.
It works, but you cannot have different names for the project, this means that you have to rename the project manually after the copy.
Using the Crafter gem
It's a useful gem, but you can only configure an existing project, you cannot create a new one.
Using KZBootstrap
The same as before, it's useful for configuring the project, not for creating a new one.
Using the xcodeproj gem (http://rubygems.org/gems/xcodeproj)
The documentation is not enough for me, and I don't understand how to use it :(
Any advice?

Finally i found a solution that fits my needs.
I started with an empty, sample project (here https://dl.dropboxusercontent.com/u/792862/SamplePRJ.zip)
and i wrote a bash script to rename all the files and all the occurrences of the previous name.
The script can be improved, but it basically works
export LC_CTYPE=C
export LANG=C
OLDNAME="SamplePRJ"
NEWNAME="Sample2PRJ"
mv $OLDNAME $NEWNAME
cd $NEWNAME
mv $OLDNAME $NEWNAME
mv ${OLDNAME}Tests ${NEWNAME}Tests
mv ${OLDNAME}.xcodeproj ${NEWNAME}.xcodeproj
mv ${NEWNAME}.xcodeproj/xcshareddata/xcschemes/${OLDNAME}.xcscheme ${NEWNAME}.xcodeproj/xcshareddata/xcschemes/${NEWNAME}.xcscheme
find . -type f -print0 | xargs -0 sed -i '' "s/${OLDNAME}/${NEWNAME}/g"

Related

How to remove unused Images from Xcode Project?

I want to delete all the unused images from a XCode project and in order to do that I am using the following script:
#!/bin/sh
PROJ=`find . -name '*.xib’ -o -name '*.[mh]'`
for png in `find . -name '*.png'`
do
name=`basename $png`
if ! grep -q $name $PROJ; then
rm –Rf "$png"
echo "$png is not referenced"
fi
done
The above script is working fine and deleting all the images from the project that are not referenced in ".xib" however, there is a catch.
Problem
The script is also deleting the images that are referenced in ".m" files. (Images that are getting set programmatically)
Request
Could you please tell me how can I add ".m" with ".xib" files in search.
PROJ=`find . -name '*.xib’ -o -name '*.[mh]'`
First, not you are using rm -Rf to delete a single image. Be careful! This removes recursively and without forcing it, so it can be risky and remove things you don't want. Probably better to just say rm.
Your script is quite well organized and tidy. To make it more robust, it is always good to use quotes in the variables. This way, it will also support names with spaces. That is, if you want to remove a file called "a b.png", and the name is stored in the variable $png, saying rm $png you run rm a b.png, so it will try to remove a and b.png.
After all this introduction, let's focus on the specific problem here.
It looks like you are looking for those files that either end with .xib or m. The find . -name '*.xib’ -o -name '*.[mh]' syntax seems to be fine, but it may be better to use regex in find.
find -type f -regex '.*\.\(xib\|m|h\)'
Finally, you are using a for loop to go through the result of a find. Note you can also say:
while IFS= read -r png;
do
# things with "$png"
done < <(find ...)
but I won't go and suggest anything else here because I don't really follow the logic on these .xib, .png files. If you can show an example I will update my answer.

Override rpmbuild build location when called from command line

I am making some config packages which are built by Jenkins, then checked out whenever they are needed. The package itself is built and runs fine. My problem right now is the directories that rpmbuild uses for actually building the project. When I call rpmbuild SPECS/package.spec from my working directory, rpmbuild makes a new directory at /home/user/rpmbuild. This was fine when I was running tests but I would rather that I just be able to build from whatever file it is called from for the Jenkins process.
I see online people saying to make a ~/.rpmmacros file to overwrite the $_topdir variable. That approach isn't really working for the Jenkins build. Is there some way to simply call rpmbuild and build in the current directory? The structure is all there and it would work better for what I am trying to do. Thanks.
Yes, just override _topdir directly.
rpmbuild -D '_topdir /new/value/for/_topdir'
or
rpmbuild --define='_topdir /new/value/for/_topdir'
those should be identical but I've learned that they aren't always for some reason (and in quick tests rpm -D '_topdir /opt/tnstmp' --showrc | grep _topdir doesn't show the modified value but rpm --define '_topdir /opt/tnstmp' --showrc | grep _topdir did).

iOS : How to add run script properly?

I'm trying to getting error logs from Parse Crash reporting for my app, its logging but not showing symbolic crash reports, also at Parse they're asking to add symbolic files for my app. I'd search for it and found that needs to upload symbolic files each time when you create a new build.
This is the sample script from Parse:
export PATH=/usr/local/bin:$PATH
cd "<path_to_cloudcode_folder>"
parse symbols -p "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
I want to add dynamic path to path_to_cloudcode_folder because we're working remotely via git so the path_to_cloudcode_folder is different based on each user.
How do I add a dynamic path there, so it will work at all of the places without error.
P.S. I thought $SCRROOT would work, but it won't. It gives me error,
No such file or directory.
What's wrong?
echo $SCRROOT
gives me following folder path,
/Hagile/Workspace/Git/TestApp
Above path contains a folder, parse having 3 sub folders. i.e.
- Hagile |
- Workspace |
- Git |
- TestApp |
- cloud | config | public
This worked for me:
cd "${PROJECT_DIR}"/<path to cloud folder>/parse
My problem laid in the fact that I had spaces in my path and this was tripping up the compiler. Providing the double quotes did it for me.
See this more in-depth explanation.
#Julian answer help me to get this working ! I needed to change it little.
echo "-start-----------------------------"
export PATH=/usr/local/bin:$PATH
cd "${PROJECT_DIR}"/parse
parse symbols -p "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
echo "-end-----------------------------"
Here's the output

Run gcov tool on folder

I run gcov tool on some .c files using gcc -fprofile-arcs -ftest-coverage [filenames]. command
But its is very tedious job of supplying file names to this command.
Instead I need help in which I can run gcov tool on a folder which contains all source files.
Is this possible?
Please help me out with a solution.
Thanks in advance.
I ran into the same problem, my project contains ~3000 files.
Write a shell script to grab all .c .gcno and .gcda files to a common folder using find exec, then run gcov using the same command.
sample:
LOCATION=your_gcov_folder_name
find -name '*.c' -exec cp -t $LOCATION {} +
find -name '*.gcno' -exec cp -t $LOCATION {} +
find -name '*.gcda' -exec cp -t $LOCATION {} +
cd $LOCATION
find -name '*.c' -exec gcov -bf {} \;
run it on your code folder which contains your project.
[LCOV][1] provides user friendly reports automatically, firstly I would suggest to take a look.
If you really want to use gcov to show coverage data you could try
find . -name "*.cpp" -exec sh -c 'gcov {} -o "$(dirname {})"' \;
this will create gcov files based on your gcno and gcda files.
And usually it is not perfect idea to move gcno/gcda files. It will cause problems with finding source codes.
First of all, the command you have specified in the question is for compiling c/c++ files and instrumenting them for getting coverage generated later at the time of execution.
That command can be used as following too:
gcc --coverage
g++ --coverage
Note: you must specify the same flag for linking too.
Now about the question, if your question is about compiling multiple files then there are a lot ways for building projects, no matter how complex. You can use automated builds for it.
If your question is about generating coverage report for multiple files then:
You can use gcovr for generating report in various forms just by specifying root directory (directory above src and obj ) with "-r or --root=ROOT" flags.
Refer to this user guide.
Answers given by others works too if you really want to use only gcov and nothing else. But in my opinion gcovr meets every purpose that can be fulfilled with gcov(except function level detail, you can get line level details though).
if you are not getting coverage report try removig
"coverageReporters": [
"text",
"text-summary" ],
from file
jest.config.js

How can I extract all localizable strings from all XIB files into one file?

I am looking for a way of extracting all localizable strings from .xib files and have all of them saved in a single file.
Probably this involves ibtool but I was not able to determine a way of merging all these in only one translation dictionary (could be .strings, .plist or something else).
Open terminal and cd to the root directory of the project (or directory where you store all XIB files) and type in this command:
find . -name \*.xib | xargs -t -I '{}' ibtool --generate-strings-file '{}'.txt '{}'
The magic is the find and xargs commands working together. -I option generates placeholder. -t is just for verbose output (you see what commands has been generated and executed).
It generates txts files with the same name as xib files in the same directory.
This command can be improved to concatenate output into one file but still is a good starting point.
Joining them together:
You can concatenate those freshly created files into one using similar terminal command:
find . -name \*.xib.txt | xargs -t -I '{}' cat '{}' > ./xib-strings-concatenated.txt
This command will put all strings into one file xib-strings-concatenated.txt in root directory.
You can delete generated partial files (if you want) using find and xargs again:
find . -name \*.xib.txt | xargs -t -I '{}' rm -f '{}'
this is a lot easier now.
in xcode, select your project (not a target)
then use menu/editor/export for localisation
xcode will output an xliff file with all localisable strings from your entire project.

Resources