I'm trying to setup a library for simulator or device building and everywhere I see explains that SDKROOT should expand to a /Developer/Platform/<>/SDKs/<>/, where <> is filled in by your project settings.
Many links on the internet explain that SDKROOT will expand to a path, but the newer versions of XCode, SDKROOT expands to "iphoneos2.2.1" - which isn't nearly as helpful (for this task).
Clearly enough if you look at apples documentation, the behavior changed:
http://developer.apple.com/mac/library/DOCUMENTATION/DeveloperTools/Reference/XcodeBuildSettingRef/9-Revision-3.1/history.html
I confirmed the change by looking at some older documentation on my mac.
Any thoughts on how to achieve similar functionality in the latest XCode builds? My end goal is to link to a static library in platform independent ways. The header files differ on each platform, so building a fat-static library doesn't solve the problem.
In Xcode 3.2.1, it looks like SDK_DIR contains the path that used to be in SDKROOT.
I can't find documentation mentioning SDK_DIR anywhere. The Behavior of SDKROOT clearly changed at some point. It used to expand to a full path and now it simply expands to a short form like "iphoneos4.3". I can't find anything documenting this behavior change though and the above link is dead.
On experimenting SDKROOT is the right thing to use. It looks like it expands to the short form "iphoneos4.3" but in reality it expands to the full path at build time. I think Xcode just shortens it for display purposes, which is confusing.
Related
I had a problem recently with some devices after I upgraded to SDK Tools r16 from SDK Tools r11.
I found out it was texture related, now looking back the APK files I created with SDK Tools r11 contain exact copies of the textures in the raw file. But the APK files created with SDK Tools r16 contain some differences at the byte level, I can't see any difference, no difference in colour depth either, but whatever has happened to them causes problems loading on PowerVR GPU devices.
JPG and BMP files are not altered.
Does anyone know what might be causing this and how I can get a raw file to stay raw?
Edit: Looking at the files inside Notepad++ I see "iCCPPhotoshop ICC profile" is removed from the header. There may be other changes.
Edit2: Looking at the properties in windows explorer the raw one says "Attributes A" and the APK one says "Attibutes N". It's definitely stripping/changing information.
Edit3: I meant SDK Tools Revision XX not API XX
I don't know why anyone thought this was a good idea but Android does some sort of compression on PNGs. See here for one guy's experience with it. I'm not sure if API 16 does something different from API 11, but this behavior has been there since way before 11. As to how to fix this behavior, I suspect that renaming your resource might help. Try naming it whatever.mp3 instead of .png and see if that fixes it.
I have downloaded openframeworks from Github. I can run all the samples but if I am trying to run opencv example given in openframeworks. Its not working, showing 44 errors and errors are not common too. I think there linking files are also missing in github. Do you have any idea why only opencv example cant get executed ?
In, for example, iPhoneFaceSamplesSomething some files are missing that you can get from other parts of the project (jpg, xml) or just ignore (png). You get a ton of warnings because they added OS X libs which XCode ignore, no big deal. And then some libs are missing for the iPhone like opencv highgui and some other. You should try to get them from somewhere else or compile them yourself. The project definition is a bit messy, you can also file a bug in github.
actually the answer to this is that the ofxOpenCv examples only work when run on the actual device. ofxOpenCv doesn't work in the simulator on iphone currently.
Check the read me file for includes. Often times OF addons have dependancies that are not included in the download.
Also another thing that will get you sometimes is when you're running the incorrect profile on your system. Like OSX 10.5 instead of OSX 10.6. Also fiddle with the release and debug options(switch back and forth), that will often help (I know it sounds hack-ish).
Anyone want to share an Xcode project that has MGTwitterEngine in it? Mine won't compile. Are there certain project settings to set? I just made a stock tab bar app for iPhone and added the MGTwitterEngine files. Tons of compiler errors. What am I missing?
I had same problem. To get it to compile I added "$SDKROOT/usr/include/libxml2" to the Header Search Paths list. I also checked Recursive checkbox.
Make sure that you're adding "$SDKROOT/usr/include/libxml2" to header search paths in your Target settings and not just the Project.
I managed to get the library path right eventually. However, in the end, I got rid of the whole MGTwitterEngine thing and went with the TwitterHelper stuff that I noticed the folks from the Stanford iPhone class using. It uses the synchronous calls and it's not as full-featured. But it's lighter and I understand it better. I just use threading to counter the synchronicity. (Hey, wasn't that a song?!) Anyway, a little JSON code and it's all under control. Most of you are probably going to think I'm a noob but it just feels cleaner and easier to handle. I know there are plenty of good reasons to use MGTwitterEngine.
Bottom line is, even though I got it to work by getting the library path right, I don't even need to worry about any paths by adding the very small TwitterHelper stuff to my project. Seems more Mac-like than to have to go into too much tinkering (I can already hear the experts saying that setting paths is not too much but I absolutely detest the Project Settings dialog.)
You also need to add
libxml to Header Search Path ( should be something like /usr/library/libxml2 )
I just wanted to add something that tripped me up. You have to make sure the Target header search path is also set because it may override the default project search path headers. If you are unable to find some header files that the path is definitely pointing to correctly in your project search path headers, then this is probably the reason.
You're probably missing the libxml library. You need to add that to your linked frameworks. Here's a question that has a little more information, but that's the gist of it.
Best approach for XML parsing on the iPhone
I am confused at this setting (Project -> Edit Active Target).
The Search Paths can differ based on the SDK setting (simulator vs device).
But if I provide both simulator and device paths, for lets say the Frameworks path, then i get linker errors. But it seems if I only provide the proper path for whichever SDK i have selected, then it builds fine!
How can I keep both path settings? Currently Im having to cut and paste the appropriate path based on the SDK i have selected to build.
Thanks!
Which kind of search path are you talking about? The system search paths are automatically handled for you, so I assume that your problem is some custom library.
There are two solutions. You can use conditional settings, or you can use universal libraries. I've grown to love universal libraries, but haven't had time to write up full instructions yet. The way they work is to build a static library for the simulator and for the device, and then use lipo to glue them together. You can then use the same library for both platforms. I really need to write up full instructions for this because it's very useful.
There are two more approaches. First you can use conditional settings. In xcconfig files (see my talk on why to use xcconfig files), you put something like this:
LD_FLAGS[sdk=iphonesimulator*] = -lsasl2
That links sasl2 just for the simulator. Set whatever you flag you need. Another solution is variable substitution:
HEADER_SEARCH_PATHS = "$(SRCROOT)/MyPackage/build/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/include"
This assumes that MyPackage is in a subdirectory of your project and it was built into the build directory. It'll look in, for example, Debug-iphoneos for its variables.
You can also do both of the above in the build pane, but I really recommend folks get away from the build pane for any serious project. Variable substitution works identically in the build pane, and conditional settings are accessible from right-clicking on a setting.
You should have two separate build target profiles set up, one for sim and one for device, rather than constantly editing the same one. That's kind of the point of targets.
If you're only using
project headers
SDK framework headers
sqlite3 headers
then your Header Search Paths should be empty. Xcode provides search paths for your project headers, SDK frameworks, and /usr/include/*.h automatically, and adjusts those for the framework in use.
The only reasons to have custom Header Search Paths is when you have references to headers that are not in the SDK, are in "deep" locations in the SDK (such as in subdirectories of /usr/include or in buried frameworks), or are in other targets or projects your project cross-references.
Rob already hinted at this, but to clarify, here's how you'd set it using the build window.
In the build settings window, select the setting you want to modify (like "Framework search paths"). Then click the gear in the lower left, and select "Add Build Setting Condition." Then you can add a value that applies only to iOS Simulator builds, and a second build setting condition to apply only to device builds.
Is there a quick-reference guide to the iPhone SDK that's as fast and easy to use as one of those little O'Reilly books, or JavaDoc?
I'm new to iPhone SDK programming. I need reference material. Let's say I want to know if the string class has a "reverse" function. For Java I go to http://java.sun.com/javase/6/docs/api/ and browse down to find "String". Then I can see everything about String, with hyperlinks to Serializable and Character. I don't see a "reverse" method, but look, there's a hyperlink to StringBuilder -- aha, there's StringBuilder.reverse(). Total elapsed time 30 seconds.
For the iPhone I go to http://developer.apple.com/iphone and log in. Everything seems to be slower here. There are fewer cross-links than in the Java documentation, and each link seems to pull in a big page that takes a long time to load. Just the page for NSString takes 30 seconds to load fully. Maybe I just don't know my way around the documentation yet, but it seems to be much harder to browse for what you want. There's no equivalent of flipping through a book, or if there is it takes 30 seconds to turn the page.
The iPhone platform is immense -- for almost anything you'd want to do, there's got to be a class somewhere that does it. The built-in help in XCode is good but I'm still lost with it.
How do YOU go about finding that class you need? Is there a better way?
I just use XCode's built-in help system. Right-click a class or symbol name, and choose "Find Selected Text in API Reference". You can also do "Jump to Definition", which will open the header file where that symbol is defined.
More info on this stuff here.
When I started with iPhone dev I used the iPhone Developers Cookbook, it has examples of how to do specific things. It's easy to pick out one piece of functionality to try out.
I'd highly recommend checking it out.
Use the XCode hot keys to jump to documentation on anything - in XCode for Leopard, you can double-click on something like "NSString" while holding down "Option" and it will take you to the documentation for that class. You can do the same thing for method names.
In Snow Leopard that key combo opens up a little help box with a summary of what you clicked on, "Cmd-Option double-click" brings up the docs as with Leopard.
The built in docs are very good and even provide links to sample code (if any exists for the subject in question).
There's also a way to generate your own XCode compatible documentation with Doxygen, just like you could with Javadoc:
http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
If the speed of browsing documentation is the issue, I recommend downloading the related doc sets and browse them locally in Xcode. In Xcode's preferences, select the last "tab" (Documentation) and click the "GET" button next to the documentation test you want. (I'm on Snow Leopard and Xcode 3.2, but it should be similar on Xcode 3.1.x as well.)
If finding what you need is the issue, I second #paulsnotes's answer — the "cookbook" approach is very helpful form a task-based exploration standpoint. Also, when you find something you were looking for, and it took much longer than usual, provide feedback on Apple's documentation. Each page has links at the bottom. You can suggest what classes, sample code, etc. would be useful to cross-link to make it easier to find what you need.
If we are recommeding books, this is excellent for a beginner, it gets you up to speed very quickly while leading you through creating highly functional apps you can use as a jumping point for your own:
Beginning Iphone Development