How do I use Xcode for a C library wrapped in Swift


(Dave Yost) #1

I just posted this on StackOverflow <http://stackoverflow.com/questions/41290913/how-do-i-use-xcode-for-a-c-library-wrapped-in-swift>. Insights most welcome.

I'm trying to create an Xcode workspace that contains projects that make:

A bird dynamic library built from C source
A Cbird Swift module that wraps bird in raw Swift
A Bird Swift module that imports Cbird and wraps it in swifty Swift
A birdchirp Swift Command Line Tool that imports Bird
All of these must have an OS X Unit Testing Bundle.

I've tried various ways with various versions of Swift 3.x and snapshots to do this starting from Project.swift files and using swift package generate-xcodeproj. All of these attempts have resulted in Xcode setups that have various problems:

having to do a swift build first and then rooting an Xcode project in a directory deep within the .build directory (created by swift build) or within the (apparently now defunct) Packages directory
having to refer to other projects via github addresses
trouble with unit test bundles not finding Cbird
Selecting Cbird in an import Cbird source line and doing Jump to Definition fails to show the Swift source for Cbird.
The birdchirp project cheats and refers to Bird source files directly instead of depending on the Bird framework.
Extra credit:

Package.swift files that work with relative references to the other projects, while still allowing the projects to be mirrors of GitHub projects


(Ankit Agarwal) #2

This setup should do what you described:

<img src=’/uploads/default/original/1X/0a16b237752e60877d9ef445caff1341e2c6678d.png’ width=‘690’ height=‘237’>

···

On Fri, Dec 23, 2016 at 2:13 AM, Dave Yost via swift-users < swift-users@swift.org> wrote:

I just posted this on StackOverflow
<http://stackoverflow.com/questions/41290913/how-do-i-use-xcode-for-a-c-library-wrapped-in-swift>.
Insights most welcome.

I'm trying to create an Xcode workspace that contains projects that make:

   - A bird dynamic library built from C source
      - A Cbird Swift module that wraps bird in raw Swift
      - A Bird Swift module that imports Cbird and wraps it in swifty
      Swift
      - A birdchirp Swift Command Line Tool that imports Bird

All of these must have an OS X Unit Testing Bundle.

I've tried various ways with various versions of Swift 3.x and snapshots
to do this starting from Project.swift files and using swift package
generate-xcodeproj. All of these attempts have resulted in Xcode setups
that have various problems:

   - having to do a swift build first and then rooting an Xcode project
      in a directory deep within the .build directory (created by swift
      build) or within the (apparently now defunct) Packages directory
      - having to refer to other projects via github addresses
      - trouble with unit test bundles not finding Cbird
      - Selecting Cbird in an import Cbird source line and doing Jump to
      Definition fails to show the Swift source for Cbird.
      - The birdchirp project cheats and refers to Bird source files
      directly instead of depending on the Bird framework.

Extra credit:

   - Package.swift files that work with relative references to the other
      projects, while still allowing the projects to be mirrors of GitHub projects

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

--
Ankit