iOS : How to add run script properly? - ios

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

Related

XlsxReaderWriter creating read only .xlsx file?

I am using XlsxReaderWriter | Objective - C to insert data and generate a .xlsx file. I am using demo.xlsx from bundle directory and then copying to documents directory to insert data and then saving it with a new name. The demo.xlsx has Read and Write for permission for everyone. After generating the new file I am giving an option to the user to export the file to Microsoft Excel app on their device. When I try to open file in Microsoft Excel app it says that it is read only file and my data till column "T" of the sheet is not shown and the sheet shows from column "U" with no data inside. But the data is being shown in other third party apps or document controller, why is this happening ?
The code I tried :
let fileManager = NSFileManager.defaultManager()
let directory = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]
let path = "\(directory)/file.txt"
let attributes: [String:AnyObject] = [NSFilePosixPermissions: NSNumber(short: 0o666)]
let success = fileManager.createFileAtPath(path, contents: nil, attributes: attributes)
if success && fileManager.isWritableFileAtPath(path) && fileManager.isReadableFileAtPath(path) {
NSLog("Worked!")
} else {
NSLog("Failed!")
}
The file was created before I gave it permission instead of "createFileAtPath"
The permissions were perfectly set, I checked in documents directory. Just that the Microsoft Excel app on iOS says it's still "Read Only" file.
I'm guessing it's likely that the problem is not anything about the file permissions, but something about the contents of the .xlsx file your app has generated that Microsoft Excel is unhappy about - hence why it is also not displaying all the data. A .xlsx file is just a zip file containing xml.
You can un-package it using unzip, and then format all the xml for easy reading using a tool like xmllint --format.
If you produce a very simple xlsx that shows the problem (the simplest example that still shows the problem) from your own app, then create a similar xlsx manually from scratch in Excel, you can do the unzip & format on both of them then do a diff -r to find the differences between them.
An alternative approach is to load the file that's showing as 'read only' into desktop microsoft excel, make a trivial edit and save it - if that file then loads into the mobile app correctly, you can diff that file against yours.
There will probably be a reasonable number of differences, so you'll need to apply some brain power to figure out which ones are most likely to cause Excel to make it readonly. Aside from anything obvious like an attribute named 'readonly', I'd look for things like the problem file using older XML namespaces.
If you find a different you can quickly find if it's the issue by hand editing, rezipping the xml (make sure your editor doesn't leave any backup files behind, as Excel tends to object to unexpected files in the zip), then load it into Excel and see if it's still readonly.
Here's a script I use to compare the xml for two ooxml documents:
#!/bin/bash
set -e
first=$1
second=$2
# convert to absolute paths
first=$(cd $(dirname $first); pwd)/$(basename $first)
second=$(cd $(dirname $second); pwd)/$(basename $second)
WORKDIR=~/tmp.$$
mkdir -p $WORKDIR
cd $WORKDIR
mkdir 1
cd 1
unzip $first
cd ..
mkdir 2
cd 2
unzip $second
cd ..
for i in `find . -name '*.xml' -o -name '*.vml' -o -name '*.rels'`; do
xmllint --format $i > $i.new
mv -f $i.new $i
done
diff -U 5 -r 1 2 | cat -v
#or kaleidoscope for better diff display:
#ksdiff 1 2
echo $WORKDIR
rm -rf $WORKDIR
Tried own code. Same thing. But it works perfectly in other apps. Seems more like Microsoft Excell app issue. Give feedback to Excell team, provide your file, and ask to fix bug, if it’s not, anyway they will give you more information than here on SO

docker cp not working

I'm following this tutorial and when I get to the part where I call:
cp /tf_files/stripped_retrained_graph.pb bazel-bin/tensorflow/examples/android/assets/stripped_output_graph.pb
and
cp /tf_files/retrained_labels.txt bin/tensorflow/examples/android/assets/imagenet_comp_graph_label_strings.txt
They both say "No such file or directory".
As you can see in this image I can cd to the tf_files folder and see that the files are there.
I can also cd to /tensorflow/tensorflow/examples/android/assets and call ls which shows there's just a BUILD file there.
In the cp command is there supposed to already be a stripped_output_graph.pb file in the destination which gets replaced? Or is it meant to just be creating a new file there?
Is there some way of doing cp [source] [current directory] rather than specifying the destination as a path?
I've tried removing the file path part in hope that it just uses the source filename but that doesn't work.
Calling
cp /tf_files/stripped_retrained_graph.pb /tensorflow/tensorflow/examples/android/assets/stripped_output_graph.pb
and
cp /tf_files/retrained_labels.txt /tensorflow/tensorflow/examples/android/assets/imagenet_comp_graph_label_strings.txt
finally worked, wasn’t at all obvious that I’d have to change the destination path or what it should be though.
Also I accidentally saved a file as .p rather than .pb but managed to remove it using $ docker exec <container> rm -rf /tensorflow/tensorflow/examples/android/asset
s/stripped_output_graph.p
Now I managed to copy the files in correctly, but then when I installed the app it was still just running the regular demo app.
Not sure why it didn’t work, so frustrating.
When I rebuilt it after copying the files in I got these conflict messages
Are these normal to have?
It looks like maybe a different labels file is taking priority over mine, how can I reach the external/inception5h/imagenet_comp_graph_label_strings.txt file to delete it so my file is used instead?
Does the “external” part mean that I can’t actually access it?

Parse Crash Reporting - Script Does not End

I just enabled ParseCrashReporting in my app, and now when I build the app, Xcode stays on "Running 2 of 2 custom shell scripts" (i have another simple script for HockeyApp integration, placing it before that does not change anything).
My script is below:
export PATH=/usr/local/bin:$PATH
cd ~/OneDrive/AppName
parse symbols AppName -p "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
My AppName folder is also where I started my parse cloud repo, it contains the folders cloud, config and public. I tried changing the path to AppName/cloud but no change.
Xcode stays running that script for a long time...i've waited 10 minutes for it before and it doesn't continue beyond that. Once I stop the build, I get an error: Shell script invocation error:
Uploading iOS symbol files...
Command /bin/sh failed with exit code 1
I assume the error just shows because I cancel the task. Why would this be sticking like so? I have looked at several questions on parse crash reporting and have not seen any similar issues.
Just use the following script instead, I just tested it and it works:
echo "Parse Crash Reporting"
export PATH=/usr/local/bin:$PATH
CLOUD_CODE_DIR=${PROJECT_DIR}/helloKittyAdventureTimeCloudCodeFolder
if [ -d ${CLOUD_CODE_DIR} ]; then
cd ${CLOUD_CODE_DIR}
parse symbols YOUR_PARSE_APP_NAME --path="${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
echo "Finished uploading symbol"
else
echo "Unable to upload symbols"
fi
IMPORTANT:
The following line needs to be changed based on your folder name, that's it, keep everything else the same:
CLOUD_CODE_DIR=${PROJECT_DIR}/helloKittyAdventureTimeCloudCodeFolder <===this should be the
name or your own folder!!, so, if your folder is named theAdventuresOfCaptainCookCloudCode,
then you would type this:
CLOUD_CODE_DIR=${PROJECT_DIR}/theAdventuresOfCaptainCookCloudCode
Also, one more thing to note, you don't need the echos and such if your run this as a Run Script in Xcode, but you don't have to take them out either, you can just run it like this and you won't have a build error.
One more thing, make sure to change YOUR_PARSE_APP_NAME to the name or your app, sorry about that, this also needs to be changed

Script to generate Xcode empty project

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"

"Error: No resource found that matches the given name..." aapt on cmd line

I have the problem that when I try to create the .apk file with the cmd line and the aapt order, It gives me the following error:
"...\res\layout-land\activity_statistics.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/bg_session')."
This error goes further thrue all layout and drawable folders.
My cmd order is the following one:
"...\Android\sdk\platform-tools\aapt.exe"
package -v -f
-A "...\workspace\WBRLight\assets"
-M "...\workspace\WBRLight\AndroidManifest.xml"
-S "...\workspace\WBRLight\res"
-I "...\Android\sdk\platforms\android-17\android.jar"
-F "...\workspace\WBRLight\bin\WBRLight.unsigned.apk" "...\workspace\WBRLight\bin"
I checked my files if they are corrupted and clean my project folder already.
With eclipse its working, but I want to to it with the cmd line order.
Could anybody help me please ? I try to solve it now since three days...
So i figured it out:
I have to "crunch" all picture in the res folder first:
aapt crunch -v -S \res -C \bin\res
And then I pointed as a source folder to the res dir and to the bin\res dir. Also added --no-chrunch --generate-dependencies
aapt package --no-crunch --generate-dependencies -v -f
-M \AndroidManifest.xml"
-S \bin\res
-S \res
-A \assets
-I \android.jar
-F \bin\APPNAME.unsigned.apk \bin
Now Its working perfectly. Also with the .9.png 9patch pictures.
I found that while using multiple native extensions, there could be a filename conflict. Etc. two different extensions use the same file (and same path)
res/values/strings.xml
inside the ANE and during APK packaging when these resources are merged in temp folder, this file will be overwritten leading to similar error message.
Solution I've found so far is to enter the ANE archive and rename the conflicting file. You can also contact author of the extension to update it or rebuild it by yourself if possible.

Resources