2

After hunting far and wide for a tool that would compile my Obj-C OS X app on Windows, I finally found . 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:

Xcode Error Message

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)
Sam Spencer
  • 8,492
  • 12
  • 76
  • 133
  • Regarding Edit 2: Don't manually add anything to the Compile Sources section. That is populated automatically when you add source files to your project. If you've made changes there you'll probably want to start over with a clean project. – SSteve Sep 17 '12 at 20:57
  • 1
    **This just in:** pauli on the Naming Things blog just a half hour ago posted [part two of his Cocotron tutorial](http://lacquer.fi/pauli/blog/2012/09/win-win-with-cocotron-part-2/). It runs through all the steps required to get an OS X project to compile under Cocotron. There's a lot in the beginning about including extra libraries, but to get up and running just skip down to the *Configuring the Windows target* section. – SSteve Sep 17 '12 at 23:52
  • @SSteve Thank you! You have saved me (er rather my project)! – Sam Spencer Sep 18 '12 at 01:04

1 Answers1

5

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: Executable folder path

Under File -> Project Settings -> Advanced, set build location to Legacy: build location

In Edit Scheme, set Build Configuration to Release: Build Configuration

A Build Products Path (mine is set to build-Windows): build products path

A Build Rule for C files to be processed with the Cocotron compiler: Build Rule

Link to Cocotron's Foundation and AppKit frameworks: link to frameworks

A Build Phase to run retargetBundle: retarget bundle

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.

SSteve
  • 10,550
  • 5
  • 46
  • 72
  • Helpful Answer, but I'm not getting the Windows folder inside of the Contents folder. Obviously I'm doing something wrong. Could this have to do with the Build Locations Settings? Or the Cocotron Settings? My EXECUTABLE_FOLDER_PATH setting looks fine, it seems like it just won't build the EXE file. – Sam Spencer Sep 06 '12 at 02:44
  • Did you set all of these [build settings](http://www.cocotron.org/Tools/Build_Settings/?path=Tools/Build_Settings)? What version of Xcode are you using? I think I've only used Cocotron under version 3. It doesn't look like these instructions have changed since then. I don't know if that means the build settings are still the same or just that the documentation hasn't been updated. – SSteve Sep 06 '12 at 05:59
  • Everything looks fine, however there are a few settings not shown in my project. I've built the project a few times and although the build succeeds, there are only two folders within the App Bundle/Contents/ folder. I am using Xcode 4.4.1. It seems odd that it won't work... – Sam Spencer Sep 06 '12 at 20:44
  • Could you check the edits. I've been working on this, and I was wondering if you could help out ( +50 bounty reward ;) ) – Sam Spencer Sep 13 '12 at 22:25
  • 1
    I'll try to take a look this weekend. – SSteve Sep 14 '12 at 02:32
  • Okay, so I've gone over every step what seems like 100 times but on every file listed in the Build Phases, Compile Sources Section I get this error: `unrecognized command line option "-Wshorten-64-to-32"`. I think that I might be missing some of the Frameworks that were installed initially. – Sam Spencer Sep 18 '12 at 23:14
  • That means you have a warning (-W) turned on that Cocotron's gcc compiler doesn't understand. Go into your Windows target's build settings and search for *shorten*. It will find the *Implicit Conversion to 32 Bit Type" setting. If you look at the Quick Help inspector you'll see that the gcc argument for this setting is "-Wshorten-64-to-32". Turn it off. Also, since your original question is answered, it's best to create new questions for any further problems instead of presenting them in comments. – SSteve Sep 19 '12 at 18:27