How do I change what version of GCC Xcode uses? - xcode

Currently, I am trying to compile Imprudence, a third party viewer for the Linden-Lab owned Second Life. I have gotten everything set up and I am now in Xcode. When I click on the Build And Run button, I get an error after a little bit stating that GCC 4.2 is not compatible with the Mac OS X 10.4 SDK.
I have tried changing the Active Architecture in Xcode to x86_64, i386, and ppc. None of these options have changed anything. I am running Mac OS X 10.6.4 and Xcode version 3.2.3. Can anyone tell me why this might be happening? Thank you!

See: http://developer.apple.com/tools/xcode/xcodebuildsettings.html
Basically, you need to go to the "Build" tab on the info window, and change the compiler version.
Edit: Seems like your problem is the SDK you're linking against not the compiler version. Fortunately, you can change the SDK version from the same panel I talked about.

You can change the compiler setting in the "Build" pane in the project's info panel. You can set both the targeted version and the compiler. These settings will cascade to each target, or can be overridden on a target-by-target basis using the same pane in the target's info panel. The base SDK for the project is set in a popup on the "General" pane of the project's info panel.

Related

QT QSystemTrayIcon on mac is squashed in the second screen

I create a system tray icon on MacBook. And I connect a screen with Mac. When I run this program,the system tran icon on the monitor is squashed.
QSystemTrayIcon *m_tTrayIcon = new QSystemTrayIcon(this);
m_tTrayIcon->setIcon(QIcon(QPixmap("/Users/xxx/Downloads/pic.png")));
m_tTrayIcon->show();
when the monitor is not focused, the icon is squashed.
and when I click the desktop of the monitor, the monitor is focused, the icon is also become normal.
This is a known bug in Qt with new verisons of MacOS. Check out this bugreport.
Solution would be either use fixed versions (they claim to fix it in 5.12.11 and 6.1.0) or compile cocoa plugin by your own and ship it with your application instead of one provided by Qt.
Fix is just a one line of code that you need to apply. The easiest way is:
download qtbase (for example from github) and checkout version you need
In case you will use Qt < 6.0.0 (i.e. building with qmake rather than with CMake) - copy .qmake.conf from root to qtbase/src/plugins/platforms/
you go to qtbase/src/plugins/platforms/cocoa and open cocoa.pro or CMakeLists.txt (depends on what version of Qt you have checked out)
you apply patch and compile the plugin
From now on you should use cocoa plugin you have just compiled instead of one shipped with Qt (either replace it in Qt installation or every time you deploy your application)

How to enable Visual Memory Debugger in Xcode 8?

I migrated a project from the previous version of Xcode to Xcode 8. What I want is to use the new visual memory debugger. It's available in new projects, but is entirely missing in my imported one. Why is this?
It appears that Swift 3 is required for Visual Memory Debugger to work.
My app migrated to Swift 2.3 did not work, when I tried migrating it to Swift 3.0 it worked instantly.
The runtime sanitization checkbox is not required for visual memory debugger to work, however the reason that it is disabled is the same.
It seems like the project requires Swift 3 to enable Adress & Thread Sanitizer (which is the Memory Debugger).
For me this applies to both iOS & OS X/macOS apps. Both written in Swift 2.2 & converted to 2.3.
Note: I only tested this on OS X El Capitan 10.11.5.
#gabriellanata confirms that it works when the code is converted to Swift 3.
I just ran an Objective-C iOS 7 project made with Xcode 7 in Xcode 8 (without migrating) and the Visual Memory Debugger icon appears at the bottom of Xcode in the debugging area next to the Debug View Hierarchy button.
It's the button with the three circles.
From the other comments, it looks like Swift 3 might be required to use this feature.
Argument '-sanitize=address' is not supported on the Swift 2.3 toolchain.
You will need to migrate your project to Swift 3 to use this feature.
Xcode 8 GM build error
P.S. Objective-c supported by Visual Memory Debugger
If you click on Memory, the source editor pane will change to show some memory information, including why it's disabled. In my case, it was because I had Zombie Objects enabled in the Scheme. (Xcode 8.3.2)

How did my Xcode project get changed from iOS project to an OSX project?

I've been doing only iOS development and never made an OSX app. In the iOS project I'm working on now I see that suddenly Xcode thinks it's an OSX project. The all my framework files are shown in red (missing), and lots of the options in the project panel show choices that are only appropriate for OSX such as "deployment target", which offers only 10.4, 10.5, 10.6 etc. and in Build Settings the Valid Architecture shows i386 x86_64 with no drop-down options.
What happened? How can I change this back to an iOS project?
could be 2 late to answer this question, however, this answer might help someone in the future, as the above answer wasn't helpful for me, so here is what I have done.
1- on the left top corner of Xcode click on the scheme.
2- click edit scheme
3- in the new window change "Executable" from non to the name of your project scheme "target"
4- on the top where it says "My Mac 64-bit" if it didn't changed automatically to iPhone/iPad change it manually.
5- if there wasn't any option, in bottom of the window click "Manage Schemes" and make sure the
check box next to your project scheme is checked.
hope this could help and save anyone time.
By your comment you should not have an issue navigating this.
Go to your Project (in upper left) -> Project (project name in submenu) -> Build Settings -> under Architectures menu select Base SDK and choose iOS 6.1.
This should switch your project back. Now under Info you should see your Deployment Target options have switched from saying OS X Development Target to iOS Development Target
As for why it originally changed, I have no idea. But hopefully this will fix your issue.
I know this is an old post, but this just happened to me in a project with multiple targets.
I'm using github and it had marked one of my target scheme files with a merge block at the top of the file after using a newer compiler. I could find a way to edit the scheme through XCode, but upon re-opening the project, it would be bad again.
I had to edit the file manually and complete the merge edit.
This recently happened to me with Xcode 8 where an old iOS project was turned into a dual destination macOS / iOS one.
To fix the issue I changed the Base SDK under Project -> Build Settings to Latest iOS (iOS10) and the change rippled through removing the macOS destination.
I fixed this by deleting the scheme showing issue and recreate it. This time it gets created as desired scheme type showing all the simulators and devices attached, if any.

iOS 3.x support in Xcode 4

Is it possible to write apps that support iOS 3.x versions using Xcode 4? If so, how? And does Apple have any official recommendations on app backwards-compatibility?
To get your app successfully run in iOS 3.x device, follow these steps (Xcode 4.2):
Click on your project name, select your Target and under "Build Settings"
a) Set "iOS development target" (under "Deployment") to 3.0
b). Add "armv6" to list of "Architectures" (under "Architectures").
c) Set "Other Linker Flags" (under "Linking") to "-weak-lSystem".
In your Info.plist file remove value of "armv7" from "Required device capabilities" (UIRequiredDeviceCapabilities).
In your code:
a). Do not use userInterfaceIdiom. If you need to know, what device is it (iPhone or iPad), see How does one get UI_USER_INTERFACE_IDIOM() to work with iPhone OS SDK < 3.2.
b) Do not use window.rootViewController. Instead use [window addSubview: self.mainViewController.view]; to add your main controller's view to window.
Click on your project name, select your Target and under "Build Phases" / "Link Binary With Libraries" set "UIKit.framework" to "Optional". Also set to optional any extra framework, which is not available in iOS 3. For example, if you're using iAd or Twitter frameworks they should be set to optional. Check availability of extra framework in your code before use.
When run on real device, compile app against last version of SDK. To do so, select second item from "Scheme" drop down (otherwise you'll get compile error related to your optional SDKs):
Yes, you can develop apps that support previous iOS versions with the current iOS SDK.
For official recommendations, see Apple's SDK Compatibility Guide.
The version of Xcode that you use isn't related to the version of iOS that your app can support. To choose the version of iOS that your app supports, simply change the iOS deployment target in your project settings. Then just be sure not to use any APIs from versions later than that.
to be sure, you can use Xcode 4 for targeting iOS 3.x as a deployment target, but you will not be able to simulate your program on a iOS 3.x SDK simulator. So you are pretty on your own (i.e., if you use any iOS 4.x-only feature, you will not find out it until you test on a physical device).
You need an older version of Xcode to debug against an older simulated SDK.

Unable to build using Xcode 4 - The selected run destination is not valid for this action

So I'm horribly confused by this error, other threads on Stack Overflow mention I should set the SDK, but I see no option to do this. I'm trying to build:http://wafflesoftware.net/shortcut/
And I get no options, and I can only choose My Mac 64-bit, and I want it in 32-bit. Really beginning to hate Xcode 4.
Here is the screenshot when I try to edit my scheme: http://groovyape.com/scheme.png
Thoughts?
Firstly, I have observed that when Xcode 4 decides my Mac is 64 bit and all my other schemes have vanished, a restart of Xcode fixes that.
If you still have the issue after a restart, go to Manage Schemes... (under the Product Menu) and click on Autocreate Schemes now button. Try to delete the other schemes and see if you can run the project now.
However, if the issue is that you need to set the SDK, that's different:
Click on the top-level project icon in the left hand panel
In the right hand panel that appears, select Build Settings (near the top).
Select "All" option (instead of Combined)
Ensure Base SDK is set appropriately, like "OS X 10.7".
FWIW I'm seriously considering reverting to Xcode 3.2.5 at the moment, 4 seems horrendously buggy.
In xCode 4.4.1, use Validate Settings to solve the problem!
I can select either 32bit or 64bit now.
Ran into the same error message ("The selected run destination is not valid for this action") when attempting to use XCode 4 to build/run a tiny Objective-C "Hello, World" project I created in XCode 3.x. Fixed it by choosing to "Manage Schemes..." from the drop-down menu to the right of the Stop button, deleting the one scheme on the list (click checkbox beside the scheme, then click the "-" button at the bottom left), and then clicking "Autocreate Schemes Now".
I also needed to change the "Base SDK" from 10.5 to 10.6, by clicking on 'folder' icon (beneath the Run button), clicking the root/top of the tree view below it, clicking on the blue icon below "PROJECT" in the pane just to the right, and then finally, choosing "Latest Mac OS X (Mac OS X 10.6)" to the right of that.
I had this issue today. I found switching Base SDK from Latest iOS (4.3) to iOS 4.3 fixed everything.
This will happen if XCode believes your mac is a 64-bit machine, when really it's a 32-bit. If this is the case for you, simply click on your project icon from the far-left pane - it's the menu item that displays your project name next to a little blue icon. This should bring up a center pane that says "PROJECT" at the top. Highlight your project name, and the third pane should now show your build settings. The first item is "Architectures" which will allow you to specify if you are building a 32-bit or 64-bit application.
Kind of amazing that none of the answers here solved the issue for me, but I figured it out. Forget restarting Xcode, or using Autocreate Schemes, still only 64-bit will show up as a valid destination in the scheme.
The correct solution is to change the Architecture for your project. Go to Build Settings (in the root node of your project), and change Architecture to 32-bit Intel, it's right above the Base SDK setting. Destination will instantly switch to "My Mac 32-bit". HTH somebody.
It sounds as if you're trying to run (Cmd-R or run button) the framework (which you can't do - it's not an executable, just a library) rather than simply build it (Cmd-B).
I had this issue and maybe it was a coincidence but when I restarted XC4 but this time didn't choose to load my project from the popup window that appears on launch - instead choosing it explicitly from the File menu - the issue didn't occur and the build started ok.
On the 3 or 4 occasions I had this error, I had chosen to load the project from the popup window that appears when XC4 first loads.
As I say, I might have just got lucky, but I certainly didn't make any other changes to the projects to 'fix' the issue.
I found a good practice for moving from Xcode 3.2.X to Xcode 4 is, to remove any references to older SDKs (in the case of Mac OS to remove any Base SDK Ref, etc., for Mac OS <= 10.5, in the case of iOS I think you need to remove everything <= 4.3) PRIOR to upgrading to Xcode 4.
I never experienced any problems for new Projects, created in Xcode 4, only for such that where created with Xcode 3.X or 2.X
Xcode 4.5. I was trying to compile for 10.6. It seemed to be stuck on 64 bit just because it couldn't find the sdk. I didn't get any message about it not finding the sdk.
I first tried to put in the correct path to /Developer-3.2.6/SDKs/MacOSX10.6.sdk but xcode didn't want to find it there. Then I copied that folder into 4.5 next to the other OSX Platform sdk (new location I think just look in the bundle).
And magically my 32 bit came back.
So my conclusion is that the 32/64 bit option is really dependent on whether xcode can verify the sdk that you're trying to use. Being stuck at 64 while trying to compile for 32 gives the error without notifying you that its first issue is that the sdk can't be found.
I fixed this by deleting my xcuserdata in my Project file. Not sure how it got corrupt. But it worked for everyone else in the office, deleting the xcuserdata did the trick. I made sure Xcode was closed while doing so. Just for fun, make sure you delete your DerivedData folder for the app, and do a build clean for superstitious folks.
If this happened after you renamed your app, go to Schemes -> Edit Scheme -> Run <YourApp> -> Info
Select the right executable file (YourApp.app)
Another way is to select None as executable and then reselect the YourApp.app from your Debug-iPhoneOS folder.

Resources