After hunting far and wide for a tool that would compile my Obj-C OS X app on Windows, I finally found cocotron. This allows me to (after a complicated installation and setup) add a few build settings and rules to my duplicated (for Windows) Xcode target and then build. The ultimate goal is to be able to run my OS X app, cross compile, and then run on Windows. The problem is, when I build & run, Xcode only generates an APP file not an EXE. Xcode won't even run it because the "Architecture" is not supported:
I've tried renaming the APP extension to EXE, but when I open it in Windows it just recognizes it as a folder not an executable program.
I feel like I am missing something. I think that Cocotron should automatically generate an EXE when done correctly, what else do I need to do to generate an EXE? I think that there is more to the documentation on cocotron.org, but it is incomplete and hard to understand.
How can I generate an EXE with Cocotron?
Anything is appreciated, as the official Cocotron documentation is scarce.... even another better cross-compiler?
EDIT: I downloaded Cocotron's TextEditor Example project and replicated every build setting EXACTLY as it was in the TextEdit project (with the exception of file paths / names). After doing this I attempted to build the windows target, once again no EXE file was generated within the .APP bundle.
EDIT 2: I have now added all of my implementation files to the Build Phases -> Compile Sources section, but I now have 130 Build Errors in the Windows target and now it doesn't build (of course, it generates 130 build errors). HOWEVER, the strange part is that 4/5s of the build errors are located in Header and PCH files. Only a handful are in the AppDelegate.m
I'm getting only a few different error messages consistently in the H and PCH files:
*:No Such File or Directory FRAMEWORK NAME
Expected * before *
Cocotron 1.0 Windows i386 gcc default (4.3.1) Error...
Some of those are appearing in the AppDelegate.M, in addition to things like:
Undeclared (First Use in this function)
The .exe is buried in the .app file. It's all in the .app folder because it mimics the structure of an OS X program. Open the .app folder and look in Contents/Windows. If your project was built correctly, the .exe file will be there.
Don't bother trying to run it from Xcode or in any other fashion under OS X, it's a Windows program.
And, yes, Cocotron's documentation leaves much to be desired. In spite of its difficulties and limitations there's no better way I've found to compile a Cocoa program to run under Windows. But be prepared for quite a bit of conditional compiling. It's been a number of months since I worked with it. I'm sure it's improving all the time.
Edit
I've got the Cocotron target in my existing project working under Xcode 4.4. Here are some settings to make sure you have:
Executable folder path:
Under File -> Project Settings -> Advanced, set build location to Legacy:
In Edit Scheme, set Build Configuration to Release:
A Build Products Path (mine is set to build-Windows):
A Build Rule for C files to be processed with the Cocotron compiler:
Link to Cocotron's Foundation and AppKit frameworks:
A Build Phase to run
retargetBundle
:After compiling with all that in place, you should see a
build-Windows
folder in your project folder that contains a Release folder which contains a .app bundle. Inside that bundle, you should see a Contents folder which contains a Windows folder which contains AppKit.1.0.dll, AppKit.framework, Foundation.1.0.dll, Foundation.framework, and yourApp.exe.If it's not working, let us know which parts of the app you see and which you don't.