Skip to content

Commit 4a6f94a

Browse files
committed
Add more clarification
1 parent 7f46097 commit 4a6f94a

6 files changed

+25
-14
lines changed

README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,13 @@ ln -sf "${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}" "${PROJECT_DIR}/build/"
235235

236236
Drag the `SwiftHaskell` executable we built previously with
237237
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,
239239

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)
241245

242246
When Xcode creates Swift frameworks, it expects that the
243247
application that links the framework will include the Swift
@@ -251,20 +255,24 @@ Standard Libraries** to **Yes**:
251255

252256
![Always Embed Swift Standard Libraries: Yes](tutorial/xcode-embed-swift-standard-libs.png)
253257

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:
259264

260265
![New Copy Files Phase](tutorial/xcode-new-copy-files-phase.png)
261266

262-
![Copy into Executables](tutorial/xcode-copy-files-swifthaskell-executable.png)
267+
![Select the executable](tutorial/xcode-choose-executable.png)
263268

269+
![Copy into Executables](tutorial/xcode-copy-files-swifthaskell-executable.png)
264270

265271
Build the SwiftAppLibrary framework in Xcode to prepare for the
266272
next sections.
267273

274+
![Select the SwiftAppLibrary target](tutorial/xcode-select-framework-target.png)
275+
268276
## Linking to the Framework
269277

270278
Add these options to the executable's section in the `.cabal`
@@ -360,13 +368,15 @@ from `MainMenu.xib`:
360368

361369
## Linking to the Executable
362370

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,
366375

367376
![The Swift module import paths](tutorial/xcode-swift-module-search-paths.png)
368377

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
370380
Header Search Paths** setting:
371381

372382
![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
382392
instead of at link time. Also note that the framework linking
383393
to symbols in the executable (and depending on the generated
384394
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
386396
will need to build the components in this order:
387397

388398
- `stack build` to generate the Haskell FFI export headers.
@@ -434,7 +444,8 @@ main = defaultMainWithHooks $ simpleUserHooks
434444
## Calling Haskell from Swift
435445

436446
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`:
438449

439450
```swift
440451
import SwiftHaskell

tutorial/xcode-add-to-no-targets.png

3.92 KB
Loading

tutorial/xcode-choose-executable.png

12.7 KB
Loading
11.9 KB
Loading
-6.4 KB
Binary file not shown.
9.74 KB
Loading

0 commit comments

Comments
 (0)