Request - Xcode and Swift files

I'm using Swift in my iOS project for native UI stuff. However, when I save the project in Introjucer I have to delete and re-add all the Swift files in order for them to be recognised by Xcode during compilation. This in Xcode 7. 

Good point - try it again now!

Just pulled the latest tip, rebuilt Introjucer and resaved my project - same issue, I need to remove and re-add all the Swift files for it to compile...

Sorry, forgot to add it to the list of source file types - try again now.

I just tried this again, and still have the same issue. It adds the Swift files OK and they're visible in the Xcode project but I have to delete and re-add them in order to compile the project.

Hi guys, I'm still having this issue, just checking in to see if there's a fix possible.

I just tried adding a .swift file to a project and it did appear correctly in Xcode, and it gets compiled. Have you definitely pulled the latest version of the Introjucer?

OK - yes, it is working now, its compiling the Swift files, however I have a new issue now in that it does not pick up the bridging header which is needed to expose Objective-C classes and frameworks to Swift. So I still have to delete and re-import Swift files to get it to build. Not sure if there is anything Introjucer can do to solve this issue.

I've never worked with swift, and have no idea how bridging headers work, but if there's something easy we can add to support it, let us know..

Has this been resolved at all?
The following xcode settings would need to be added for target:
Screenshot 2020-05-18 at 13.00.48

You can set any Xcode setting that you fancy by adding them to the “Custom Xcode Flags” field (for each configuration) in Projucer.

Thanks! I’ve thought of that as well, and added SWIFT_VERSION=5.0 as I needed.
But I have no idea what flag would I use to set the bridging header for Swift.
Been trying to search through xcode docs without success…
Do you have any pointers to the full list of configurable xcode flags I can set?

The technique I usually use is to git add the Xcode project, change something in the Xcode UI, then I can see the relevant setting in the diff.

1 Like

Ha! Great idea! :wink: I’ll try! Do you know if all settings can be updated via SOME_XCODE_FLAG=XXX, or some of them can only be specified in the project file (whatever its format is)?

YES!!!
SWIFT_OBJC_BRIDGING_HEADER='../../Source/MyApp-Bridging-Header.h'
The ../../ is needed because of the way Juicer generates projects in subfolders.
Thanks a lot, good method!

2 Likes

P.S. Users might want to add SWIFT_OPTIMIZATION_LEVEL="-Onone" for the Debug configurations that use Swift. Also SWIFT_VERSION=5.0 (or the version you want to use) has to be added manually to all configurations flags in Juicer.

2 Likes

There’s another way to see the build setting names. In Xcode when looking at the build settings go to the “Editor” menu and select “Show Setting Names”, if you see “Show Setting Titles” then Xcode is already displaying the names. Additionally if you want to see the value you need to enter into the Projucer, again from the “Editor” menu in Xcode select “Show Definitions”, if you see “Show Values” Xcode is already showing the definitions. Note when “Show Definitions” is selected you won’t get the nice drop menus with all the available options for each setting.

2 Likes