Sometimes Xcode appears to ignore target build settings? - iphone

I've created a iPhone static library project with two targets like this
Project
--> Library (Device) target
--> Library (simulator) target
The device target has the SDK set to the device so it produces an armv6/7 library and the simulator target is set to the simulator SDK so it produces an i386 library.
The issue I'm having is that the SDK settings on the targets keep getting overridden by the XCode active target setting. i.e. if I build the device target, but the XCode window is showing the active SDK as being the simlulator, XCode will build a simulator library instead of a device library, ignoring the settings of the target. Although it will put it into the *-iphoneos/ directory in the build directories!
I originally had the same issue with another static library project, and after a lot of playing around got everything to work correctly. i.e. The targets ignore the XCode active SDK because they have their own specifications of what to build.
The problem is that I don't know what made it work in that project and I have not been able to reproduce the issue in it either.
Does anyone have any ideas as to what is going on?
ciao
Derek

OK, I think I've figured it out.
Set the project SDK to the general setting, ie. Simulator SDK so that you get the APIs and libraries correct during coding.
Set each target to the SKD it needs to build. ie. device SDK or simulator SDK.
Leave XCodes SDK set to current SDK, effectively telling it to not override the targets.

Related

XCode 4.5 (4G182) + iPhone 5 iOS6 - Choose a destination with a supported architecture in order to run on this device

So I have a brand new app I created last night for iOS6, using XCode 4.5. I can properly develop on my iPhone 4 with iOS6.
Today I got my new iPhone 5 with iOS6 and, after updating the certificates with the new device UUID, I tried to run my app on it and got this error:
XCode cannot run using the selected device. Choose a destination with
a supported architecture in order to run on this device.
I've enabled the device for development. Both armv7 and armv7s are on the settings.
I have included the sources from the Facebook 3.0 SDK and the linker flag '-lsqlite3.0'. I'm guessing the issue has to be related, but cannot figure what is wrong.
Any ideas how to solve it?
PS: The issue happens too when running the app on the simulator. No idea what changed on my project or XCode between last night and today, other than I have a new device and new certificates.
The selected destination does not support the architecture for which the selected software is built. Switch to a destination that supports that architecture in order to run the selected software.
Also you need to select the compiler LLVM in
Project --> Build Settings --> Build Options
I have found the same issue while running an OLD project on XCode 5.0 and My solution is:
You need to do following steps for getting out with this:
1. Set Valid Architectures : armv7,armv7s
2. Set compiler as LLVM in Project ---> Build Settings ---> Build Options.
3. Set Base and Deployment sdk properly.
This is my solution. Happy To Help.
You need to add armv7s to your valid architectures under your Target's Build Settings.
You included src/Framework/Resources/Info.plist when added Facebook SDK files to your project. Just remove it from your project and everything will work again. Guaranteed! :)
I have solve the problem using the below steps.
Close the Xcode
Delete the application from device
Restart the device
then re-run the application
it is working fine..
Make sure the bundle name (in plist file) is same as the project name. I changed it and it worked.
One of my 3rd party libraries couldn't run on armv7s so I removed that option. I also removed armv6 and kept armv7 as the only option. It built and ran on the phone with only armv7.
I have solve the problem using the below steps.
Close the Xcode
Delete the application from device
Restart the device
then re-run the application
it working fine..
I faced this problem because Build settings-> Complier for C/C++/Objective c was set wrong.
So I changed it to default compiler available, it worked!
Just need to select the compiler LLVM in
Targets --> Build Settings --> Build Options
I ran into the same problem. When I check the compiler it is showing incompatible compiler. you need to make it valid one. To set valid compiler follow the steps
select your
project----> build settings-->
on the search bar type compiler and search
now you can find build options under build options you will find compiler for c/c++/objective c set it to valid one.
So basically I created a new project, copied all the sources and everything seems to work fine. At least the app runs.
I am not sure which setting was causing the problem.
I had an issue with an out of data library that was built for iOS 4.x and I was building a new app for iOS 6 with iPhone 5 support. I received this error and the only way I resolved it was to make armv7 the only architecture and valid architecture listed in my project and target build settings.
remove info.plist refrence. And then re-drag info.plist to proj but don't copy to "target"
You just goto Build setting Then valid architecture Replace armv7 armv7s instead of armv7 .Then it will work fine .
Ok, not sure if this is the Problem in Your Project. But what fixed it for me, was to change the Name of the Info.plist File.
I changed the name from Info.plist to my-project-info.plist
also change it under target-build-settings/Packaging/Info.plist
Than delete the App from Devices/Simulators and re-run the App through Xcode
In my Case, everything worked fine since than. In my Case there was nothing wrong with the specifications made in the plist file or with the valid architectures.
some times this happens when your project was build in xcode 4.5 and you are trying to run in xcode 5.0.
so in my case I found the solution.
Change your compiler for C/C++/ObjectiveC Go to Build
Settings->Build OPtions->compiler for C/C++/ObjectiveC; select
Default(Apple LLVM5.0)

Building XMLRPC.framework: Wrong Architecture?

it's me again with my iOS trouble. I've finally managed to build the master branch of this XML-RPC framework https://github.com/eczarny/xmlrpc which produced an XMLRPC.framework for me. I managed to include that framework in my iOS project, all good, but when I build it...
ld: warning: ignoring file /Users/kovshenin/Library/Developer/Xcode/DerivedData/XMLRPC-emidbddzjlofthfgowywcfscewgd/Build/Products/Development/XMLRPC.framework/XMLRPC,
file was built for unsupported file format which is not the architecture being linked (i386)
So I went back to the XMLRPC project and tried to select different Base SDKs and Architectures for the target, but with no luck, seems like it's only building it for 64-bit Intel. Even tried the iOS SDK which gives me a "The selected run destination is not valid for this action." error.
Sorry again for my "newbish" talk, but the official dev forums can't seem to help me out. Thanks!
P.S. I'm using Xcode 4.
Architecture is related to the processor on which you are running your code. If you are building for the simulator, then you are building for your Mac, which is Intel, i386. If you are building for a physical iOS device, then you are building for arm6 or arm7, depending on how new the devices are. Fourth generation iPhone 4 and iPad were the first arm7 devices.
As far as setting the build settings, I'd recommend taking a look at the build settings. In Xcode. Here's a screenshot:
Click on your project, then on your build. Under the architectures section, you can configure your architectures as necessary. You should note though, that the original developer would have to have built it for the simulator as well as the device, or you won't be able to run it on the simulator.
It looks as though the library may not fat meaning it'll only build for the device, and not for the simulator. Connect your device and select it in the drop down, then build again and see if the error disappears.

XCode 4 - Device does not show up in the schema "destination" dropdown

I can't for the life of me find out how to run applicaitons on a device (specifically, and iPhone 4) using XCode 4.
The documentation says to "Set the run destination to iOS device in the scheme editor and build and run your application."
The dropdown menu in the schema editor only has simulator options.
Could someone present a step-by-step method for running applications on devices using Xcode 4?
Using:
Xcode 4.0.2 (iOS 4.3)
iPhone 4.3.3
UPDATE
I ended up doing a series of restarts (Macbook Pro, iPhone 4, Xcode), did a few cleans and builds of the project, and set the "Base SDK" build attribute for the TARGET to "Latest iOS (iOS 4.3).
After that, the device appeared in the destination drop-down in the scheme editing menu.
(Thank you for your time septi!)
Be sure to Verify the BASE SDK used in your project. From the docs:
"
Note: If you are building to your development device, the Base SDK version number defined on your Xcode project must be greater than or equal to the software version number on your development device; otherwise Xcode cannot initiate a debugging session with the device. In that case, you will need to download and install the latest iOS SDK version that is greater than or equal to your device software version.
"
I had a similar problem. My phone has iOS 4.2.1
I downloaded a sample app and my phone did not show up as an option, only the simulators were listed.
So this is just a configuration issue:
To fix this you need to select the project, and:
(as noted above) Select Build Settings/Base SDK = (in my case) Latest iOS (iOS 4.3)
Select Summary: Devices: iPhone
Select Deployment Target: (in my case) 4.2
Now I get the following in the dropdown list of targets:
Myiphone (4.2.1, overriding Base SDK to 4.3)
Also watch out for the UIRequiredDeviceCapabilities property in the plist file. This can prevent a device from showing up sometimes.
I encountered this today in XCode 5 and tried the steps specified. Eventually, I found another solution that may be of use to future readers (Xcode 4 or otherwise).
Go to your project settings and select your target.
Select the "General" tab and scroll to Deployment Info.
Under "Deployment Target", make sure that your device's OS, or something lower, is specified.
---> Your device should now show up as available for debugging in the listing.
Came across this by checking the same device in another project. In that project, the device was listed just fine. When looking at the project settings between the two, the above difference was what stuck out and resolved the issue.
The "Deployment Target" in the project general settings needs to be <= your device, as Danny said above.
Be aware that when you create a new project in a new version of XCode, the default deployment target will be the latest OS release. If your iPhone is on a lower release, this means you either need to upgrade your iPhone, or install an older SDK into your XCode.
You can install an older SDK by copying it into the XCode package at location:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs

iPhone + OSX targets on the same project

I created a project with two targets, one for iPhone and another for Mac OsX. They both build and run well when I build them the first time (I built the OsX target first then iPhone target next).
However, if I build the iPhone target and switch back to OsX target, the OsX target now thinks that it uses the iPhone SDK rather than it's own mac OsX SDK, and doesn't compile anymore (can't find the OSX SDK header files).
My build settings of the project and targets are setup correctly and the ".pbxproj" file is not changed in the process of switching targets. But I tracked down the problem to the ".pbxuser" file, specifically in the parameter "activeSDKPreference =".
Basically when I switch to iPhone target this parameter gets changed from macosx10.6 to iphonesimulator4.0, but when I switch back to OsX target it stays on iphonesimulator4.0. The only way to get it to work again is to close the project, manually change that param to macosx10.6, and reopen the project. This would solve it until I switch to iPhone again.
Is it a bug in XCode? anyone has a solution or a work around?
The same question is asked and answered at http://lists.apple.com/archives/xcode-users/2010/Oct/msg00132.html
It says there: "you can Opt-Click your "Overview" combo box ([in the] Xcode Project [window], in the toolbar). You should see a more complete list of Active SDKs; pick an explicit OSX SDK".
it is a bug in xCode, so you use the latest version of xCode
when you build this it set all your target. you can solve this by clean all target than build it. you wil find this in xcode build manu >> clean all target. than build this. it will work.

Xcode 3.2.3 and up - static libs with targets for multiple platforms

I have a static lib project with targets for iPhone and for os x.
With Xcode 3.2.2 and earlier versions all worked just fine, but in 3.2.3 apple seems to have introduced changes in how to handle target settings.
In 3.2.2 I just could choose "base-sdk" from drop-down menu and set up a target for each, iPhone simulator, iPhone device and Mac and xcode would always automatically build for the correct platform and architecture for that target.
Now, with xcode 3.2.3 and later you can't choose this option any more.
Switching between targets for simulator or device does not have influence on the platform, you build for, anymore. You always have to choose the platform separately and then all targets are build for that platform.
This issue is already described for simulator vs device here:
Targeting multiple platforms in iPhone SDK 4
For iPhone only projects I could live with it and just only have one target and choose the platform separately from the target.
The real issue with that change is with having an iPhone and a mac target in the project:
if the mac target is chosen, you do not have the option anymore, to switch between device and simulator, but they still affect the mac target.
If the platform has been set to device prior to switching active target from iPhone to mac, than xcode does not find the CoreServices for the mac target, because it is searching in iPhone device frameworks, where this isn't existing. Xcode even builds for arm in this case, also the target settings clearly tell it to build for i386.
If switching back to iPhone target an setting the platform to simulator and then switching back again to mac target, CoreServices framework is found, but the simulator one is used, not the os x one, which leads into the issue of dozens of "error: expected declaration specifiers or '...' before 'CFXMLTreeRef'" errors in the iphone simulator core services framework, where this is not defined, although I do of course want to use the mac version of the framework for mac target.
As I already mentioned, this was all working fine before Xcode version 3.2.3. Projects only for iPhone or only for mac are still building fine.
Any ideas, how I can get projects with static libs targets for iPhone and for mac, to build with Xcode 3.2.3 and later versions?
this guy has the solution...
http://blog.vucica.net/2010/09/single-xcode-project-for-ios-and-mac-os-x.html