Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Adding an outlet on an object in Xcode/IB to match an @outlet in a .j file

15 views
Skip to first unread message

Luke

unread,
Jan 19, 2023, 11:38:57 PM1/19/23
to Cappuccino & Objective-J
It has been a long time since I played Cappuccino and clearly there has been a lot of water under the bridge with how Xcode/IB works. 

I'm pretty sure the last time I used IB, I could manually add a named outlet onto an object in IB.  However, now (reading the Xcode documentation) it seems as if Xcode is now code-aware and will find properties flagged as outlets in the actual code, manifesting the outlet in the graphical representation of the object in the xib file under edit. 

I can't find a way to manually cast the outlet onto an object without Xcode being aware of the source file/language and finding the outlet tagged property.  In particular, I have added an @outlet in my AppController.j file and need this to show up in my App Controller object in the xib, so that I can connect another UI element to it.   As I doubt Xcode has any way to scan a .j file and extract things marked with @outlet to manifest them in IB, how is one supposed to do this now?


Michael Bach

unread,
Jan 20, 2023, 1:43:44 AM1/20/23
to objec...@googlegroups.com
Dear Luke:

> … I can't find a way to manually cast the outlet onto an object without Xcode being aware of the source file/language and finding the outlet tagged property. In particular, I have added an @outlet in my AppController.j file and need this to show up in my App Controller object in the xib, so that I can connect another UI element to it. As I doubt Xcode has any way to scan a .j file and extract things marked with @outlet to manifest them in IB, how is one supposed to do this now?

Xcode does it for me. Never found the systematic way, but saving, re-saving the *.j file will work eventually; sometimes even quit/restart Xcode. Once the outlet turns up in the Interface Builder, it’s the usual dance with control-drag to connect.

It’s not XcodeCapp that does it – that doesn’t work anyway after Apple pulled Python 2 as we discussed in Gitter. I wrote a shell script to create the `.XcodeSupport` structure. I’m glad that `OneObjj2objcskeleton` and `nib2cib` made the transition.



Good luck with Cappuccino, best, Michael
--
https://michaelbach.de

Luke

unread,
Jan 20, 2023, 3:17:23 AM1/20/23
to Cappuccino & Objective-J
Interesting, thanks. 

I definitely can't get simple changes in a .j file (@outlet and IBAction items) to show up in Xcode 14 automatically.  I've tried multiple saves of the .j file and relaunches of Xcode (from XcodeCapp's button) - all to no avail. 

I've taken (temporarily I hope) to manually creating a similarly-named .m file in my project with an @interface section for @outlet and IBAction declarations.
That is definitely scanned by Xcode and I get the requisite outlets and actions in IB, which of course work with the similarly named items in the .j file at runtime. 
Annoying to have to make this extra file though and manage it's declarations, so I'm hoping I'll find a better way.

Martin Carlberg

unread,
Jan 20, 2023, 3:19:47 AM1/20/23
to Cappuccino & Objective-J
Hi!

Xcode need corresponding .h and .m files for each .j file as it does not know Objective-J to find outlets and actions. We have, as Michael points out, the objj2objcskeleton tool to create .h and .m files for Xcode.

XcodeCapp is a Mac app that listens to any changes to .j files in your project and run the tool on the file. It also listens to changes to .xib files and runs nib2cib to create the corresponding .cib file. It has many more functions but it uses python version 2 that is no longer installed on a Mac (version 3 is the current). It is in the Cappuccino projects tools folder.

There is a quick fix in the node branch for XcodeCapp so it will run objj2objcskeleton and nib2cib on any files in your project. The other functions will not work yet. XcodeCapp should be built when you built the Cappuccino project on a Mac. If not open it in Xcode and build it manually.

The .h and .m files can also be manually created with the objj2objcskeleton tool. Here is a one liner I use to create them all :-)

ls *.j | xargs -L1 bash -c 'objj2objcskeleton $0 .XcodeSupport'


Michael too has a nice shell script that will do it automatically.

Happy coding,

- Martin

--
You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectivej+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/objectivej/751AF009-8483-44BF-8474-CCA4651D15B6%40uni-freiburg.de.

Luke

unread,
Jan 20, 2023, 3:37:39 AM1/20/23
to Cappuccino & Objective-J
OK, thanks for the notes.  I was unaware of the objj2objcskeleton tool, so I'll probably go that route to at least save me the manual effort of maintaining the extra file or files.

I did actually build the XcodeCapp tool after fetching and building a clean (from source) build of the node framework/tools, and I do have the "Create Objective-C class pairs" option turned on.  However, I've never seen that work.
It does do the automatic xib to cib conversion, and it's nice to have a visual cue that it's doing that work.  Hopefully I cloned the latest node version of Cappuccino.  I think I did, but perhaps the fixed XcodeCapp is in another branch. 

Martin Carlberg

unread,
Jan 20, 2023, 4:22:09 AM1/20/23
to Cappuccino & Objective-J
Hi!

This works well for me. Make sure your Xcode project includes the .XcodeSupport folder (or where you have your .h and .m files).


- Martin

Luke

unread,
Jan 20, 2023, 3:11:18 PM1/20/23
to Cappuccino & Objective-J
Ah right.  Yes, I hadn't noticed that all the .h/.m files were being created/updated in the .XcodeSupport folder (which is of course normally hidden).
Adding this to the Xcode project files does indeed work.  

Reply all
Reply to author
Forward
0 new messages