Xcode 5 Cocoa App Fails to Load Nib on OS X 10.6 - xcode

I'm creating a Cocoa application for 10.6 and newer OSs. I created a brand new document-based application in Xcode 5 (10.9) and changed two settings to make it 10.6-compatible: I changed the deployment target to 10.6 and turned Auto Layout off on both MainMenu.xib and xxDocument.xib, the two default nibs that are included with the document-based template. I archived my application (no code signing) adding no other code and tested it on four different OSs. Here are the results:
OS X 10.9: Launches and shows a new document window ("Your document contents here") as expected.
OS X 10.8: Launches as expected; same as 10.9.
OS X 10.7: Fails to launch; Console applications yields "App Name: Unable to load nib file: MainMenu, exiting".
OSX 10.6: Fails to launch; Console yields same as 10.7.
I'm quite baffled as to the behavior of my application. I added absolutely no code to the template document-based app that Xcode created for me; I just changed the required settings to make it compatible with 10.6 and up. I also tried turning off ARC in the build settings, which made no difference at all. I checked Apple docs and also searched for other questions about the console error I received, but none of them were related to this problem. I was very surprised that 10.7 exhibited this behavior, as 10.7 is compatible with ARC. I would greatly appreciate any advice on how I can fix this problem. I would suspect that there is an easy modification to the default template, as Apple probably wouldn't supply a template that requires extensive modification to merely get it working. Thanks.
UPDATE:
As suggested, I turned off base internationalization in Xcode. I ran the app, and it worked fine. I exported the application (no code signing) and tested on all of the above OSs. This time, the error that I received above occurred for all OSs. This even occurred on the SAME machine that I built the project with, the only difference is that I didn't run it from Xcode. My next step was to actually make a MainMenu.xib file (because removing base internationalization deleted the old one) and set that as the main interface. Now not only do I get the error in the exported application on all OSs, but it shows up in Xcode when I try to run the application! Is there something else that I am missing?

AS mentioned before you need to disable Internationalization Base.
In the Project Navigator Click on the on the first item which is your project (denoted by blue page with white A in it, it is the root of all other items)
You should by default see the Info page to the left (if not select it from the tab at the top)
The last item in the Info property sheet is Localization. Under Localization you will have the ability to add and remove languages and you should by default have two already Base, and English.
Delete both, and deselect the check box "Use Base Internationalization"
Once you have done this, remove the any *.xib files you have from the project itself. MAKE SURE TO ONLY REMOVE REFERENCES !!!DO NOT SEND TO TRASH!!!
Once the references have been removed, go into Finder, Open your project directory and you will find a directory called Base.lproj with your *.xib files located in them. Copy or move them one level up to your project directory, and delete Base.lproj directory.
Go back into xCode and add back in your *.xib files. ++K to clean the project, then ++R to rebuild.
This should move the *.xib files in the App Package from Base.lproj (where 10.6 does not seem to find them) to the Resources file folder, and solve the problem.

Newly created Xcode 5 projects have base internationalization turned on. Base internationalization is supported on OS X 10.8 and later. You'll have to turn off base internationalization to support 10.7 and 10.6. See the following Stack Overflow question for more information:
Base.lproj/MainMenu.xib is not available when compiling for targets before Mac OS X 10.8
Another thing you may need to do to support 10.6 is to set the deployment target to 10.6 for both the project and the xib files. I know you said you set the deployment target to 10.6 in your question, but it wasn't clear if you set it for both the project and the xib files. As you're discovering, Apple's project templates do not place a high priority on compatibility with old OS versions.

Related

Deploy a Swift OS X app locally?

I am not new to programming, but I am new to Swift. I have developed a small app that I have no intention of distributing, I just want to use it for myself. Everything works just as desired in XCode and now I want to deploy that app locally. How can I run my app on my machine without needing to have XCode also running? I just want to see my app in my Applications folder and run it when I want. Does XCode put build files somewhere that I can access them and use outside of XCode?
On the Product menu there is an Archive option. Select that to create an archive of your app.
Xcode should then automatically open the Organiser window with the archive of your app selected.
You'll see a big blue button called Upload to App Store on the right with two smaller buttons below it. The one you want is called Export... Press it and you'll get a pane giving you various export options with different kinds of signing.
The bottom option creates an unsigned .app file which you can put in your Applications directory.
NB As Eric D says, you can just drag the app out of the products directory, but unless you edit the scheme, that will give you a debug build with less optimisation and with asserts activated.
Update for Xcode 11.2
As Bell B. Cooper points out, the process has changed slightly. Now when you archive an app, you get a window listing the apps and a big blue "Distribute" button. Pressing this, gets you a dialog box giving you the various options. Which one you choose depends on what you want to do with the executable. With Catalina, unless it's just for your own use, you probably want to go for one of the options that involves signing the app.
Edit: while this answer still works, it targets old Xcode versions and uses the debug version of your executable. For recent Xcode versions, and for using the release version of your executable, see JeremyP's answer.
Each time you build an OS X application with the current scheme, Xcode automatically populates the "Products" folder with the related app bundle.
You can find this folder in the Project Navigator:
Xcode > Project Navigator > "Products" folder
Your .app is in there and ready to be used and/or copied to the /Applications folder.

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.

Xcode default scheme and architecture setting mismatch (iPhone development)

I am developing iPhone application and choosing to build iPhone project. However, I don't know which setting or which part I edited in info.plist. Now the default scheme and architecture is set to be Mac application development.
Can anyone tell me how to edit the .plist file or make any setting to make the project build in iPhone/iPad stimulator nor Mac, when I choose to build an iPhone/iPad project. (I had edited the plist file using terminal, so I not sure which part I did wrong and cause this problem).
Because now every iPhone application project cannot be built, even for the new iOS application project (due to the setting will auto set to Mac nor iPhone).
in the build settings for your project (and you may have to do this for each target) change BaseSDK to Latest iOS.
i have no idea why changing the info.plist in one project would affect any new projects you create, tho.

XCode Developer API - Object Library - Objects Disappearing

Fairly new to the Xcode Developer API and need a little help. When a project is first opened in Xcode, the Object Library displays the full list of UIKit objects available (and other linked frameworks I believe). However, when I switch files in the project navigator to/from any file (.m, .h, .xib, etc), the Object Library list changes; most of the objects are missing - such as NSButton, NSTableView etc. The standard objects are still visible - Label, Round Rect Button, Text Field, etc.
Closing and re-opening the same project appears to restore the Object Library list, but the same issue happens once a different file is opened.
Using Xcode Version 4.2.1, Build 4D502.
Help!
I think I see what you are describing. When I first open an iOS project the Object Library is showing objects that are valid for OS X but not iOS (like File Menu Item). When I switch to a xib file the Object Library gets updated to show only the objects that are valid for iOS. Ideally I suppose that wouldn't happen but since you can't do anything with the Object Library while a source file is in the editor no harm is done.
If you are developing application for iOS(iPad or iPhone) you will not get that library which contains pop button , check box ,NSButton, NSTableView etc,that library is available for OS X app development.
OS and OS X don't use the same graphics library. iOS and OS X development are similar, but not the same. For example - you don't have Cocoa Bindings on iOS.
I you want to check then make one project for iOS & then see your library contents,then create another project for OSX & see your library contents... :D

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