Giter VIP home page Giter VIP logo

masterdetail-j2objc-swift's Introduction

masterdetail-j2objc-swift

This sample project uses J2ObjC to share Java application logic between Android and iOS master-detail apps. For iOS, the Java code is translated into Objective-C. Those classes are then used in the app, which is coded in Swift.

The application logic implements the Model View ViewModel pattern (MVVM) to share UI logic between the Android and iOS implementations. Besides the view model, the application logic includes a model class and service for persisting the model.

There are three projects:

  • masterdetail-lib: The shared application logic as an Android Studio project
  • masterdetail-android: The Android project
  • masterdetail-ios: The iOS Xcode project

Building for iOS

  1. Install the latest release of J2ObjC
  2. Open the project masterdetail-lib in Android Studio. This step will ensure that certain project dependencies get initialized properly. In the future, it would be convenient for this step to be handled via the makefile (noted a few steps below).
  3. Open the Xcode project in masterdetail-ios/masterdetail-ios.xcodeproj
  4. Open the project settings in Xcode and navigate to Build Settings. In the User-Defined section, update J2OBJC_HOME to the location of your J2ObjC distribution. For example, if the distribution is two directories up from the Xcode project in a folder named j2objc-dist, it would have a value of ${SRCROOT}/../../j2objc-dist
  5. Open a Terminal session, navigate to the masterdetail-lib folder, and run make. This step is necessary as there appears to be a build order issue with Xcode in that it will attempt to compile Swift code before dependent code (i.e. the dependent Java code which is to be translated via a build rule). The makefile will translate all of the shared Java code to Objective-C.
  6. Back in Xcode, any Swift errors should be gone. Note that future edits to the Java code shouldn't result in compilation errors in the Swift code. Just be sure to make any Java changes prior to the Swift changes.
  7. Run the app on the simulator.

Building for Android

Open the masterdetail-j2objc-swift project in Android Studio. Run masterdetail-android as you would any Android app.

License

Apache License Version 2.0, January 2004

masterdetail-j2objc-swift's People

Contributors

kirkvogen avatar kpgalligan avatar

Stargazers

pbochenski avatar

Watchers

 avatar James Cloos avatar Wojciech Dziemianczyk 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.