Clean build in Xcode with Build Rules works in Objective-C but not in Swift (.h files not found in Bridging Header)

240 views
Skip to first unread message

ruggier...@gmail.com

unread,
Jan 3, 2017, 1:17:33 PM1/3/17
to j2objc-discuss
Hello

As described in the title, the Build Rules work fine and the .h/.m files gets generated.
I can import them in both Obj-C/Swift files (thanks to Bridging Header) and use them.

The problem comes when the build shall be clean, or a file has to be re-added (if there was a compile error). In that case, if the bridging header is importing the missing file, AND there is at least a Swift file, I can no more compile because Xcode apparently. In my example project, only workaround I found is, comment everything from the Swift files that references to transpiled classes, comment in Bridging Header the import of missing files, compile, and undo the changes.

Clearly this is utterly unconfortable. This problem is even reproducible in J2Reversi project.
Just add one Swift file. Xcode will ask you to create a bridging header file, say yes.

Now **clean** the project and import any transpiled (still to transpile) file, for example Move.h.

Now Xcode will complain and give error of file not found, and failed to import bridging header.

Is there a way to execute the build rule script before actually compiling Swift files?

I'd like to use Swift because it's much more clean than Objective-C and Swift 3 has pretty clean names in functions too, even if they're not mapped.

Tom Ball

unread,
Jan 3, 2017, 3:04:49 PM1/3/17
to j2objc-discuss
Is there a way to execute the build rule script before actually compiling Swift files?

You may be able to get Xcode to work if you define a static library target, move the Java files into it, then have your app depend on that library instead of directly on the Java files. When Xcode cleans an app that depends on other targets, it also cleans those targets. I haven't tried this, though. Perhaps other developers have experiences they can share.

--
You received this message because you are subscribed to the Google Groups "j2objc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to j2objc-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ruggier...@gmail.com

unread,
Jan 3, 2017, 6:03:02 PM1/3/17
to j2objc-discuss
How do I import generated files of a static library target? I had tried it but found no clue to import theme. Also, would you recommend more build with make? I think it could be better... it worked smooth on a sample project I downloaded but it's not easy for me configure J2ObjC in all its different ways.

I'd have also be interested in Build with Gradle but I heard it's not really well supported.
Reply all
Reply to author
Forward
0 new messages