Three20 JSON problem: Can deploy to simulator but not device (extThree20JSON) - iphone

Everything builds and runs in the simulator fine ... but when I attempt to run on device I get:
"arm-apple-darwin10-gcc-4.2.1:
..../three20/Build/Products/Debug-iphoneos/libextThree20JSON+YAJL.a:
No such file or directory"
I check that directory and indeed the file doesn't exist. It does exist in the "Debug-iphoneosimulator" though (which I guess explains why it works in the simulator).
So what gives and what can I do to correct this?
Thanks

This is fixed by adding the library via the python script from Three20. Do this in the command line:
python src/scripts/ttmodule.py -p ~/MyApp/MyApp.xcodeproj -c Debug -c Release extThree20JSON:extThree20JSON+SBJSON
OR
python src/scripts/ttmodule.py -p ~/MyApp/MyApp.xcodeproj -c Debug -c Release extThree20JSON:extThree20JSON+YAJL
depending on which library you need.

Are you building libextThree20JSON+YAJL.a from source, or did you just copy that .a file into your project? If the latter, the problem is probably that it is built for your computer's architecture (probably i386 or x86_64) and not ARM, what the iPhone/iPad use. To work on the device you need to either add the ARM-built version to your project, or add the library's source to your project so that it will automatically be built for the correct architecture with the rest of your code.

I switched from SBJSON to YAJL and for me a Clean Build Folder helped.

Related

-sh /usr/local/sbin/wpa_supplicant no such file or directory

I have built the TI wilink utilities which then I have integrated in my rootfs. This done using petalinux 2016.4 and have created a install template app in yocto build to copy all the tools and libraries in the rootfs.
When I bring up the BOOT.bin and image.ub, I see the files and libraries but when I try to run for example wpa_supplicant it does not work
even wpa_supplicant -h wont work.
It shows me error:
-sh: /usr/local/sbin/wpa_supplicant: no such file or directory.
The file is present and also has executable permissions.
Do you have any idea why it is not able to run ?
Thanks
Typically, this means that executable file is built for the wrong architecture, i.e. there is a mismatch between the environment where are you running and environment for which you are building. This is how you can make sure they do match or not (execute on target):
# file /usr/local/sbin/wpa_supplicant
...
# uname -m
...
If you see mismatch, then it all boils down to how are you building TI wilink.

CoreServices.h file not found in portaudio build on macOS 10.11 Xcode 8.0

This is called though cocoa.h and foundation.h, then NSURLError.h. Not sure why this compiler error just came up when I added portaudio and some other needed frameworks. The error first comes from some existing code. Indeed, there is no CoreServices/CoreServices.h anywhere on the whole system. Do I need to update Xcode?
I found an Apple help answer that said "Those are not makefile directives. How are you trying to build it? Most projects like this come with "configure" scripts that you just need to run from the command line. The only thing you need from Xcode are the Command Line Tools." I don't know what this means or how to do this.
I did run the port audio/configure terminal script, but saw nothing about CoreServices.h being generated. Where does this need to come from?
Thanks.
I further note that in the CoreServices frameworks directory associated with the Xcode project, there is a terminal file called "CoreServices" that when run, generates the error "CoreServices.framework/Versions/A/CoreServices: cannot execute binary file" . What could it be missing?
It's hard to answer your question in this specific case but:
I believe that CoreServices.h can be found at /System/Library/Frameworks/CoreServices.framework/Versions/A/Headers/CoreServices.h, is it not the case on your machine? If not, you might have to re-install Xcode
To install PortAudio, you can also use brew with the command brew install portaudio and then link your project with its headers and libs (/usr/local/Cellar/portaudio/19.6.0/include and /usr/local/Cellar/portaudio/19.6.0/lib) in your Xcode project (under the tab Build Phases > Link Binary with Libraries). That might be the easiest option.

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).

Debugging with Clang

I'd like to use clang on my Xcode iPhone project. However this is the getting started guide:
http://clang.llvm.org/get_started.html
I've been working with Xcode for a year but this is far far far from being understandable to me! Can anyone explain in plain english how to install and use Clang with my existing iPhone project? I am not familiar with loading things from the console.
Thanks!
Dan
Nikita Zhuk has wrapped Clang in a GUI and made it available at http://www.karppinen.fi/analysistool/. Very useful.
Download and extract the clang distribution to some directory. Optionally add this directory to your path, or you can just prepend it's location to the command line later on.
cd to your top level project directory (probably something like cd ~/Documents/yourprojectdirectory)
Tell the clang utility to do a build of your project using your xcode project settings by typing in the following command line: pathtoclangdirectory/scan-build -o ./clang_out xcodebuild
The utilty should give you a message after it has run successfully to run the scan_view utility.
Run the command that was output at the end of the build. This will start a temporary web server on your machine and then open up Safari and show you the code analysis. You may need to prepend the path to your clang directory again, like so: pathtoclangdirectory/scan_view ...
I didn't see this question until after I had done something similar to make Clang more useful inside XCode:
Using Clang Static Analyzer from within XCode