27 Commits
Author SHA1 Message Date
NanoTech 1d0791226a Explain how to add a label in Interface Builder 2017-02-25 21:22:39 -06:00
NanoTech f4e9fe6d04 Add workaround for "Use of unresolved identifier" 2017-02-25 18:00:06 -06:00
NanoTech 23e63b31b6 Reset project module settings to match tutorial results
These are the default settings on a new Xcode
Swift project.

This fixes "Umbrella header 'SwiftAppLibrary.h'
not found" on clean builds.
2017-02-25 17:35:11 -06:00
NanoTech 5ccabf268b Switch project group order to match the reader's project 2017-02-25 17:31:19 -06:00
NanoTech 52703c2dc9 Need to build the framework after adding runNSApplication 2017-02-25 17:17:58 -06:00
NanoTech b545a3ae24 Add a screenshot for adding Run Script 2017-02-25 17:17:33 -06:00
NanoTech 8f52ca7cb9 Update Swift stdlib embed screenshot 2017-02-25 16:24:31 -06:00
NanoTech 624b296fa4 Add a step to remove @NSApplicationMain 2017-02-25 16:15:10 -06:00
NanoTech b4e8e344e1 Table of contents 2017-02-24 00:35:23 -06:00
NanoTech 6e2df7fc73 Add troubleshooting section 2017-02-24 00:35:23 -06:00
NanoTech 4a6f94a435 Add more clarification 2017-02-24 00:35:23 -06:00
NanoTech 7f46097382 Add flag references 2017-02-24 00:35:23 -06:00
NanoTech 6c24bf8649 Clarify the framework conversion section
Also, switch to embedding the Swift standard
libraries in the app's Frameworks directory.
It works just as well (@executable_path/../Frameworks
is one of the framework's rpaths) and is
consistent with typical Swift apps.
2017-02-24 00:35:23 -06:00
NanoTech ab21acac78 Describe script output 2017-02-24 00:35:23 -06:00
NanoTech 4e47c437f3 Order targets in addition order
To match what the reader will see in their project.
2017-02-24 00:35:23 -06:00
NanoTech 163d0d0a6d Improve link-deps.sh comments 2017-02-24 00:35:23 -06:00
NanoTech 3c0871874d Add a short introduction 2017-02-24 00:35:23 -06:00
NanoTech fcf526afb1 Instruct to build the framework before linking it 2017-02-21 18:59:28 -06:00
NanoTech 31d3a4771b Reminder to change EXECUTABLE_NAME if needed 2017-02-21 18:58:23 -06:00
NanoTech 7e9f47e85a Change some titles 2017-02-15 22:40:47 -06:00
NanoTech 4f82e89ba9 Update screenshots
- Crop the first two project creation screenshots
- Update and use the New Copy Files Phase screenshot
- Remove unused screenshots
2017-02-15 22:40:47 -06:00
NanoTech e504bbd81d Update Run Script input files 2017-02-15 22:40:47 -06:00
NanoTech 01fd35818c Fix linking with -whole-module-optimization enabled 2017-02-15 22:40:47 -06:00
NanoTech d244d0293d xcodebuild postBuild hook example 2017-02-15 21:47:06 -06:00
NanoTech 898c58a23e Add FFI tutorial and examples 2017-02-15 20:32:22 -06:00
NanoTech 4fea5657c2 Complete the linking tutorial 2017-02-12 03:06:39 -06:00
NanoTech 47f6693417 Alternate version that links the Swift code as a framework 2017-02-09 23:21:59 -06:00
40 changed files with 1451 additions and 312 deletions
+852 -140
View File
File diff suppressed because it is too large Load Diff
+3
View File
@@ -0,0 +1,3 @@
module SwHaLib {
export *
}
+115
View File
@@ -0,0 +1,115 @@
//
// AppDelegate.swift
// SwiftAppLibrary
//
// Created by NanoTech on 2017-02-09.
// Copyright © 2017 nanotech. All rights reserved.
//
import Cocoa
import SwiftHaskell
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
@IBOutlet weak var label: NSTextField!
func applicationDidFinishLaunching(_ aNotification: Notification) {
let bytes: [UInt8] = [1, 2, 3, 2, 1, 2]
callbackExample { n in
print(n)
}
var callbackResult: CInt? = nil
contextCallbackExample { n in
callbackResult = n
}
let m = Multiplier(5)
label.stringValue = [
"5^2 = \(square(5))",
"2 occurs \(count(byte: 2, in: bytes)) times in \(bytes)",
"getSequence returned \(getSequence())",
"Context callback returned \(callbackResult)",
"5 * 3 = \(m.multiply(3))",
].joined(separator: "\n")
}
func applicationWillTerminate(_ aNotification: Notification) {
}
}
// Swift to Haskell ByteString Example
func count(byte: UInt8, in bytes: [UInt8]) -> Int {
var r = 0
bytes.withUnsafeBufferPointer { bytesBufPtr in
r = Int(SwiftHaskell.countBytes(byte,
HsPtr(mutating: bytesBufPtr.baseAddress),
HsWord64(bytesBufPtr.count)))
}
return r
}
// Haskell to Swift ByteString Example
func getSequence() -> [UInt8] {
var n = 0
let p = SwiftHaskell.getSequence(&n).assumingMemoryBound(to: UInt8.self)
let a = [UInt8](UnsafeBufferPointer(start: p, count: n))
free(p)
return a
}
// Swift to Haskell Callback Example
func callbackExample(f: (@convention(c) (CInt) -> Void)) {
let hsf = unsafeBitCast(f, to: HsFunPtr.self)
SwiftHaskell.callbackExample(hsf)
}
// Swift to Haskell Callback with Context Example
func contextCallbackExample(f: ((CInt) -> Void)) {
class Wrap<T> {
var inner: T
init(_ inner: T) {
self.inner = inner
}
}
let x = 3
func release(context: HsPtr) {
let _: Wrap<(CInt) -> Void> = Unmanaged.fromOpaque(context).takeRetainedValue()
}
func call(context: HsPtr, value: CInt) {
let wf: Wrap<(CInt) -> Void> = Unmanaged.fromOpaque(context).takeUnretainedValue()
let f = wf.inner
f(value)
}
let release_hs = unsafeBitCast(
release as @convention(c) (HsPtr) -> Void, to: HsFunPtr.self)
let call_hs = unsafeBitCast(
call as @convention(c) (HsPtr, CInt) -> Void, to: HsFunPtr.self)
let ctx = Unmanaged.passRetained(Wrap(f)).toOpaque()
SwiftHaskell.contextCallbackExample(ctx, release_hs, call_hs)
}
// Swift to Haskell Function Example
class Multiplier {
let funPtr: HsFunPtr
init(_ x: CInt) {
self.funPtr = SwiftHaskell.makeMultiplier(x)
}
func multiply(_ y: CInt) -> CInt {
typealias F = @convention(c) (CInt) -> CInt
let f = unsafeBitCast(self.funPtr, to: F.self)
return f(y)
}
deinit {
SwiftHaskell.freeMultiplier(self.funPtr)
}
}
@@ -13,7 +13,7 @@
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="SwiftHaskell" customModuleProvider="target"> <customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="SwiftAppLibrary" customModuleProvider="target">
<connections> <connections>
<outlet property="label" destination="drV-ep-pYM" id="xdv-Y5-tR0"/> <outlet property="label" destination="drV-ep-pYM" id="xdv-Y5-tR0"/>
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/> <outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
@@ -690,9 +690,8 @@
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/> <rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="drV-ep-pYM"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="drV-ep-pYM">
<rect key="frame" x="18" y="323" width="37" height="17"/> <rect key="frame" x="18" y="323" width="444" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="Wba-z2-8m1"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="Wba-z2-8m1">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -700,6 +699,11 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
</subviews> </subviews>
<constraints>
<constraint firstItem="drV-ep-pYM" firstAttribute="top" secondItem="EiT-Mj-1SZ" secondAttribute="top" constant="20" id="5eo-Sd-hEH"/>
<constraint firstItem="drV-ep-pYM" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" constant="20" id="OlT-mM-yos"/>
<constraint firstAttribute="trailing" secondItem="drV-ep-pYM" secondAttribute="trailing" constant="20" id="kzO-Mq-rea"/>
</constraints>
</view> </view>
</window> </window>
</objects> </objects>
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017 nanotech. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
+19
View File
@@ -0,0 +1,19 @@
//
// SwiftAppLibrary.h
// SwiftAppLibrary
//
// Created by NanoTech on 2017-02-08.
// Copyright © 2017 nanotech. All rights reserved.
//
#import <Cocoa/Cocoa.h>
//! Project version number for SwiftAppLibrary.
FOUNDATION_EXPORT double SwiftAppLibraryVersionNumber;
//! Project version string for SwiftAppLibrary.
FOUNDATION_EXPORT const unsigned char SwiftAppLibraryVersionString[];
FOUNDATION_EXPORT void runNSApplication(void);
// In this header, you should import all the public headers of your framework using statements like #import <SwiftAppLibrary/PublicHeader.h>
+13
View File
@@ -0,0 +1,13 @@
#import "SwiftAppLibrary.h"
@interface AClassInThisFramework : NSObject @end
@implementation AClassInThisFramework @end
void runNSApplication(void) {
NSApplication *app = [NSApplication sharedApplication];
NSBundle *bundle = [NSBundle bundleForClass:[AClassInThisFramework class]];
NSArray *topObjects;
[[[NSNib alloc] initWithNibNamed:@"MainMenu" bundle:bundle]
instantiateWithOwner:app topLevelObjects:&topObjects];
[app run];
}
+245 -101
View File
@@ -7,136 +7,187 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
BFABC4321E4BE794006036C6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFABC4311E4BE794006036C6 /* AppDelegate.swift */; }; BFABC4601E4C1DD1006036C6 /* SwiftAppLibrary.h in Headers */ = {isa = PBXBuildFile; fileRef = BFABC45E1E4C1DD1006036C6 /* SwiftAppLibrary.h */; settings = {ATTRIBUTES = (Public, ); }; };
BFABC4341E4BE794006036C6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BFABC4331E4BE794006036C6 /* Assets.xcassets */; }; BFABC4CD1E4D627E006036C6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFABC4CC1E4D627E006036C6 /* AppDelegate.swift */; };
BFABC4371E4BE794006036C6 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = BFABC4351E4BE794006036C6 /* MainMenu.xib */; }; BFABC4D21E4D664D006036C6 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = BFABC4D01E4D664D006036C6 /* MainMenu.xib */; };
BFABC4C31E4C26C8006036C6 /* libswifthaskell.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BFABC4C21E4C26C8006036C6 /* libswifthaskell.dylib */; }; BFABC4E01E4D781D006036C6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BFABC4DF1E4D781D006036C6 /* Assets.xcassets */; };
BFABC4C61E4C26DF006036C6 /* libHSrts_thr-ghc8.0.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BFABC4C51E4C26DF006036C6 /* libHSrts_thr-ghc8.0.1.dylib */; }; BFABC4ED1E4D78E5006036C6 /* SwiftHaskell in Copy Files */ = {isa = PBXBuildFile; fileRef = BFABC4EA1E4D78D9006036C6 /* SwiftHaskell */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
BFABC4C81E4C26E2006036C6 /* libffi.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BFABC4C71E4C26E2006036C6 /* libffi.dylib */; }; BFABC4F01E4D7951006036C6 /* SwiftAppLibrary.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BFABC45B1E4C1DD1006036C6 /* SwiftAppLibrary.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
BFABC4C91E4C2746006036C6 /* libswifthaskell.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = BFABC4C21E4C26C8006036C6 /* libswifthaskell.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; BFE4CC421E55553000F232D6 /* SwiftAppLibrary.m in Sources */ = {isa = PBXBuildFile; fileRef = BFE4CC411E55553000F232D6 /* SwiftAppLibrary.m */; };
BFABC4CA1E4C2746006036C6 /* libffi.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = BFABC4C71E4C26E2006036C6 /* libffi.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
BFABC4CB1E4C2746006036C6 /* libHSrts_thr-ghc8.0.1.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = BFABC4C51E4C26DF006036C6 /* libHSrts_thr-ghc8.0.1.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
BFABC4E81E4D7842006036C6 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = BFABC4521E4C1DD1006036C6 /* Project object */;
proxyType = 1;
remoteGlobalIDString = BFABC45A1E4C1DD1006036C6;
remoteInfo = SwiftAppLibrary;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
BFABC44B1E4C1BFA006036C6 /* CopyFiles */ = { BFABC4EC1E4D78DF006036C6 /* Copy Files */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 6;
files = (
BFABC4ED1E4D78E5006036C6 /* SwiftHaskell in Copy Files */,
);
name = "Copy Files";
runOnlyForDeploymentPostprocessing = 0;
};
BFABC4EF1E4D7948006036C6 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase; isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
BFABC4C91E4C2746006036C6 /* libswifthaskell.dylib in CopyFiles */, BFABC4F01E4D7951006036C6 /* SwiftAppLibrary.framework in Embed Frameworks */,
BFABC4CA1E4C2746006036C6 /* libffi.dylib in CopyFiles */,
BFABC4CB1E4C2746006036C6 /* libHSrts_thr-ghc8.0.1.dylib in CopyFiles */,
); );
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
BFABC42E1E4BE794006036C6 /* SwiftHaskell.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftHaskell.app; sourceTree = BUILT_PRODUCTS_DIR; }; BFABC45B1E4C1DD1006036C6 /* SwiftAppLibrary.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftAppLibrary.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BFABC4311E4BE794006036C6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; BFABC45E1E4C1DD1006036C6 /* SwiftAppLibrary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftAppLibrary.h; sourceTree = "<group>"; };
BFABC4331E4BE794006036C6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; BFABC45F1E4C1DD1006036C6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BFABC4361E4BE794006036C6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; }; BFABC4CC1E4D627E006036C6 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
BFABC4381E4BE794006036C6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; BFABC4D11E4D664D006036C6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = MainMenu.xib; sourceTree = "<group>"; };
BFABC4461E4C011B006036C6 /* SwiftHaskell-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SwiftHaskell-Bridging-Header.h"; sourceTree = "<group>"; }; BFABC4D71E4D781D006036C6 /* SwiftHaskell.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftHaskell.app; sourceTree = BUILT_PRODUCTS_DIR; };
BFABC4C21E4C26C8006036C6 /* libswifthaskell.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libswifthaskell.dylib; path = build/libswifthaskell.dylib; sourceTree = "<group>"; }; BFABC4DF1E4D781D006036C6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
BFABC4C51E4C26DF006036C6 /* libHSrts_thr-ghc8.0.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libHSrts_thr-ghc8.0.1.dylib"; path = "build/libHSrts_thr-ghc8.0.1.dylib"; sourceTree = "<group>"; }; BFABC4E41E4D781D006036C6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BFABC4C71E4C26E2006036C6 /* libffi.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libffi.dylib; path = build/libffi.dylib; sourceTree = "<group>"; }; BFABC4EA1E4D78D9006036C6 /* SwiftHaskell */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = SwiftHaskell; path = build/SwiftHaskell; sourceTree = SOURCE_ROOT; };
BFE4CC411E55553000F232D6 /* SwiftAppLibrary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SwiftAppLibrary.m; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
BFABC42B1E4BE794006036C6 /* Frameworks */ = { BFABC4571E4C1DD1006036C6 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
BFABC4C31E4C26C8006036C6 /* libswifthaskell.dylib in Frameworks */,
BFABC4C81E4C26E2006036C6 /* libffi.dylib in Frameworks */,
BFABC4C61E4C26DF006036C6 /* libHSrts_thr-ghc8.0.1.dylib in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
/* End PBXFrameworksBuildPhase section */ /* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */ /* Begin PBXGroup section */
BFABC4251E4BE794006036C6 = { BFABC4511E4C1DD1006036C6 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
BFABC4301E4BE794006036C6 /* SwiftHaskell */, BFABC4D81E4D781D006036C6 /* SwiftHaskell */,
BFABC4C41E4C26CA006036C6 /* Libraries */, BFABC45D1E4C1DD1006036C6 /* SwiftAppLibrary */,
BFABC42F1E4BE794006036C6 /* Products */, BFABC45C1E4C1DD1006036C6 /* Products */,
); );
sourceTree = "<group>"; sourceTree = "<group>";
}; };
BFABC42F1E4BE794006036C6 /* Products */ = { BFABC45C1E4C1DD1006036C6 /* Products */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
BFABC42E1E4BE794006036C6 /* SwiftHaskell.app */, BFABC45B1E4C1DD1006036C6 /* SwiftAppLibrary.framework */,
BFABC4D71E4D781D006036C6 /* SwiftHaskell.app */,
); );
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
BFABC4301E4BE794006036C6 /* SwiftHaskell */ = { BFABC45D1E4C1DD1006036C6 /* SwiftAppLibrary */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
BFABC4311E4BE794006036C6 /* AppDelegate.swift */, BFABC45E1E4C1DD1006036C6 /* SwiftAppLibrary.h */,
BFABC4461E4C011B006036C6 /* SwiftHaskell-Bridging-Header.h */, BFE4CC411E55553000F232D6 /* SwiftAppLibrary.m */,
BFABC4331E4BE794006036C6 /* Assets.xcassets */, BFABC4CC1E4D627E006036C6 /* AppDelegate.swift */,
BFABC4351E4BE794006036C6 /* MainMenu.xib */, BFABC4D01E4D664D006036C6 /* MainMenu.xib */,
BFABC4381E4BE794006036C6 /* Info.plist */, BFABC45F1E4C1DD1006036C6 /* Info.plist */,
);
path = SwiftAppLibrary;
sourceTree = "<group>";
};
BFABC4D81E4D781D006036C6 /* SwiftHaskell */ = {
isa = PBXGroup;
children = (
BFABC4DF1E4D781D006036C6 /* Assets.xcassets */,
BFABC4EA1E4D78D9006036C6 /* SwiftHaskell */,
BFABC4E41E4D781D006036C6 /* Info.plist */,
); );
path = SwiftHaskell; path = SwiftHaskell;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
BFABC4C41E4C26CA006036C6 /* Libraries */ = {
isa = PBXGroup;
children = (
BFABC4C21E4C26C8006036C6 /* libswifthaskell.dylib */,
BFABC4C71E4C26E2006036C6 /* libffi.dylib */,
BFABC4C51E4C26DF006036C6 /* libHSrts_thr-ghc8.0.1.dylib */,
);
name = Libraries;
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
BFABC4581E4C1DD1006036C6 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
BFABC4601E4C1DD1006036C6 /* SwiftAppLibrary.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
BFABC42D1E4BE794006036C6 /* SwiftHaskell */ = { BFABC45A1E4C1DD1006036C6 /* SwiftAppLibrary */ = {
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = BFABC43B1E4BE794006036C6 /* Build configuration list for PBXNativeTarget "SwiftHaskell" */; buildConfigurationList = BFABC4631E4C1DD1006036C6 /* Build configuration list for PBXNativeTarget "SwiftAppLibrary" */;
buildPhases = ( buildPhases = (
BFABC42A1E4BE794006036C6 /* Sources */, BF2EA5CA1E5030E100651018 /* stack build and link-deps */,
BFABC42B1E4BE794006036C6 /* Frameworks */, BFABC4561E4C1DD1006036C6 /* Sources */,
BFABC42C1E4BE794006036C6 /* Resources */, BFABC4571E4C1DD1006036C6 /* Frameworks */,
BFABC44B1E4C1BFA006036C6 /* CopyFiles */, BFABC4581E4C1DD1006036C6 /* Headers */,
BFABC4441E4BFEA3006036C6 /* ShellScript */, BFABC4591E4C1DD1006036C6 /* Resources */,
BFABC4CE1E4D6344006036C6 /* Link framework to build */,
); );
buildRules = ( buildRules = (
); );
dependencies = ( dependencies = (
); );
name = SwiftAppLibrary;
productName = SwiftAppLibrary;
productReference = BFABC45B1E4C1DD1006036C6 /* SwiftAppLibrary.framework */;
productType = "com.apple.product-type.framework";
};
BFABC4D61E4D781D006036C6 /* SwiftHaskell */ = {
isa = PBXNativeTarget;
buildConfigurationList = BFABC4E51E4D781D006036C6 /* Build configuration list for PBXNativeTarget "SwiftHaskell" */;
buildPhases = (
BFABC4D51E4D781D006036C6 /* Resources */,
BFABC4EF1E4D7948006036C6 /* Embed Frameworks */,
BFABC4EC1E4D78DF006036C6 /* Copy Files */,
);
buildRules = (
);
dependencies = (
BFABC4E91E4D7842006036C6 /* PBXTargetDependency */,
);
name = SwiftHaskell; name = SwiftHaskell;
productName = SwiftHaskell; productName = SwiftHaskell;
productReference = BFABC42E1E4BE794006036C6 /* SwiftHaskell.app */; productReference = BFABC4D71E4D781D006036C6 /* SwiftHaskell.app */;
productType = "com.apple.product-type.application"; productType = "com.apple.product-type.application";
}; };
/* End PBXNativeTarget section */ /* End PBXNativeTarget section */
/* Begin PBXProject section */ /* Begin PBXProject section */
BFABC4261E4BE794006036C6 /* Project object */ = { BFABC4521E4C1DD1006036C6 /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0820; LastUpgradeCheck = 0820;
ORGANIZATIONNAME = nanotech; ORGANIZATIONNAME = nanotech;
TargetAttributes = { TargetAttributes = {
BFABC42D1E4BE794006036C6 = { BFABC45A1E4C1DD1006036C6 = {
CreatedOnToolsVersion = 8.2;
LastSwiftMigration = 0820;
ProvisioningStyle = Automatic;
};
BFABC4D61E4D781D006036C6 = {
CreatedOnToolsVersion = 8.2; CreatedOnToolsVersion = 8.2;
ProvisioningStyle = Automatic; ProvisioningStyle = Automatic;
}; };
}; };
}; };
buildConfigurationList = BFABC4291E4BE794006036C6 /* Build configuration list for PBXProject "SwiftHaskell" */; buildConfigurationList = BFABC4551E4C1DD1006036C6 /* Build configuration list for PBXProject "SwiftHaskell" */;
compatibilityVersion = "Xcode 3.2"; compatibilityVersion = "Xcode 3.2";
developmentRegion = English; developmentRegion = English;
hasScannedForEncodings = 0; hasScannedForEncodings = 0;
@@ -144,73 +195,108 @@
en, en,
Base, Base,
); );
mainGroup = BFABC4251E4BE794006036C6; mainGroup = BFABC4511E4C1DD1006036C6;
productRefGroup = BFABC42F1E4BE794006036C6 /* Products */; productRefGroup = BFABC45C1E4C1DD1006036C6 /* Products */;
projectDirPath = ""; projectDirPath = "";
projectRoot = ""; projectRoot = "";
targets = ( targets = (
BFABC42D1E4BE794006036C6 /* SwiftHaskell */, BFABC4D61E4D781D006036C6 /* SwiftHaskell */,
BFABC45A1E4C1DD1006036C6 /* SwiftAppLibrary */,
); );
}; };
/* End PBXProject section */ /* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */ /* Begin PBXResourcesBuildPhase section */
BFABC42C1E4BE794006036C6 /* Resources */ = { BFABC4591E4C1DD1006036C6 /* Resources */ = {
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
BFABC4341E4BE794006036C6 /* Assets.xcassets in Resources */, BFABC4D21E4D664D006036C6 /* MainMenu.xib in Resources */,
BFABC4371E4BE794006036C6 /* MainMenu.xib in Resources */, );
runOnlyForDeploymentPostprocessing = 0;
};
BFABC4D51E4D781D006036C6 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BFABC4E01E4D781D006036C6 /* Assets.xcassets in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
/* End PBXResourcesBuildPhase section */ /* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */
BFABC4441E4BFEA3006036C6 /* ShellScript */ = { BF2EA5CA1E5030E100651018 /* stack build and link-deps */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
); );
inputPaths = ( inputPaths = (
"$(PROJECT_DIR)/src/Lib.hs", "$(PROJECT_DIR)/src/Main.hs",
"$(PROJECT_DIR)/SwiftHaskellLibrary.cabal", "$(PROJECT_DIR)/SwiftHaskellLibrary.cabal",
"$(PROJECT_DIR)/stack.yaml", "$(PROJECT_DIR)/stack.yaml",
); );
name = "stack build and link-deps";
outputPaths = ( outputPaths = (
"$(PROJECT_DIR)/build/libswifthaskell.dylib", "$(PROJECT_DIR)/build/SwiftHaskell",
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "stack build"; shellScript = "stack build\nbash link-deps.sh";
showEnvVarsInLog = 0;
};
BFABC4CE1E4D6344006036C6 /* Link framework to build */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"$(BUILT_PRODUCTS_DIR)/$(FULL_PRODUCT_NAME)",
);
name = "Link framework to build";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -u\nln -sf \"${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}\" \"${PROJECT_DIR}/build/\"";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
/* End PBXShellScriptBuildPhase section */ /* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */
BFABC42A1E4BE794006036C6 /* Sources */ = { BFABC4561E4C1DD1006036C6 /* Sources */ = {
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
BFABC4321E4BE794006036C6 /* AppDelegate.swift in Sources */, BFABC4CD1E4D627E006036C6 /* AppDelegate.swift in Sources */,
BFE4CC421E55553000F232D6 /* SwiftAppLibrary.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
/* End PBXSourcesBuildPhase section */ /* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
BFABC4E91E4D7842006036C6 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = BFABC45A1E4C1DD1006036C6 /* SwiftAppLibrary */;
targetProxy = BFABC4E81E4D7842006036C6 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */ /* Begin PBXVariantGroup section */
BFABC4351E4BE794006036C6 /* MainMenu.xib */ = { BFABC4D01E4D664D006036C6 /* MainMenu.xib */ = {
isa = PBXVariantGroup; isa = PBXVariantGroup;
children = ( children = (
BFABC4361E4BE794006036C6 /* Base */, BFABC4D11E4D664D006036C6 /* Base */,
); );
name = MainMenu.xib; name = MainMenu.xib;
path = Base.lproj;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
/* End PBXVariantGroup section */ /* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */ /* Begin XCBuildConfiguration section */
BFABC4391E4BE794006036C6 /* Debug */ = { BFABC4611E4C1DD1006036C6 /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
@@ -233,6 +319,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-"; CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
@@ -256,10 +343,12 @@
SDKROOT = macosx; SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
}; };
name = Debug; name = Debug;
}; };
BFABC43A1E4BE794006036C6 /* Release */ = { BFABC4621E4C1DD1006036C6 /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
@@ -282,6 +371,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-"; CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -297,69 +387,123 @@
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx; SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
}; };
name = Release; name = Release;
}; };
BFABC43C1E4BE794006036C6 /* Debug */ = { BFABC4641E4C1DD1006036C6 /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = SwiftHaskell/Info.plist; DEFINES_MODULE = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; DYLIB_COMPATIBILITY_VERSION = 1;
LIBRARY_SEARCH_PATHS = ( DYLIB_CURRENT_VERSION = 1;
"$(inherited)", DYLIB_INSTALL_NAME_BASE = "@rpath";
"$(PROJECT_DIR)/build", FRAMEWORK_VERSION = A;
INFOPLIST_FILE = SwiftAppLibrary/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
OTHER_LDFLAGS = (
"-undefined",
dynamic_lookup,
); );
PRODUCT_BUNDLE_IDENTIFIER = net.nanotechcorp.SwiftHaskell; PRODUCT_BUNDLE_IDENTIFIER = net.nanotechcorp.SwiftAppLibrary;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "SwiftHaskell/SwiftHaskell-Bridging-Header.h"; SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "$(PROJECT_DIR)/SwiftHaskell/include";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0; SWIFT_VERSION = 3.0;
USER_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/build $(PROJECT_DIR)/build/include"; USER_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/build/ghc/include";
}; };
name = Debug; name = Debug;
}; };
BFABC43D1E4BE794006036C6 /* Release */ = { BFABC4651E4C1DD1006036C6 /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = SwiftAppLibrary/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
OTHER_LDFLAGS = (
"-undefined",
dynamic_lookup,
);
PRODUCT_BUNDLE_IDENTIFIER = net.nanotechcorp.SwiftAppLibrary;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "$(PROJECT_DIR)/SwiftHaskell/include";
SWIFT_VERSION = 3.0;
USER_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/build/ghc/include";
};
name = Release;
};
BFABC4E61E4D781D006036C6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = SwiftHaskell/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = net.nanotechcorp.SwiftHaskell;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
BFABC4E71E4D781D006036C6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = SwiftHaskell/Info.plist; INFOPLIST_FILE = SwiftHaskell/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/build",
);
PRODUCT_BUNDLE_IDENTIFIER = net.nanotechcorp.SwiftHaskell; PRODUCT_BUNDLE_IDENTIFIER = net.nanotechcorp.SwiftHaskell;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "SwiftHaskell/SwiftHaskell-Bridging-Header.h";
SWIFT_VERSION = 3.0;
USER_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/build $(PROJECT_DIR)/build/include";
}; };
name = Release; name = Release;
}; };
/* End XCBuildConfiguration section */ /* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */ /* Begin XCConfigurationList section */
BFABC4291E4BE794006036C6 /* Build configuration list for PBXProject "SwiftHaskell" */ = { BFABC4551E4C1DD1006036C6 /* Build configuration list for PBXProject "SwiftHaskell" */ = {
isa = XCConfigurationList; isa = XCConfigurationList;
buildConfigurations = ( buildConfigurations = (
BFABC4391E4BE794006036C6 /* Debug */, BFABC4611E4C1DD1006036C6 /* Debug */,
BFABC43A1E4BE794006036C6 /* Release */, BFABC4621E4C1DD1006036C6 /* Release */,
); );
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release; defaultConfigurationName = Release;
}; };
BFABC43B1E4BE794006036C6 /* Build configuration list for PBXNativeTarget "SwiftHaskell" */ = { BFABC4631E4C1DD1006036C6 /* Build configuration list for PBXNativeTarget "SwiftAppLibrary" */ = {
isa = XCConfigurationList; isa = XCConfigurationList;
buildConfigurations = ( buildConfigurations = (
BFABC43C1E4BE794006036C6 /* Debug */, BFABC4641E4C1DD1006036C6 /* Debug */,
BFABC43D1E4BE794006036C6 /* Release */, BFABC4651E4C1DD1006036C6 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
BFABC4E51E4D781D006036C6 /* Build configuration list for PBXNativeTarget "SwiftHaskell" */ = {
isa = XCConfigurationList;
buildConfigurations = (
BFABC4E61E4D781D006036C6 /* Debug */,
BFABC4E71E4D781D006036C6 /* Release */,
); );
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release; defaultConfigurationName = Release;
}; };
/* End XCConfigurationList section */ /* End XCConfigurationList section */
}; };
rootObject = BFABC4261E4BE794006036C6 /* Project object */; rootObject = BFABC4521E4C1DD1006036C6 /* Project object */;
} }
-34
View File
@@ -1,34 +0,0 @@
//
// AppDelegate.swift
// SwiftHaskell
//
// Created by NanoTech on 2017-02-08.
// Copyright © 2017 nanotech. All rights reserved.
//
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
@IBOutlet weak var label: NSTextField!
func applicationDidFinishLaunching(_ aNotification: Notification) {
var argv0 = Array("SwiftHaskell".utf8CString)
argv0.withUnsafeMutableBufferPointer { argv0bp in
var argv = [argv0bp.baseAddress];
var argc = CInt(argv.count)
argv.withUnsafeMutableBufferPointer { argvbp in
var argvp = argvbp.baseAddress
hs_init(&argc, &argvp)
}
}
label.stringValue = "\(square(5))"
}
func applicationWillTerminate(_ aNotification: Notification) {
hs_exit()
}
}
@@ -1,14 +0,0 @@
//
// SwiftHaskell-Bridging-Header.h
// SwiftHaskell
//
// Created by NanoTech on 2017-02-08.
// Copyright © 2017 nanotech. All rights reserved.
//
#ifndef SwiftHaskell_Bridging_Header_h
#define SwiftHaskell_Bridging_Header_h
#include "Lib_stub.h"
#endif /* SwiftHaskell_Bridging_Header_h */
+16
View File
@@ -0,0 +1,16 @@
#include "HsFFI.h"
#ifdef __cplusplus
extern "C" {
#endif
extern HsInt32 square(HsInt32 a1);
extern HsWord64 countBytes(HsWord8 a1, HsPtr a2, HsWord64 a3);
extern HsPtr getSequence(HsPtr a1);
extern void callbackExample(HsFunPtr a1);
extern void contextCallbackExample(HsPtr a1, HsFunPtr a2, HsFunPtr a3);
extern HsFunPtr makeMultiplier(HsInt32 a1);
extern void freeMultiplier(HsFunPtr a1);
extern HsInt32 Main_d9Dt(StgStablePtr the_stableptr, HsInt32 a1);
#ifdef __cplusplus
}
#endif
+4
View File
@@ -0,0 +1,4 @@
module SwiftHaskell {
header "Main_stub.h"
export *
}
+11 -7
View File
@@ -13,13 +13,17 @@ build-type: Simple
extra-source-files: extra-source-files:
cabal-version: >=1.10 cabal-version: >=1.10
library
hs-source-dirs: src
exposed-modules: Lib
ghc-options: -threaded -dynamic -shared -fPIC -o build/libswifthaskell.dylib
build-depends: base >= 4.7 && < 5
default-language: Haskell2010
source-repository head source-repository head
type: git type: git
location: https://github.com/nanotech/swift-haskell-tutorial location: https://github.com/nanotech/swift-haskell-tutorial
executable SwiftHaskell
default-language: Haskell2010
hs-source-dirs: src
main-is: Main.hs
ghc-options: -threaded -framework-path build
ld-options: -rpath @executable_path/../Frameworks
frameworks: SwiftAppLibrary
build-depends: base >= 4.7 && < 5
, bytestring >= 0.10 && < 0.11
, text >= 1.2 && < 1.3
Executable
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -eu
EXECUTABLE_NAME=SwiftHaskell
DIST_DIR="$(stack path --dist-dir)"
GHC_VERSION="$(stack exec -- ghc --numeric-version)"
GHC_LIB_DIR="$(stack path --compiler-bin)/../lib/ghc-$GHC_VERSION"
STUB_BUILD_DIR="${DIST_DIR}/build/${EXECUTABLE_NAME}/${EXECUTABLE_NAME}-tmp"
STUB_MODULE_DIR="${EXECUTABLE_NAME}/include"
STUB_MODULE_MAP="${STUB_MODULE_DIR}/module.modulemap"
# Create a module map from the generated Haskell
# FFI export headers for importing into Swift.
mkdir -p "${STUB_MODULE_DIR}"
NL="
"
module_map="module ${EXECUTABLE_NAME} {${NL}"
for h in $(find "${STUB_BUILD_DIR}" -name '*.h'); do
h_filename="${h/$STUB_BUILD_DIR\//}"
cp "$h" "${STUB_MODULE_DIR}/"
module_map="${module_map} header \"${h_filename}\"${NL}"
done
module_map="${module_map} export *${NL}"
module_map="${module_map}}"
echo "${module_map}" > "${STUB_MODULE_MAP}"
# Symlink to the current GHC's header directory from a more
# convenient place for Xcode to find.
mkdir -p build/ghc
ln -sf "${GHC_LIB_DIR}/include" build/ghc/
# Symlink to the Haskell executable for Xcode.
ln -sf "../${DIST_DIR}/build/${EXECUTABLE_NAME}/${EXECUTABLE_NAME}" build/
+106
View File
@@ -0,0 +1,106 @@
module Main where
import Control.Concurrent (forkIO)
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Unsafe as BU
import qualified Data.Text as T
import Data.Word (Word8)
import Foreign.C (CChar (CChar), CInt (CInt), CSize (CSize))
import Foreign.ForeignPtr (newForeignPtr, withForeignPtr)
import Foreign.Marshal.Array (copyArray, mallocArray)
import Foreign.Ptr (FunPtr, Ptr, freeHaskellFunPtr)
import Foreign.Storable (poke)
foreign export ccall square :: CInt -> CInt
square :: CInt -> CInt
square x = x * x
foreign import ccall "runNSApplication" runNSApplication :: IO ()
main :: IO ()
main = do
putStrLn "hello world"
runNSApplication
-- Examples
-- Swift to Haskell ByteString Example
foreign export ccall countBytes :: Word8 -> Ptr CChar -> CSize -> IO CSize
countBytes :: Word8 -> Ptr CChar -> CSize -> IO CSize
countBytes needle haystack haystackLen = do
s <- B.packCStringLen (haystack, fromIntegral haystackLen)
pure (B.foldl (\count b -> count + if b == needle then 1 else 0) 0 s)
-- Haskell to Swift ByteString Example
mallocCopyByteString :: ByteString -> IO (Ptr CChar, Int)
mallocCopyByteString s =
BU.unsafeUseAsCStringLen s $ \(p, n) -> do
a <- mallocArray n
copyArray a p n
pure (a, n)
foreign export ccall getSequence :: Ptr CSize -> IO (Ptr CChar)
getSequence :: Ptr CSize -> IO (Ptr CChar)
getSequence sizePtr = do
(p, n) <- mallocCopyByteString (B.pack [1..10])
poke sizePtr (fromIntegral n)
pure p
-- Swift to Haskell Callback Example
foreign export ccall callbackExample :: FunPtr (CInt -> IO ()) -> IO ()
foreign import ccall "dynamic" unwrapCallback :: FunPtr (CInt -> IO ()) -> (CInt -> IO ())
callbackExample :: FunPtr (CInt -> IO ()) -> IO ()
callbackExample f = (unwrapCallback f) 3
-- Swift to Haskell Callback with Context Example
foreign export ccall contextCallbackExample
:: Ptr ()
-> FunPtr (Ptr () -> IO ())
-> FunPtr (Ptr () -> CInt -> IO ())
-> IO ()
foreign import ccall "dynamic" unwrapContextCallback
:: FunPtr (Ptr () -> CInt -> IO ())
-> (Ptr () -> CInt -> IO ())
contextCallbackExample
:: Ptr () -- ^ Context pointer
-> FunPtr (Ptr () -> IO ()) -- ^ Context release function
-> FunPtr (Ptr () -> CInt -> IO ()) -- ^ Callback function
-> IO ()
contextCallbackExample ctxp releaseCtx callbackPtr = do
ctxfp <- newForeignPtr releaseCtx ctxp
let callback :: CInt -> IO ()
callback result = withForeignPtr ctxfp $ \ctxp' ->
(unwrapContextCallback callbackPtr) ctxp' result
_ <- forkIO $ do
let result = 3 -- perform your complex computation here
callback result
pure ()
-- Swift to Haskell Function Example
foreign export ccall makeMultiplier :: CInt -> IO (FunPtr (CInt -> CInt))
foreign import ccall "wrapper" wrapMultiplier
:: (CInt -> CInt)
-> IO (FunPtr (CInt -> CInt))
makeMultiplier :: CInt -> IO (FunPtr (CInt -> CInt))
makeMultiplier x = wrapMultiplier (x *)
foreign export ccall freeMultiplier :: FunPtr (CInt -> CInt) -> IO ()
freeMultiplier :: FunPtr (CInt -> CInt) -> IO ()
freeMultiplier = freeHaskellFunPtr
-12
View File
@@ -1,12 +0,0 @@
#!/bin/sh
set -eux
DIST_DIR="$(stack path --dist-dir)"
GHC_VERSION="$(stack exec -- ghc --numeric-version)"
GHC_LIB_DIR="$(stack path --compiler-bin)/../lib/ghc-$GHC_VERSION"
ln -sf ../"$DIST_DIR"/build/Lib_stub.h build/
ln -sf "$GHC_LIB_DIR"/include build/
ln -sf "$GHC_LIB_DIR"/rts/libHSrts_thr-ghc"$GHC_VERSION".dylib build/
ln -sf "$GHC_LIB_DIR"/rts/libffi.dylib build/
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB