I have been working with Xcode 4.2.1, but following some tutorials and videos from the earlier version of Xcode.
As usual I had the problem with the Windows Based Application. I created a empty application for my Windows Based Application project and was following some steps from the same forum of how to add a MainWindow.xib file to my project using this post
There is no .xib file when I create a new "Empty Application" in XCode
I also followed one more post which has some good screenshots:
http://www.trappers.tk/site/2011/06/16/mainwindow-xib/
Now my problem is I cannot ctrl+drag of the window outlet from the App Delegate object to the Window object. The reason is I could not find out the window outlet from tze attributes menu. One can see the screenshot of how it is looking in my xcode:
And below one can see how it should have a windows outlet for the App Delegate.
Is there anything I am missing or left something behind before coming there. I followed the steps exactly as mentioned in the above posts. I tried creating new projects just to make sure Im doing everything correct.
Any information regarding this would be appreciated.
Thanks
Raaks
From your tutorial..
http://www.trappers.tk/site/2011/06/16/mainwindow-xib/
The answer to your problem is Simple(and also this is the way you should do most of the time in future..)
1) Click on File's Owner(In the placeholder section..left to the xib).
2) In the attributes section you will see a window Outlet..
3) Drag window from the attributes section(right click-drag or ctrl-drag.) and drop it on window in Objects window..(left to the xib)
Related
Trying to create an AppleScript executable for MacOS 11.5 using Xcode 13 with AppleScript framework. Right out of the box (no processing on my part), the delegate icon on the IB display does not point to the default AppleScript code. This is clear since the outlet list for the icon claims that the AppDelegate does not have an outlet named theWindow whereas the AppleScript code clearly does. I've been trying for days to do a simple Hello World sort of thing and have been completely unable to connect UI elements with the "delegate", especially action elements. Am I missing some configuration step or is this a Xcode 13 bug? In examples I've seen on YouTube for creating this for this kind of simple thing the normal Xcode storyboard techniques work as expected (e.g. ctrl drag) but none of them used Xcode 13. Any insight is appreciated.screenshot of IB delegate binding
For future reference, this is starting to pop up on various forums, and appears to be a bug.
The normal signatures for creating IB outlets and action handlers is not being recognized by the Interface Editor. Existing projects - including the base Xcode templates - will build normally, although the editor shows warnings that outlets/actions don’t exist.
There isn’t much of a workaround other than creating objects programmatically or going back to an earlier version of Xcode until a fix is issued.
Update:
As mentioned in other answers and comments, the IB outlet and action handler connection bug has been fixed in Xcode 14, but the AppleScript application and Automator action templates are no longer included.
Custom templates can be created (or copied from an earlier version of Xcode from its Xcode.app/Contents/Developer/Library/Xcode/Templates/Project Templates/macOS/Other folder) and placed in a custom templates folder in your user’s Library folder at ~/Library/Developer/Xcode/Templates/. You can name this template folder whatever you want, such as "My Templates", where it will be shown in the template chooser.
Each template contains a TemplateInfo.plist file with various settings for that template - a complete tutorial is beyond the scope of this topic, but the value for the key "Identifier" in the base dictionary can be used to give your template a custom identifier, such as "com.my.cocoaApplicationAppleScript".
I am using 13.4.1 and the bug is still there.
I am wondering its its worth trying version 14 beta to see if it has been resolved
Playing around with this a little, I did find a workaround, though it's not entirely satisfactory. It amounts to editing the xib xml directly. For example, say you have button in the GUI that you'd like to reference in your script. First, create a property in the AppleScript like so:
property myButton : missing value
Then navigate to the xib file in Xcode, right-click on the xib in the file navigator and choose Open as... → Source Code (the default is "interface Builder XIB Document", which you'll want to return to later). This will show you the xml that underlies the graphical representation. First, search through the text to find the button in question. It will look something like:
<window title="Window" ...>
...
<view key="contentView" id="...">
...
<subviews>
<button ... id="xok-ud-pwL">
...
</button>
</subviews>
</view>
</window>
You want to get the id from the button, which in this case is "xok-ud-pwL". Then go back up to the top of the xml and look for the AppDelegate entry, which will look like:
<customObject id="Voe-Tx-rLC" customClass="AppDelegate"/>
You'll want to edit this so that it looks like the following:
<customObject id="Voe-Tx-rLC" customClass="AppDelegate">
<connections>
<outlet property="myButton" destination="xok-ud-pwL" id="gn6-Ea-hra"/>
</connections>
</customObject>
property should be the name of the property in the script
destination should be the id value of the button you want to connect
id should be a random and unique alphanumeric in 3-2-3 format
This will create an outlet connection between the property and the GUI element. It will even appear in the pop-up menu for the appDelegate so that you can reconnect it graphically. However, if you delete the connection in IB, Xcode will delete the entry from the xml, so you'll have to start again from scratch.
Still buggy, but...
The Release Candidate version of Xcode 14 patch it !
"Fixed an issue with outlet and action connections to AppleScript-based AppDelegates. (83373726) (FB9643535)"
But, you can't create a new project.
If you could find this old Template directory from an Xcode version < 14, you could add again the template AppleScript App.
Quit Xcode
Copy source template from version < 14 (I used v12.4):
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/Project Templates/macOS/Other/AppleScrip App.xctemplate
Copy to the destination folder:
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/Project Templates/Other/
Restart Xcode
I think Apple wants to remove AppleScript in next version of MacOS
Tested on Xcode 14 (14A309) 11 Sept 2022!
Regards
Laurent
In Xcode have added two localizations, German and English. I am following documentation on Apple regarding "Use Base Internationalization" which is obtained by going to the project, clicking Info and pressing on the checkbox.
If I do this, it launches a pane or page which is empty.
IE:
How do I get it to be populated, or otherwise be in a situation to select the relevant resource file?
The answer is to localize your storyboards. Go to storyboard, there is a button called localize. If you do this, the pane is no longer empty.
Check the answer from hassan83 (https://stackoverflow.com/users/1586924/hasan83) in another question. It solved my problems.
https://stackoverflow.com/a/27720065/7017099
"This could happen if Base Internationalization was active before then disabled and files deleted manually.
Create Base.lproj folder in your project folder using the finder.
Move your main story board to it also using the finder.
Fix the reference to it from Xcode.
Remove app from device, clean & build
your project.
All will be back to normal."
I have a little bit of a situation here. A few days ago, I accidentally deleted my storyboard, so immediately went into my trash and dragged the storyboard back into the project. Everything worked fine. But then I just emptied my trash and the storyboard no longer appears to be in my project; the storyboard file is showing up red and when I click on it, nothing loads. To my dismay, I thought all was lost so I started building a new storyboard and connecting the classes, outlets and actions.
I then went to build the project on the simulator, and it's building with the OLD storyboard. I thought it might just be loading it from memory so I deleted the app on the simulator and built the project again. Same thing again. So then I built it to my iPhone and somehow the old storyboard is still there even though I can't find it anywhere in my project.
What's going on here? Does this mean I'll be able to recover my storyboard?
Also, when I open the project inspector and go to Build Phases > Copy Bundle Resources, and right click on Storyboard.storyboard, and click show in finder, It shows my new storyboard.
1 - There is a place in Derived Data with following path:
/Users/<Your user name>/Library/Developer/Xcode/DerivedData/<Your App Name>/Build/Products/Debug-iphonesimulator/<app Name.app>
Browse to that location.
2 - On your .app file, right click -> Show Package Contents.
3 - In resulting directory list, browse the folder Base.lproj. Under that you are likely to find your old storyboard.
If you have done Delete Derived Data from XCode organizer, you are not likely to find anything up here. But fortunately, XCode doesn't delete it twice against your own wishes.
So try your luck.
I also faced same problem in Xcode 7.
But when I copy and paste it from Derived Data. I got
"Interface Builder cannot open compiled nibs"
So If you delete storyboard by reference. First, check your project folder (using the Finder). If it's there, you can drag it back into your project in Xcode, or you can use the “Add Files to …” menu option. that file is work perfectly.
We try to create a new project at Xcode. We create it and put some buttons on View on storyboard. When we execute project it executes an old project. What Im thinking is in Java there is a thing like set as main project is there anything like this in Xcode? Moreover if not what might cause the problem of this. It shows different buttons in storyboard and in execution it opens old project :S. I didn't like Xcode to be honest but I have to :(
Your project will have a file called -Info.plist. If you open this you will find and entry with the name of the main storyboard. This should be the storyboard you are editing. If it is something else that would explain the behaviour you describe.
This is a real 'WTF?' moment for me.
I copied some classes out from another project, including copy and pasting the code and some UIBulder components. What did NOT get copied was the XIB file (I went from XIB to storyboard).
My tab / swipe recognizers aren't activating, and when I drill down the only thing I can discover that can explain it is that somehow, someway, I'm hooking up against the XIB file. (When I click on the little button next to the IBAction/IBOutlet lines in the header, it shows me both the storyboard and the xib file as connected).
I'm not referencing that file anywhere that I can find, it's just somehow magically recognized in Xcode. I don't know what to do, how to fix this.
Anyone have any ideas?
Edit: The really annoying bit is that the file doesn't appear to be in my files list when I check there, I can't just delete the reference that way. And since it's referencing the file in the original project, I can't just delete it. (Any changes made in either project cause changes in BOTH projects; their both using the same xib file for some reason). I should be able to simply delete the reference to the xib file, but I can't find the reference.
If you copy the view controller code from one project into another project you will notice a strange thing happening with the outlet. It is referencing the view from the first project without you ever connecting any outlets.
If you left click the little circle and click the reference link you will even be taken to the storyboard view in the other project. Trying to figure out how to get rid of this reference can drive you crazy.
Well, the good news is that there is really nothing for you to fix. You didn't copy over some deep, hard to find referencing link. Xcode is just getting confused because the View Controller and the outlet name are the same in both projects. Basically just ignore what that little circle says. You can close the first project and Xcode will figure things out eventually. Right click your views in the storyboard to see what referencing outlets really exist in the current project. (See my fuller answer for more details.)
No need to delete Derived Data. That doesn't solve the problem anyway. Just try opening both projects at the same time again and you will get the same strange behavior.
The way I figured this out was to separately create two new projects that had view controllers with the same name and a referencing outlet with the same name. I never copied anything but Xcode showed one was referencing the other. Like I said, ignore the little circle.
I just had the same problem. What solved it for me was to close both projects, delete the derived data from both and then reopen the destination project.
I agree, it's a crazy problem.
I'm sure that this problem could happen and I fix it deleting the content of the Derived data folder of XCode.
I just want to add the steps of how to delete those files:
Don't Delete the DerivedData folder.
Go to preferences (Command ,) > Locations Tab
On Derived Data you are going to see the path, clic the right pointing arrow (that will open that location in Finder)
Close XCode
Select all the files inside the DerivedData Folder (do NOT select parent folder) and (Command Delete) or move them to the Trash and then Empty Trash
Open the project and you are done
I hope it helps someone
unless the xib file is in the project. it should not have a link to it.
the xib file connects to the .h file. not the other way around.
You may want to remove the connections in the storyboard and re-connect them.
Also make sure that the storyboard is the UI being started and that the item on the navigation stack is actually the storyboard page. But you should be able to connect both the storyboard and the xib file to the class at the same time. You just cannot connect one IBOutlet to more than one object in a single ui component (e.g. two buttons on the storyboard cannot both be connected to #property IBOutlet UIButton *myCurrentButton you must have a separate IBOutlet for each connection. On the other hand, any number of actions can be connected to an IBAction. which is why you get (id) sender on each action.
I dont know if this is exactly what you are experiencing, but I hope that understanding helps you debug your issue.