Coder Social home page Coder Social logo

dinneo / swift-package-manager-ios Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joshchngs/swift-package-manager-ios

0.0 2.0 0.0 34 KB

Example of how to use SPM v4 to manage iOS dependencies

License: MIT License

Swift 80.61% Ruby 19.39%

swift-package-manager-ios's Introduction

Swift Package Manager with iOS

This project demonstrates a working method for using Swift Package Manager (SPM) to manage the dependencies of an iOS project. It has been tested with Xcode 9.1, using Swift 4 and the SPM v4 description format.

Note: At this time there is no official support for iOS targets or the related system libraries in SPM.

To get started:

  1. Install the xcodeproj ruby library: sudo gem install xcodeproj

  2. Run ruby generate-project-dependencies.rb in the project root directory. This will pull down dependencies as defined in Package.swift and then generate and modify a Dependencies project which is then included as a sub-project by the example project.

  3. Open SwiftPackagesWithiOS.xcodeproj in Xcode

  4. Build the main target (you may need to manually build the target for the Dependencies sub-project).

This will build a simple app that depends on RxSwift. RxSwift was chosen because it shows how to handle modules generated from Objective-C.

The end result will be a standard iOS application, with Static Frameworks for each of its dependencies embedded within the bundle.

You can link the dependencies dynamically if you prefer, by removing the config.build_settings['MACH_O_TYPE'] = 'staticlib' line in generate-project-dependencies.rb. If you do this you will need to embed the dependencies in your main app target.

You can step through the commits to see what steps were taken, with a brief overview of the process below.

Process:

(This process hasn't been tested with Xcode 8.3 & Swift 3.1)

  1. Generate iOS App project with Xcode
  2. Generate swift package for Dependencies
  3. Create dummy source file for Dependencies (I've chosen to put this in .deps-sources but does not necessarily need to be hidden)
  4. Modify build settings in generated xcodeproj (this is done in generate-project-dependencies.rb)
  5. Add Dependencies.xcodeproj as subproject of the main app xcodeproj
  6. Add a dependency (to RxSwift in this example) in Package.swift
  7. Link our App with the new Rx*.frameworks
  8. Write some sample code to verify that the import works
  9. Override MODULEMAP_FILE setting for non-Swift modules

swift-package-manager-ios's People

Contributors

joshchngs avatar benlachman avatar thomasburguiere avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.