Giter VIP home page Giter VIP logo

ghc-xcode's Introduction

Summary

The ghc-xcode program makes it easier to develop graphical Haskell applications on OS X and iOS. It integrates into the XCode build system as a custom build phase. The programmer uses foreign export declarations to export a C API for their Haskell code. The ghc-xcode program ensures that all of the necessary object files will be compiled and linked together with the rest of the XCode project.

This package has been tested with XCode-4.1. It also currently requires ghc-7.4 or later.

Installation

This package may be installed by calling the following code from within the ghc-xcode directory:

cabal update; cabal install 

Instructions

  1. Copy the necessary Haskell modules into the directory that contains the .xcodeproj file. We will call this the "XCode directory".

  2. cd into the XCode directory. Run:

     ghc-xcode [args] [modules]
    

    where:

    • [args] is a list of compiler flags (e.g.: -O2, -threaded or -XScopedTypeVariables)
    • [modules] is a list of paths to the modules which contain foreign export declarations
  3. The ghc-xcode program will:

    • Perform an initial compile of the [modules] as well as any other module files which they import.

    • Create a C file named _hs_module_init.c which calls hs_init, hs_exit and hs_add_root in C constructors/destructors.

    • Create a symbolic link named _ghc_rts_include which points to ghc's rts include folder

    • Print a list of instructions for how to add the Haskell source code to the XCode project. For example:

        Compiling...
        Succeeded.
        You will need to make the following changes in XCode:
          * Under Build Settings, add Header Search Paths:
              _ghc_rts_include
          * Under Build Settings, add Other Linker Flags:
              -liconv
              -Wl,-no_compact_unwind,-no_pie
          * Add the following files to your XCode project:
              _hs_module_init.c
              FibTest_stub.h
          * Add a "Run Script" build phase which occurs before the
            "Compile Sources" phase and calls: 
              /Users/judah/.cabal/bin/ghc-xcode haskell/FibTest.hs
      

    Follow those instructions.

  4. Try building the XCode project. The ghc-xcode build phase will rebuild the modules and their dependencies as necessary. It will also tell XCode's link step to include the necessary module and package object files.

    If it fails, check the build logs; the most likely culprit is a missing C library or framework. These may be added in the XCode target's Build Settings.

This project is still somewhat experimental, so let me know if you run into any problems getting it set up.

ghc-xcode's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.