iPhone/iPad universal build problem with firmware version - iphone

I was doing a project as Universal binary for iPhone/iPad. I created the iPhone app side
and I was doing to complete the iPad too. I noticed one thing, on iPad classes I use the UIPopoverController class, means that when I build now for 3.2 in the Simulator, it runs te iPad one and it works fine, BUT if I want to see the iPhone version app, means 3.1.3, It give me an error of framework missing in the iPad classes.
I have no idea how to solve this problem because I cannot anymore see the iPhone version of the app and make changes. I can only remove all the iPad classes and after reimport again.
thanks guys!

With the 3.2 SDK the Simulator will only run as an iPad.
If you want to test your iPhone side, you will have to wrap the 3.2 specific code in preprocessor conditions to make it compile with 3.1.3.
If you have a device, you should be able to compile both the iPad and the iPhone version using the 3.2 SDK by setting the "Deployment Target" setting in your target's build settings.
Set it to the lowest version of iPhone OS you're willing to support, for example, 3.1.3 and compile using 3.2. You will also need to "weak link" against any new 3.2 frameworks, such as Core Text.
Finally, if you're not already, you should be using runtime checks to make sure your iPhone version doesn't try to make use of any 3.2 features, such as popovers.
This way, you won't have to remove your popover references and you should be able to compile. However, as I said, this will only be useful if you have a physical device to test with.
If you want to use the simulator, you'll have to follow the preprocessor conditions method.

You can only build with 3.2 Base SDK and iPhone OS Deployment Target 3.1.3 (or earlier). When you do this, the simulator will only run as 3.2/iPad. That's just how it is.
You will therefore need to debug on an actual device for iPhone testing.

Related

How can I support both iOS 4.X SDK and iOS 5 SDK in my iPhone app?

I am writing an iPhone app in which I want to support the largest user base possible at this point in time (with minimal pain), so I decided that targeting IOS 4.3+ would be a good subset of users for my audience.
I started working in XCode 4.2, but reverted back to XCode 4.1 when I realized that the project templates had changed and everything seemed very intertwined with storyboarding, ARC, etc.
I have built out my application to the point I actually want to test on my device, which has iOS5 installed. When I attempt to use it though, I get this message as soon as I click 'use for development' in Organizer/XCode:
The project's build settings look like this:
My Question Is This: How do I get this application, built in XCode 4.1, to run on both iOS 4.3 and iOS 5 phones?
Are iOS SDKs not backward compatible? I come from Android development in which a less than current SDK will generally work on a newer SDK - is this different in the iOS world? And if so, how is this handled typically?
Any direction on how I should proceed would be greatly appreciated.
You can go ahead and open your app in Xcode 4.2 and it should still work. I've been working on a particular app since Xcode 3.x days and I'm nearly done, chugging along in Xcode 4.2 right now. It shouldn't be a problem. If you want to work with Xcode 4.1 you will be fine, but you won't be ale to use new features introduced in iOS 5.
There are several aspects of "cross-version" development to note.
Testing: You can only test on version of iOS that are included with your SDK, or that are installed on physical devices that you may have. The SDK generally comes only with the latest iOS, sometimes the previous one is included as well, but since Xcode 4 was released, the older SDKs have been progressively deprecated with each release. This is not to say that your app which is linked against the iOS 5 SDK won't run on older versions of iOS. It just depends on how you implement new features.
Features: In order to support older versions of iOS properly, you want to make sure that you don't implement new features without properly checking for the existence of classes, methods, and properties that were introduced in the newer versions of the OS. Unlike Android, you don't have to worry about a million hardware configurations. ;-)
Weak Linking: To support a new feature and still be compatible with older versions of iOS, you need to weak link against frameworks that you are using to implement new features. You can read more about that in the Apple Documentation on Weak Linking.
Deployment Target: The setting that prevents the app from loading on older devices is called the "Deployment Target". If you set this to 3.1.3, then your app will run on iOS 3.1.3 and higher. Remember that if you don't code the the proper version checking, your app may break.
ARC: You can choose to enable or disable Automatic Reference Counting when you create the project. ARC scans your program at compile time only, not at runtime, it doesn't break the app on older versions of the OS.
You need the latest version of XCode and the iOS SDK to install your apps onto your iOS 5.0 phone. That doesn't mean the inverse is true -- you don't need the same version of iOS on your device that you have installed on your computer.
Hope this helps!
You can use the latest SDK and simply set the "IOS Deployment Target" version to 4.3 in the project build settings.
XCode 4.1 doesn't support iOS5 in the sense that Xcode package doesn't contain the iOS5 SDK. So you must return to Xcode 4.2 and target your project for iOS 4.3 (you can also target it for iOS 4.0 with this Xcode version, but you will not be able to simulate it; you can even download older iOS 4.x package versions from the Xcode preferences menu if you really need to simulate them in your device).
You can opt-out of ARC if you want, this choice is given to you when you create the project, so don't worry; but consider that ARC does its magic at compile time only, not at runtime, so your backward compatibility will be kept if you decide to use this technology. Finally if you don't want Storyboard just pick the Empty app template and it will simply put in your project only the basic files. From this template you can create any iOS app, this is the approach I normally follow.

Why does XCode say that my iPhone app is only able to run on iPad?

I have a project in XCode with two targets. One target is for the iPhone only and the other is for iPad only.
The iPad target works as expected, but the iPhone target does not.
If I try to run it in the simulator, it starts the iPad simulator every time, but in iPhone compatibility mode with the 2x button.
If I try to run in on my iPhone 4 device, I get this message:
Can’t install application. The application at /Users/jacob/Documents/code/Projects/TVGuide/build/Debug-iphoneos/TVGuidePlus.app can only be installed on iPads.
This is XCode 3.2.6 and the iOS 4.3 SDK.
I have TARGETED_DEVICE_FAMILY defined at the target level and it looks like it is set correctly. The problem is the same for debug/release/...
have you selected the simulator as iphone?
most iphone apps are supposed to work on ipad too.
otherwise you may need to go to the project tab and go to project settings. there are some setting involving the choice of ios. i have not tried this since i havent recieved the error but i hope that it works.
Actually it turned out that I had Armv7 selected as architecture for my iPhone build. After changing that to armv6, I can now install and run the build on my device.

Can I install an ad hoc build on iPad for an iPhone targeted app?

I'm creating an app targeted at iPhone/iTouch devices. They build on that just fine. Can I install an ad hoc build onto an iPad while having the 'Targeted Device Family' set to iPhone and not iPhone/iPad? I'm expecting of course because it isn't a universal app that it will run in the small window on the iPad. I don't have an iPad, client does and would just like to test on it.
Yes, as long as the target OS matches the version of the iPad it should work.
Sure; you just need to set "iOS Deployment Target" (IPHONEOS_DEPLOYMENT_TARGET) correctly (i.e. 3.2 if your client has not updated to 4.2 yet).
Note that Apple has rejected iPhone-only apps with IPHONEOS_DEPLOYMENT_TARGET=3.2 (and SDKROOT=iphoneos4.0). The only thing you could do was set iOS Deployment Target to 3.1.3 and below (and be forced to support iPhone/3.1.3), which was a bit of a pain since 3.2 has a lot of improvements on 3.1.
I'm not sure if they've fixed it. You have three options:
IPHONEOS_DEPLOYMENT_TARGET=3.1.3 (or below) and support old phones as well. (Don't support OS versions you can't test on!)
IPHONEOS_DEPLOYMENT_TARGET=3.2 and face possible rejection.
IPHONEOS_DEPLOYMENT_TARGET=4.0 (or above) and force users to upgrade.

iOS Development: How can I run my iPhone 4.2 app on the iPhone 3.2 simulator?

I'm diving into iOS development and I'm building a simple app that will support iOS version 3.2 to 4.2. I've tested it fairly well in the latest version of Xcode on the 4.2 simulator, but I would like to also simulate it running on a iOS 3.2 device. After reading a few tutorials on this, I managed to download and install an older version of xcode along with the older 3.2 SDK, but when I build my project in the older version of Xcode, I get a ton errors due surrounding all the iOS 4.2 functionality that the older version of Xcode doesn't support. I'm weak-linking all the 4.2 frameworks, but I'm still getting errors. How can I get my 4.2 app to build successfully in this older version of Xcode and get it to run in the 3.2 iPhone simulator?
Thanks so much for your wisdom!
You need to add #ifdef __IPHONE_4_2...#endif around any lines that reference features that only exist on 4.2. That way the 3.2 compiler will build your app as if those lines don't exist.
You need to be extremely careful to structure these statements in such a way that they exactly mirror the bits of code that would be disabled when running the built-for-4.2 build on 3.2, otherwise there's not a lot of point.
This will build your app without any of the 4.2 functionality included, so it isn't actually testing whether your weak-linking etc is correct, it's just testing how the fallback 3.2 code works.
It will probably throw up a few warnings about features/methods you didn't know didn't exist in 3.2. Make sure these have appropriate fallback code added.
(btw Apple has been known to reject iPhone apps with a Base SDK of 3.2. You need to support at least 3.1.3 if you go back before 4.0)
Did you select the option of setting the base SDK to 3.0 or others?Because by doing so you can run the new APIs available in iOS 4.2 on older OS also.
Cheers
On the second issue, of actually running it in a 3.2 version of the iPhone within the iOS simulator: I've struggled with this -- Xcode 4.0.2, set my deployment target to iOS 3.2, set my project to iPhone only, but when I try to run in the iOS Simulator under version 3.2, the simulator morphs into the iPad simulator, even if it had been running as an iPhone simulator until I selected the version number.
This frustrated me for a while. But I read this and it made sense:
http://en.wikipedia.org/wiki/IOS_version_history
The iPhone never ran 3.2; that was an iPad-only release. So, even though the Hardware > Version menu in the iOS Simulator lists 3.2 (7W367A), presumably that setting is only intended to be compatible with Hardware > Device > iPad. The simulator is enforcing this rule when it switches me into an iPad simulator. It makes complete sense.
So I'd need a 3.1.3 simulator, or older, to run my app as if running on a 3.x-generation iPhone. This isn't available in my Xcode 4 build, so it makes sense to me now that I'm just unable to do anything about this, short of putting older Xcode builds on my machine.
I think the right way to do is as follows:
1.If you are developing for version 4.2, then you must be having Xcode version 4.2 installed.
2.While building your application on devices 4.0 and 3.2 OS, select base SDK to 4.2, and deployment target device to the minimum version you want to support, say 3.2. This will make your code compatible to lower version and your application will be loaded on lower versions.
Also to support new APIs in lower versions you may follow the link :
http://www.marco.org/1648550153
I hope this helps you
You can run both 3.2 and 4.x simulators in the latest Xcode (not at the same time, of course!). You have to set "Base SDK" to 4.2 and "iOS Deployment Target" to 3.2. Now you can select the 3.2 Simulator (or later) from the "Overview" popup menu in the top left corner of the project window. Also you can select the simulator version in the iOS Simulator app itself, via the "Hardware->Version" menu item.

iPhone Build SDK 4.0 With 3.2 Target Won't Install on iPad OS 3.2

I'm building an app for iPhone/iTouch that I also want to run on iPads (not a universal app, but one that just runs on on iPad with the 1x/2x button in the lower right hand corner).
I'm using iPhone SDK 4.0 and setting the following:
Base SDK: 4.0
iPhone OS Deployment Target: 3.2
When I do this, I can build an app just fine and run it on an iPhone/iTouch, but when I try to install it on my iPad I get the following error: The Info.plist for application specifies a minimum OS version of 4.0
In addition, if I package up the binary and submit it to Apple and it becomes available on the iTunes store, it shows that it's only available for iPhone (not the iPad). When I go to the App Store icon on my iPad, it doesn't even list the app as available (because Apple thinks it won't run on iPad, I assume).
Now I'm really confused, because I thought I understood the difference between the Base SDK and the Deployment Target, but Xcode is telling me I don't.
Can anyone help explain this to me?
As an aside but related question, if I build with Base SDK = "iPhone Device 3.2" it works fine on my iPad, but by doing so would I lose the Base SDK 4.0 built-in multi-tasking feature?
Check the 'Targeted Device Family' setting in your target's build settings. It needs to be set to iPhone/iPad if you want to be able to deploy to both devices.
This build setting automatically sets the UIDeviceFamily entry in the app's Info.plist (You shouldn't update this yourself, though—use the build setting instead.)
UIDeviceFamily