YutoMizutani / SwiftPMExamples

Examples of Swift Package Manager; C, Cpp and ObjC linking examples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SwiftPMExamples

Examples of Swift Package Manager

Use Clang

Simple (automatically generated) modulemap

Targets

  • Simple (Swift) - CHello
  • CHello (Clang)
tree

.
├── Sources
│   ├── CHello
│   │   └── include
│   └── Simple
└── Tests
    └── SimpleTests

One of Clang package (CHello) linked another C static library (libhello/lib/libhello.a)

Targets

  • Staticlib (Swift) - CHello
  • CHello (Clang) - libhello (libhello.a)
  • libhello (Clang)
tree

.
├── Sources
│   ├── CHello
│   │   ├── include
│   │   └── src
│   ├── Staticlib
│   └── libhello
│       ├── bin
│       ├── example
│       ├── include
│       ├── lib
│       ├── src
│       └── tmp
└── Tests
    └── StaticlibTests

Use Cpp

Cpp called from extern linkage C header

Targets

  • CLinkage (Swift) - CppHello
  • CppHello (Cpp)
tree

.
├── Sources
│   ├── CLinkage
│   └── CppHello
│       └── include
└── Tests
    └── CLinkageTests

Use Objc

Targets

  • Simple (Swift) - ObjcHello
  • ObjcHello (Objc)
tree

.
├── Sources
│   ├── ObjcHello
│   │   └── include
│   └── Simple
└── Tests
    └── SimpleTests

Swift only

Targets

tree

.
├── Sources
│   └── GitHubLib
└── Tests
    └── GitHubLibTests

Targets

  • MultiLayer (Swift) - FooBar
  • FooBar (Swift)
tree

.
├── Sources
│   ├── FooBar
│   │   ├── Sources
│   │   │   ├── Bar
│   │   │   ├── Foo
│   │   │   └── FooBar
│   │   └── Tests
│   │       └── FooBarTests
│   └── MultiLayer
└── Tests
    └── MultiLayerTests

Targets

  • MultiModule (Swift) - Bar, Foo
  • Bar (Swift)
  • Foo (Swift)
tree

.
├── Sources
│   ├── Bar
│   ├── Foo
│   └── MultiModule
└── Tests
    └── MultiModuleTests

Targets

  • Simple (Swift)
tree

.
├── Sources
│   └── Simple
└── Tests
    └── SimpleTests

For Developers

Test

$ make test

Clean

$ make clean

About

Examples of Swift Package Manager; C, Cpp and ObjC linking examples


Languages

Language:Swift 87.6%Language:Makefile 6.4%Language:C 4.6%Language:Objective-C 0.7%Language:C++ 0.6%