retrieve app's author - jailbreak iOS 6 - iphone

How can I retrieve an app's author (or developer or publisher, etc) on a jailbroken iOS 6.x device? In iOS 4.x and 5.x, there was an author member in the SBApplication class. But in iOS 6.1 I now get an NSUnknownKeyException when requesting the author. A quick look at SBApplication.h from a iOS 6 class dump online didn't show anything promising (except signerIdentity, but that's something else). Is there any easy way to get this, without digging around in any Info.plist files?
Update: The Info.plist files actually don't contain this information either. The iTunesMetadata.plist file on the other hand does, but System/Cydia apps don't have this file.

I haven't yet jailbroken my iOS 6 device or run class-dump on all the iOS 6 frameworks, so I can't tell you if there's another private API to do exactly what you used to be able to do.
Your suggestion about inspecting the contents of app folders (e.g. /var/mobile/Applications/*/*.app/) and reading the iTunesMetadata.plist files sounds reasonable. Reading each app's Info.plist would also give you the CFBundleIdentifier, which would normally at least contain the publisher's domain name (e.g. com.mycompany.MyAppName).
For apps that don't come from the app store (and don't have iTunesMetadata.plist), you could try another technique (in addition to reading Info.plist):
Cydia packages are maintained with dpkg utilities. You can list all installed packages with the command dpkg -l. You can invoke this command either with
system("dpkg -l >> /tmp/output.log 2>&1");
piping the output into a temporary file, or with NSTask. NSTask is part of OS X APIs, and is not in the iOS public APIs. But, if you add the NSTask.h header to your project yourself, you can certainly use it as a private API in a non-App Store app, to run a command and capture output programmatically.
At the command line, running dpkg -l would give you:
ii libhide 2.1 Library to hide icons. If you are a developer wanting to use this library, code samples included in /usr/lib
ii libxml2-lib 2.6.32-3 represents the library for libxml2
ii lsof 33-4 shows what files programs have open
ii lzma 4.32.7-4 slower, but better, compression algorithm
ii make 3.81-2 dependency-based build environments
ii mobilesubstrate 0.9.3999.1 powerful code insertion platform
ri ncurses 5.7-12 feature-complete terminal library
ii network-cmds 307.0.1-6 arp, ifconfig, netstat, route, traceroute
so, your app could parse that output, to read package names from the second column.
Then, you could use the apt-cache show command to get the information from the package's DEBIAN/control file, which would have something like this:
iPhone-3G:~ root# apt-cache show sqlite3
Package: sqlite3
Version: 3.5.9-12
Architecture: iphoneos-arm
Maintainer: Jay Freeman (saurik) <saurik at saurik dot com>
Installed-Size: 348
Pre-Depends: dpkg (>= 1.14.25-8)
Depends: sqlite3-lib
Replaces: sqlite3 (<= 3.5.9-11)
Filename: debs/sqlite3_3.5.9-12_iphoneos-arm.deb
Size: 71928
MD5sum: 6d47c112692ac00af61bd84e3847aa42
Section: Data_Storage
Priority: standard
Description: embedded database used by iPhoneOS
Name: SQLite 3.x
Tag: purpose::library, role::developer
I know this is more work than just using author from SBApplication, but maybe it's good enough? Hopefully, some one else will chime in with another answer ...

Related

Cross compiling FreeTDS to iPhone

Since this question is unanswered and I spent the majority of a semester figuring it I thought I would post how to Cross compiling FreeTDS 0.91 to iPhone ARMv6, ARMv7 architecture. This was done using Xcode 4.2 and iOS 5 SDK.
The reason this question is asked it because you are developing an app for an iOS device that requires connecting to an Mircosoft SQL Sever, which requires using the Tabular Data Stream (TDS) protocol as it is Microsoft proprietary.
I will also mention that you need some level of technical skill to even attempt this. This is a very condensed version of what took me nearly two months to figure out (I left all the things you shouldn't do).
Other documentation relating to this:
Basic How To on using FreeTDS http://www.freetds.org/userguide/samplecode.htm
Microsoft's TDS API documentation
http://msdn.microsoft.com/en-us/library/aa936985(v=sql.80)
See my answer below.
Also see saskathex answer for Xcode 4.5 updated files.
For those like me that will spend hours finding the documentation for these standard configure flags (for running ./configure make make install)
./configure --build is used for specifing the architecture you want to complie for
./configure --host is used to specify the ark of the machine doing the compileing (running xcode)
./configure --target seems to be an alias
Now then to solving the problem.
1) Get the latest version of the FreeTDS http://www.freetds.org/
2) The next step is to make your own bash shell files that correctly run the FreeTDS ./configure. You will need two as the simulator is i386/i686 architecture and an apple device (iPhone, iPod, etc.) is ARM architecture. Also, your compiler files/version within the iPhone development directories may be different, just find what makes logical sense and has similar naming convention. The mac host architecture is supplied with the command uname -p.
Here is my example for building for use on the simulator (i386) build_for_simulator_i386.sh:
#!/bin/sh
#unset some shell variables
unset CC
unset CFLAGS
unset CPP
export buildPath=`pwd`
# make i386 (Simulator) target
export CC=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/i686-apple-darwin11-llvm-gcc-4.2
export CFLAGS="-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk"
# if you want Windows Authentication (NTLM) support you must use at least tds version 7
# the default is 5
./configure --build=i386 --host=i386 --target=i386 --with-tdsver=7.1
Example for configuring for ARM compilation (build_for_device_armv7.sh):
#!/bin/sh
# unset some shell variables
unset CC
unset CFLAGS
unset CPP
export buildPath=`pwd`
# make arm target
export CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2
export CFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk"
export CPP=/usr/bin/cpp
./configure --build=arm-apple-darwin10 --host=x86_64-apple-darwin11.3.0 --target=armv7 --with-tdsver=7.1
3) Next cd to the root freetds directory that resulted from unzipping the freetds download, mine was freetds_0.91
4) Run one of your scripts. You can only compile for ONE architecture at a time
sh build_for_(desiered build)
this runs ./configure for you with the correct options
(tds version 7 required for NTLM authentication)
5) Once the configure process completes you have to hack the configuration file. Open freetds_0.91/include/config.h then on line 172 change #define HAVE_ICONV 1 to #define HAVE_ICONV 0
6) If you previously ran ./configure, make, make install then run these commands. Especially if your switching architectures as you will get errors running make without doing this
sudo make clean
sudo make uninstall
7) Perform the compilation using make
make all
sudo make install
The make procedure does through some error on purpose, but if you see errors within six or seven lines of shell prompt, once it returns, you have problems and need to fix them before proceeding. Lets just say lots of things can go wrong at this point.
8) After installing the binary complied file that is the culmination of all the little .o files that freetds makes is /usr/local/lib/libsybdb.a Trust me you don't want to pull a .o file for just the library you want. Copy /usr/local/lib/libsybdb.a to the appropriate folder in your project. What I did was have two separate folders, one per architecture, named "compiled_freetds-0.91_simulator_i386" and "compiled_freetds-0.91_device_armv7."
9) Since you want to make you life easy and have xcode figure out which compiled file to use follow this subset of steps to perform the dynamic linking.
a) Select you project settings on the left had side of xcode
(the blue think with the name of your project on it)
b) Select the Target (usual the same name as your app)
c) Navigate to **build settings**, scroll down to **linking > other linker flags**
d) On the left side of Other Linker Flags a mouse over will reveal an expander,
expanding will reveal Debug and Release rows.
e) Add the appriate architectures by selecting the plus on the right side of
either Debug or Release. When the new row appears select the architecture,
double click the first editable field from the right to open an entry box
that you can then drag the appropriate complied file into it to be dynamically
linked. You must do this for both files and when done correctly the file
under ARMv7 will be used when building for the device and the one for Any iOS
Simulator SDK will be used when running on the simulator.
**Note:** You may also need to add the -all_load flag to resolve linking issues.
10) The final step which seems to avoid problem of dynamic linking error involving libsybdb.5.dylib when running code on device is to make uninstall. Also, when running on the device you will also get lots of warnings, in increments of 36, about CPU_SUBTYPE_ARM_ALL being deprecated, that is normal, but annoying.
sudo make uninstall
I hope this helps.
I used the above bash files but since XCode 4.5 the Developer Tools are inside the app bundle. So I modified the scripts to run with my MacOS Lion and the current XCode Version "4.5.2 (4G2008a)"
build_for_simulator_i386.sh:
#!/bin/sh
# unset some shell variables
unset CC
unset CFLAGS
unset CPP
# make i386 (Simulator) target
export CC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/i686-apple-darwin11-llvm-gcc-4.2
export CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk"
export CPP=/usr/bin/cpp
./configure -build=i686-apple-darwin11 --host=i686-apple-darwin11 --target=i686-apple-darwin11 --with-tdsver=7.1
build_for_device_armv7.sh:
#!/bin/sh
# unset some shell variables
unset CC
unset CFLAGS
unset CPP
# make arm target
export CC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2
export CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk"
export CPP=/usr/bin/cpp
./configure --build=arm-apple-darwin10 --host=x86_64-apple-darwin11 --target=armv7 --with-tdsver=7.1
A nice add-on is to use lipinfo to merge two static libraries into one by
lipo compiled_freetds-0.91_device_armv7/libsybdb.a compiled_freetds-0.91_simulator_i386/libsybdb.a -create -output universal_libsybdb.a
and just adding this to the project's settings.
Wanted to share it, since the above scripts saved me a lot of time.

Deploying iOS apps to /Applications from XCode via build phase script? (Jailbroken)

I'm developing a Cydia app. It's been in development for awhile, and I've never had any problems until recently, when I resumed development after a few months. There are a couple of things that have changed since the last time I worked on it:
Upgraded to Lion
Moved to Xcode 4
Updated to 4.3.5 on my iPad, iPhone to 5.0
From the research I've done, I've come to the conclusion that there was something "unusual" about my old setup. I've discovered that provisioned apps get put in the "sandboxed directory" /private/var/mobile/Applications, and system apps that get read access to the entire filesystem go in /Applications. I guess from using updated tools and Lion, I broke whatever was giving me system-wide read privileges. So, I need information on how to get Xcode to deploy directly to the non-sandboxed system directory.
There are some caveats though. I don't want to have to use an installer, I want Xcode to do it automatically after Build and Run. I also want to be able to have the debugger attached so I can view the console.
Can anyone with experience in this teach me how to use Build Phase Scripts to do necessary magic to take the signed binary and deploy it automatically after each build? I'd imagine this is indeed possible, because console output is such a valuable tool, that it would be too difficult to develop apps like Cydia itself.
Thank you for your help!
The general consensus among the community is that this isn't desirable. A build system like Theos coupled with on device GDB and either a syslog package or deviceconsole is what many are using.
I added a script as custom build phase. The script signs the app, create a package, copy it to the phone and install it.
The Build Phase is "Run a Script" with /bin/sh and I added "${PROJECT_DIR}/MyApp/install.sh"
The scripts (very basic - no error handling) is below (replace with appropriate values) :
(LatestBuild is a link to the build directory)
(ldid is installed with iosopendev project)
cd $HOME/Projects/iPhone/MyProject/MyApp
cp -r ../LatestBuild/MyApp.app com.test.MyApp/Applications/
ldid -S com.test.MyApp/Applications/MyApp.app/MyApp
rm com.test.MyApp.deb 2>&1
/opt/local/bin/dpkg-deb -b com.test.MyApp
scp com.test.MyApp.deb root#192.168.0.10:/var/root
ssh root#192.168.0.10 "dpkg -r com.test.MyApp"
ssh root#192.168.0.10 "dpkg -i com.test.MyApp.deb"
ssh root#192.168.0.10 "killall -9 MyApp"
#ssh root#192.168.0.10 "killall -HUP SpringBoard"
cd -
It can be improved a lot - but it just works for my needs
I'm not particuralry well knowledgable about xcode but like most IDE's im assuming in one shape or another that you can have it run a post build script if you can figure out what that is its as simple as an scp command to upload from there you can use ldid -S nameofapp in the dir that the app is uploaded to.
You can if you want allow your app to reside in /Applications though upgrading to 4.3.5 most likely forces you on a tethered Jailbreak I'm not aware of an untethered JB for 4.3.5 so thats a hassle if you wind up having to reboot.
As far as debuggers give gdb(you can get it from cydia) a go its really useful :). What Id do is just have xcode run a post build script to use scp to upload to your device then sign it manually with ldid thats the easiest way i can think of unless you have access to a developer idevice.
Give me a few minutes Ill write a script and try to describe how it works I need one anyone since i finally got a mostly working open toolchain. :)
A simple upload script
#!/bin/bash
scp -r $1 $2#$3:$4
$1 is lets say your app folder ill use my dpatcher as an example
$2 is user name either mobile or root(if you upload as root you need to chmod permissions to 755)
$3 is your idevices local ip(ie your routers ip for it)
you can find your ip with sbsettings or by going to settings tap the blue arrow next to your ap and it will tell you.
$4 is where you want it to be most likely /Applications or /var/mobile/Applications
i named it upload.sh but you can name it anything
An example
upload.sh dpatcher.app mobile#192.168.1.65 /Applications
Then all you do is ssh in and sign it with ldid -S nameofapp
If you want to upload single files remove -r as thats for recursive uploads(ie folders)
the reason that you must use scp or sftp for uploading files is that normal ftp AFAIK is not supported with out the use of 3rd party apps.
I'm not sure how to integrate with Xcode I do every thing with either vi, emacs or nano(and I don't own a mac).

QR Code generation in shell / mac terminal

I want to create QR codes for a project I'm working on in applescript the resulting qr will be placed in the indesign document. I have found that there is a plugin for indesign but I suspect that requires user interaction.
So I've been search for how to generate the qr using a shell command. I've found things related to php and rails and even coldfusion but none of those will fit the bill on this. I need to generate them using shell command so image events or perl basically anything I can run from the command line that comes with the mac os
thanks for your help.
antotheer
I wonder if I could call a url using curl or somthing to get one ?
For doing something similar, we use libqrencode.
It's a c library for generating QR codes, but it comes with a command line utility (called qrencode) which lets you generate QR codes from a string, e.g.:
./qrencode -o /tmp/foo.png "This is the input string"
It supports most options you'd probably want (e.g. error correction level, image size, etc.).
We've used it in production for a year or two, with no problems.
I've only run it on linux systems, but there's no reason you shouldn't be able to compile it on Mac OS, assuming you have a compiler and build tools installed (and any libraries it depends on of course).
As Riccardo Cossu mentioned please use homebrew:
brew install qrencode
qrencode -o so.png "http://stackoverflow.com"

How to install a .deb file on a jailbroken iphone programmatically?

I'm developing an app with Xcode for the iPhone (jailbroken). Now I want to install a .deb file programmatically. How can I do this? I could execute a command to install it, but how? Is it enough if I install my app via Xcode on my jailbroken iPhone? (.ipa) or do I need to create a .deb? If yes, how?
Thank you very much!
Have a nice day.
edit: I made a app. In this app I have a file browser (only for documents directory). In this directory there are .deb files. Now, I want to install these .deb files programmatically if the user taps on one. How do I go about this?
AFAIK dpkg -i *.deb is the command to install a .deb. But you cannot install a .deb in a .deb because the package manager is locked thus you need a script or something.
If you want your app to function as a package installer, then yes, I would use
dpkg -i filename.deb
You could execute this command programmatically with a system() call, or an exec() call, with "dpkg -i filename.deb" as the command. You might want to fully qualify the path to dpkg (e.g. /usr/bin/dpkg ... or whatever it is ... I'm not on my phone now) if you use system() especially.
It might be that you find that you need to have root privileges to do this. See this on how to give your app root privileges.
Another option, that doesn't require your app running as root or using exec() or system() calls, is to use the technique I describe in this answer, which was about how to reboot an iPhone programmatically. Just as I used a script to call the reboot command, you could write a script to execute dpkg -i filename.deb. You'd just need to come up with a mechanism to pass the filename to your script, which I assume would change dynamically (unless your program used a temporary link that always pointed to the current .deb file to be installed.)
Many options.
You can learn the source code of Cydia.( Official site provide source code)
Learn source code from Icy Github. https://github.com/ripdev/Icy
The simple way, just use system function to invoke dpkg command.
NSString *appsyncDebPath=#"/var/root/appsync.deb";
NSString *cmdString=[NSString stringWithFormat:#"/usr/bin/dpkg -i %# >/tmp/dpkg.log;",appsyncDebPath];
const char *cmdChar=[cmdString UTF8String];
system(cmdChar);
You may show result from /tmp/dpkg.log
AFAIK jailbreaking an iPhone let you install ipa without certificates... so it's enough...

TiMidity: need help compiling this library for the iPhone

I'm using a powerful library called TiMidity, which I'm sure many iPhone developers have used already used. This is a platform-independent set of programs, but during compile-time in XCode (gcc compiler), there are hundreds of dependency errors that come up.
If anyone here has used TiMidity before for their apps, your advice will be gold.
Thanks everyone,
Phil.
I usually use this script to compile static libraries for the iPhone, but TiMidity++ isn't a library and the API's it uses to output sound on OS X aren't available on the iPhone OS.
Here's what I've gotten so far:
Save build_for_iphoneos somewhere in your path and +x it
cd to the extractd TiMidity++ folder
build_for_iphoneos simulator
This will fail
Copy timidity/newton_tables.c somewhere safe.
make clean
build_for_iphoneos device
Manually edit timidity/makefile and remove all references to DAU_DARWIN and darwin_a
Copy newton_tables.c back into the timidity subfolder and touch it
make
You should now have a timidity binary that can be used from the shell on a jailbroken device (after signed via ldid of course) and object files you can include in your project.
Note: TiMidity++ is GPL, so you will have to release your application under that license if you use any part of it. Also, this is really messy because TiMidity++ wasn't designed to be used this way, all of the darwin integration is broken on iPhone OS, and automake confuses me.
You have to remove AU_DARWIN from ./Makefile as well as timidity/Makefile.