j2objc-gradle


Source link: https://github.com/j2objc-contrib/j2objc-gradle

Hey! We are looking for new developers to maintain the plugin. Let us know on j2objc-discuss if you are interested. Active development on this plugin is otherwise currently suspended.

J2ObjC Gradle Plugin

The J2ObjC Gradle plugin enables Java source to be part of an iOS application's build so you can write an app's non-UI code (such as application logic and data models) in Java, which is then shared by Android apps (natively Java) and iOS apps (using J2ObjC).

The plugin:

  • Translates your Java source code to Objective-C for iOS (iPhone/iPad) using J2ObjC, an open-source tool from Google
  • Builds Objective-C static libraries and headers ready-to-use in Xcode
  • Runs translated versions of your JUnit tests to ensure your code works in Objective-C form
  • Handles multiple Java projects, external Java libraries [1], and existing Objective-C code you'd like to link in
  • Configures Xcode projects to use your translated libraries, using CocoaPods (optionally)

The plugin is not affiliated with Google but was developed by former Google Engineers and others. Note that the plugin is currently in alpha; we may need to make breaking API changes before the 1.0 release.

Home Page: https://github.com/j2objc-contrib/j2objc-gradle

Quick Start Guide

You should start with a clean Java only project without any Android dependencies. It is suggested that the project is named shared. It must be buildable using the standard Gradle Java plugin. Starting with an empty project allows you to gradually shift over code from an existing Android application. This is beneficial for separation between the application model and user interface. It also allows the shared project to be easily used server-side as well.

The Android app, shared Java project and Xcode project should be sibling directories, i.e children of the same root level folder. Suggested folder names are 'android', 'shared' and 'ios' respectively. See the FAQ section on recommended folder structure.

Configure shared/build.gradle for your Java-only project:

// File: shared/build.gradle plugins {

  id 'java'
  id 'com.github.j2objccontrib.j2objcgradle' version '0.5.0-alpha' 
}
  dependencies {

  // Any libraries you depend on, like Guava or JUnit
  compile 'com.google.guava:guava:18.0'
  testCompile 'junit:junit:4.11' 
}
  // Plugin settings; put these at the bottom of the file. j2objcConfig {

  // Sets up libraries you depend on
  autoConfigureDeps true

 // Omit these two lines if you don't configure your Xcode project with CocoaPods
  xcodeProjectDir '../ios'  //  suggested directory name
  xcodeTargetsIos 'IOS-APP', 'IOS-APPTests'  // replace with your iOS targets

finalConfigure()

 // Must be last call to configuration 
}

Finally, make the Android application's android/build.gradle depend on the shared project:

// File: android/build.gradle dependencies {

  compile project(':shared') 
}

For more complex situations like:

, check the FAQ table of contents or see all of the j2objcConfig settings in J2objcConfig.groovy.

Minimum Requirements

The plugin requries modern versions of Gradle and J2ObjC, and assumes the J2ObjC Requirements:

  • Gradle 2.4
  • J2ObjC 0.9.8.2.1 or higher
  • JDK 1.7 or higher
  • Mac workstation or laptop
  • Mac OS X 10.9 or higher
  • Xcode 7 or higher

Applications built with the plugin may target

  • iOS 6.0 or higher
  • OS X 10.6 or higher

J2ObjC Installation

If J2ObjC is not detected when the plugin is first run, on-screen instructons will guide you through installation from your Terminal.

Alternatively: Download the latest version from the J2ObjC Releases. Find (or add) the local.properties in your root folder and add the path to the unzipped folder:

# File: local.properties j2objc.home=/J2OBJC_HOME

Build Commands

The plugin will output the generated source and libaries to the build/j2objcOutputs directory, run all unit tests, and configure your Xcode project (if you specified one).

It is integrated with Gradle's Java build plugin and may be run as follows:

./gradlew shared:build 

Problems

Having issues with the plugin? Please first check the Frequently Asked Questions.

Next, search the Issues for a similar problem. If your issue is not addressed, please file a new Issue, including the following details:

  • build.gradle file(s)
  • contents of Gradle build errors if any
  • version of J2ObjC you have installed

If you are not comfortable sharing these, the community may not be able to help as much. Please note your bug reports will be treated as "Contribution(s)" per the LICENSE.

Mozilla's Bug writing guidelines may be helpful. Having public, focused, and actionable Issues helps the maximum number of users and also lets the maximum number of people help you. Please do not email the authors directly.

FAQ

Please see FAQ.md.

Contributing

See CONTRIBUTING.md.

License

This library is distributed under the Apache 2.0 license found in the LICENSE file. J2ObjC and libraries distributed with J2ObjC are under their own licenses.

Footnotes

[1] where source is appropriately licensed and available

Resources

Juste a funcy button with progress bar.

Proteus is meant to be a drop-in replacement for Android’s LayoutInflater; but unlike the compiled XML layouts bundled in the APK, Proteus inflates layouts at runtime.

With Proteus, you can control your Apps layout from the backend (no WebViews). Forget the boilerplate code to findViewById, cast it to a TextView, and then setText(). Proteus has runtime data bindings and formatters. Plugin in your own custom views and attributes and formatters.

SmartDeviceLink (SDL) is a standard set of protocols and messages that connect applications on a smartphone to a vehicle head unit. This messaging enables a consumer to interact with their application using common in-vehicle interfaces such as a touch screen display, embedded voice recognition, steering wheel controls and various vehicle knobs and buttons. There are three main components that make up the SDL ecosystem.

Simple custom ImageView for android giving you a simple way to enable overlapping of two images one over the other.

OkHttp-Stats is an android library built on top of OkHttp3, which is responsible for intercepting all the network calls and for calculating network stats such as the average network speed of the user.

This is more of an analytical tool which can be used to track the success and error response logs.

Can be plugged in to any app which uses okhttp in their networking stack.

Example app to use Protobuf in Android using Square's Wire library.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes