Cocoa (OSX) and CocoaTouch (iPhone) components in the same Xcode project file? - iphone

Is it possible to have an Xcode project file which contains both the Cocoa (MacOSX) and CocoaTouch (iPhone) versions of a component?
I thought I was getting close until I realized that you need to set "Base SDK for All Configurations" in the Project Settings in order for the cross-compiler to be called (and for any CocoaTouch frameworks to be found and properly handled by Xcode).
Since that is a project-wide setting, I don't know how I can have both MacOSX and iPhoneOS targets in the same project file.
Specifying:
SDKROOT = iphoneos3.0
in an xcconfig file (used by iPhone-only targets) did not seem to work.

Yes, you can, but there are some glitches.
Okay first off, you can override any Base SDK in several ways. One is that you can on the gear at the bottom of the inspector and "Add Build Setting Condition" which lets you conditionalize any build settings based on things like the target architecture, etc.
Second, even if you have a project wide setting, it can been overriden per target. So if you have seperate targets you can just add an SDKROOT to the to the various targets with their SDKROOT.
Third, the SDK selected in the popup in your Xcode window overrides evertyhing else. So if you have something besides "Base SDK" in that popup it will get used. Also, if you do switch that (lets say from "Base SDK" to "iPhone Simulator") and then you switch targets to a target that does not support the currently selected SDK it will appear to deselect, but it doesn't actually correctly autorevert the Base SDK, you need to reselect it in the pop up.
I still can't consistently get multiple archs building together properly as part of an aggregate (for instance, having an OS X target that preprocesses some resource built so that it can be used as a build phase in a later target building an iPhone app).

Related

Core-Plot error

I want to use a graph in my iPhone app. I have downloaded the source code Core- Plot for it, but now when I am trying to run it I am getting an error.
clang: error: -Z-reserved-lib-stdc++: 'linker' input unused when '-c' is present
Can anyone suggest me what this error mean or how to resolve it.
`iPhone, iPod Touch, and/or iPad Application
Dependent Project Install
Because frameworks cannot be used in Cocoa Touch applications in the same way as on the Mac, the means of including Core Plot within an iPhone application are slightly different.
First, drag the CorePlot-CocoaTouch.xcodeproj file into your iPhone application's Xcode project. Show the project navigator in the left-hand list and click on your project.
Select your application target from under the "Targets" source list that appears. Click on the "Build Phases" tab and expand the "Target Dependencies" group. Click on the plus button, select the CorePlot-CocoaTouch library, and click Add. This should ensure that the Core Plot library will be built with your application.
Core Plot is built as a static library for iPhone, so you'll need to drag the libCorePlot-CocoaTouch.a static library from under the CorePlot-CocoaTouch.xcodeproj group to the "Link Binaries With Libraries" group within the application target's "Build Phases" group you were just in.
You'll also need to point to the right header location. Under your Build settings, set the Header Search Paths to the relative path from your application to the framework/ subdirectory within the Core Plot source tree. Make sure to make this header search path recursive. You need to add -ObjC to Other Linker Flags as well (as of Xcode 4.2, -all_load does not seem to be needed, but it may be required for older Xcode versions).
Core Plot is based on Core Animation, so if you haven't already, add the QuartzCore framework to your application project.
Finally, you should be able to import all of the Core Plot classes and data types by inserting the following line in the appropriate source files within your project:
import "CorePlot-CocoaTouch.h"`
Source: core plot wiki on google
I got a solution for it here is the link.
CorePlot failed to build in XCode 4.4
Basically the issue was related to Xcode.

Xcode 3.2.6: an issue with the Cocos2d Framework

I'm using XCode 3.2.6. I'd like to make my game work for earlier version 3.1.3 but when I build the Project in Xcode, I'm getting the following error:
File /Users/.../build/Debug-iphoneos/libcocos2d libraries.a depends on itself. This target might include its own product.
And it's the only error. What's the meaning of this error? What's the issue here?
For some reason your Cocos2d library depends on itself. Open the properties for your Cocos2d library target (right click -> "Get Info") and look at the general tab. There's a list called "DirectDependencies". Remove the cocos2d library from that list.
Another place where a direct dependency could occur is the Cocos2d library product. Open the properties for your Cocos2d library product (this time under "Products" not under "Targets"). Open the targets tab and look at the targets. If the cocos2d library is checked as target, uncheck it.

Minimum OS version incorrect

I've got my deployment target set to iOS 4.0 and yet when it's all compile the value is 3.1. WTF?
Anyone know what's going on here?
Settings like this can be set in multiple places. Check that your target setting is correct: it'll override the project setting.
Application settings can be set on the project (typically the blue icon at the top of your Xcode drawer) but also can be overridden in individual application Targets (the little red bullseye icon). Settings applied to the project are kind of like global settings. You can change the global settings in different targets though. So check that you're not setting 3.1 in a target thus overriding your Project settings which you have set to 4.0.

How do I get Xcode to treat an Info.plist as an iPhone/iPad Info.plist?

I have two cocoa-touch apps in one Xcode project. Xcode gives me iPhone/iPad related options for keys in the first's Info.plist, such as "Launch Image (iPad)". But, Xcode gives me Mac OS X options for keys for the second, such as "Java classpaths" and "Quick Look preview height."
Here's how the project was built:
I created the new project as a Universal Window-based Application using Xcode, which came with a default Info.plist that translates raw plist keys like UIPrerenderedIcon to more human readable values like "Icon already includes gloss effects." All good.
In the same Xcode Project, I added a second target, also a Cocoa-Touch application, and built it from scratch, including the Info.plist file.
I've opened up the "Active Target" project settings for both apps and have exactly one "Setting Defined at This Level": Product Name. At the higher "Project Settings" level, no Product Name is defined and the Info.plist File is defined as ${EXECUTABLE_NAME}/${EXECUTABLE_NAME}-Info.plist. (Other settings, like Prefix Header, are similarly defined with variable substitution.)
Both apps build, run and use their respective Info.plist files appropriately, but Xcode still tries to give me Mac OS X Info.plist values when editing the second app's Info.plist.
How can I tell Xcode that the plist should be an iPad/iPhone Info.plist, not a Mac OS X Info.plist?
Try this: select/open the Info.plist in question, and then from the menu, do
View > Property List Type > iPhone Info.plist
for Xcode 5 there's no View -> Property List Type so the solution is to open the file, right click anywhere in it and right under Show Raw Keys/Values you'll find the Property List Type menu.
Happy coding,
Z.
I'm also curious about this. I ran into the same thing while upgrading an iPhone project for iPad, and after days of trying to figure it out, I just made a new project and reimported the custom classes. I upgraded the target and this time the keys were still for iOS.
My best guess is this is an XCode bug.

Turn off or fix Bounce Zoom warning from iPhone XIB compilation

This has been annoying me for a while in several XCode projects. I really don't like to have compiler warnings when I build. When I build my current project, I get the following warning from a bunch of XIB files:
/.../CaseInformationView.xib:3:0 UIScrollView's 'Bounce Zoom' option will be ignored on iPhone OS versions prior to 2.1.
Since I'm building for 3.0, I don't care if it will be ignored. If I want to use the Bounce Zoom option in my XIB file, how can I not see this warning?
In IB, select "Document Info" from the Window menu and set your Deployment target to 3.0.
EDIT: In more current versions of Xcode
Choose the xib
Go to the File Inspector
In the Interface Builder Document section, set Deployment and Development
Also, set Deployment Target on Project's Summary page (choose main project, then Summary tab)