@@ -235,9 +235,13 @@ ln -sf "${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}" "${PROJECT_DIR}/build/"
235
235
236
236
Drag the ` SwiftHaskell ` executable we built previously with
237
237
Stack into Xcode from the ` build/ ` directory that we symlinked
238
- it into, but do not add it to any targets when prompted:
238
+ it into,
239
239
240
- ![ The SwiftHaskell executable in Xcode] ( tutorial/xcode-files-swifthaskell-executable.png )
240
+ ![ The SwiftHaskell executable in Xcode] ( tutorial/xcode-drag-swifthaskell-executable.png )
241
+
242
+ but do not add it to any targets when prompted:
243
+
244
+ ![ Do not add the executable to any targets] ( tutorial/xcode-add-to-no-targets.png )
241
245
242
246
When Xcode creates Swift frameworks, it expects that the
243
247
application that links the framework will include the Swift
@@ -251,20 +255,24 @@ Standard Libraries** to **Yes**:
251
255
252
256
![ Always Embed Swift Standard Libraries: Yes] ( tutorial/xcode-embed-swift-standard-libs.png )
253
257
254
- In the SwiftHaskell app target's Build Phases, remove the
255
- ** Compile Sources** and ** Link Binary With Libraries**
256
- phases, and add a new ** Copy Files** phase that copies the
257
- ` SwiftHaskell ` executable into the app bundle's Executables
258
- directory:
258
+ In the app target's Build Phases, remove the ** Compile Sources**
259
+ and ** Link Binary With Libraries** phases. We are using Stack to
260
+ build the app's executable instead of Xcode.
261
+
262
+ Add a new ** Copy Files** phase that copies the ` SwiftHaskell `
263
+ executable into the app bundle's Executables directory:
259
264
260
265
![ New Copy Files Phase] ( tutorial/xcode-new-copy-files-phase.png )
261
266
262
- ![ Copy into Executables ] ( tutorial/xcode-copy-files-swifthaskell -executable.png )
267
+ ![ Select the executable ] ( tutorial/xcode-choose -executable.png )
263
268
269
+ ![ Copy into Executables] ( tutorial/xcode-copy-files-swifthaskell-executable.png )
264
270
265
271
Build the SwiftAppLibrary framework in Xcode to prepare for the
266
272
next sections.
267
273
274
+ ![ Select the SwiftAppLibrary target] ( tutorial/xcode-select-framework-target.png )
275
+
268
276
## Linking to the Framework
269
277
270
278
Add these options to the executable's section in the ` .cabal `
@@ -360,13 +368,15 @@ from `MainMenu.xib`:
360
368
361
369
## Linking to the Executable
362
370
363
- Add ` $(PROJECT_DIR)/SwiftHaskell/include ` to the framework
364
- target's ** Swift Compiler - Search Paths, Import Paths** setting
365
- in Xcode,
371
+ To tell Xcode where to find our ` module.modulemap ` , add
372
+ ` $(PROJECT_DIR)/SwiftHaskell/include ` to the framework target's
373
+ ** Swift Compiler - Search Paths, Import Paths** setting in
374
+ Xcode,
366
375
367
376
![ The Swift module import paths] ( tutorial/xcode-swift-module-search-paths.png )
368
377
369
- and ` $(PROJECT_DIR)/build/ghc/include ` to the framework's ** User
378
+ and, for the GHC headers the module depends on, add
379
+ ` $(PROJECT_DIR)/build/ghc/include ` to the framework's ** User
370
380
Header Search Paths** setting:
371
381
372
382
![ The User Header Search Paths] ( tutorial/xcode-header-search-paths.png )
@@ -382,7 +392,7 @@ Be aware that this means that link errors will occur at runtime
382
392
instead of at link time. Also note that the framework linking
383
393
to symbols in the executable (and depending on the generated
384
394
headers), and the executable linking to the framework, creates
385
- a circular dependency. When initially building the project, you
395
+ a circular dependency. When building the project clean , you
386
396
will need to build the components in this order:
387
397
388
398
- ` stack build ` to generate the Haskell FFI export headers.
@@ -434,7 +444,8 @@ main = defaultMainWithHooks $ simpleUserHooks
434
444
## Calling Haskell from Swift
435
445
436
446
We're now ready to use exported Haskell functions from Swift.
437
- Import ` SwiftHaskell ` at the top of ` AppDelegate.swift `
447
+ Import the module we defined in our ` module.modulemap ` ,
448
+ ` SwiftHaskell ` , at the top of ` AppDelegate.swift ` :
438
449
439
450
``` swift
440
451
import SwiftHaskell
0 commit comments