Adding the JreEmulation Project to Your Xcode Project
Stay organized with collections
Save and categorize content based on your preferences.
J2ObjC's JRE emulation library can be built using Xcode, and can be included as a sub-project in your Xcode projects. This allows you to control the settings used to build that library so it can best be used by your projects.
Download the Source Code
Either:
- Download and upzip the current source bundle into a local directory; or
- Clone the source code tree using git. The advantage of a local source check out is that it's easier to stay current with the latest J2ObjC project changes, but it does require some knowledge of version control systems.
The source code can go anywhere on your local system. For the purposes of this document we'll use /usr/local/src/j2objc
, but change that path as you prefer.
Xcode's command-line tools and Apache Maven need to be installed to build J2ObjC. Here are some tips:
These are Google searches instead of static pages, because installation can often change with new Mac OS X and Xcode versions.
Build the Project
Follow the Building J2ObjC steps. Command-line builds are optional, but easier to debug than when invoked inside Xcode.
When debugging the JRE, it is recommended to add the following lines at the top
of the jre_emul/environment.mk before
running a clean build:
DEBUGGING_SYMBOLS=YES
OPTIMIZATION_LEVEL=0
The JreEmulation Xcode project
In Xcode, open /usr/local/src/j2objc/jre_emul/JreEmulation.xcodeproj
. Its folders include:
- Classes: the set of core JRE emulation classes, which are not created by translating Java source files.
- jre_emul_tests: the set of unit tests which are built and run within Xcode. These do not include the translated JUnit tests, which are built and run from the command-line using
make test
in the jre_emul
directory.
- Transpiled Classes: these are the files created by translating the JRE library's Java source files. Notes:
- Xcode marks missing files in red. Because these files are created during the build, they will initially all be red until the project is built.
- We're adding new classes regularly to the JRE emulation library, so this list may be out of date. If so, right-click on this folder, click "Add Files to JreEmulation.xcodeproj", and add new
.m
and .h
files from jre_emul/build_result/Classes
and its sub-directories.
To build the JreEmulation project, select the jre_emul
target and click Xcode's Run button. To build and run the unit tests, click on the down arrow next to the Run button and select Test.
Add the JreEmulation project to your project
- In the Project Naviagator panel on the left, right-click on your project and select "Add Files to Project Name".
- Find the
jre_emul/JreEmulation.xcodeproj
file and click the Add button.
- Click your project and select its main target, then select the target's Build Phases tab.
- Open the Target Dependencies section, click the + button, and select the
jre_emul
target.
- Open the Link Binary With Libraries section, click the + button, and select
libjre_emul.a
.
- Select the target's Build Settings tab, find Header Search Paths, and add the path to the
/usr/local/src/j2objc/dist/include
directory (substituting the actual location).
Now when your project is built, the JreEmulation project is built as needed.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eJ2ObjC's JRE emulation library can be built and included as an Xcode sub-project, offering control over build settings.\u003c/p\u003e\n"],["\u003cp\u003eBuilding J2ObjC requires Xcode command-line tools and Apache Maven to be installed.\u003c/p\u003e\n"],["\u003cp\u003eThe JreEmulation Xcode project includes core classes, unit tests, and transpiled classes from the JRE library.\u003c/p\u003e\n"],["\u003cp\u003eAdding the JreEmulation project to your project involves adding it as a dependency and linking it with your target.\u003c/p\u003e\n"]]],["J2ObjC's JRE emulation library can be integrated into Xcode projects as a sub-project. Begin by downloading the source code and installing Xcode command-line tools and Maven. Build the project using the provided steps. To use the JRE in Xcode, open the `JreEmulation.xcodeproj`, including its core classes and unit tests. Add the `JreEmulation.xcodeproj` file to your project, link the `jre_emul` target, add the `libjre_emul.a` library, and specify the header search path.\n"],null,["# Adding the JreEmulation Project to Your Xcode Project\n\nJ2ObjC's JRE emulation library can be built using Xcode, and can be included as a sub-project in your Xcode projects. This allows you to control the settings used to build that library so it can best be used by your projects.\n\n### Download the Source Code\n\nEither:\n- Download and upzip the [current source bundle](https://github.com/google/j2objc/archive/master.zip) into a local directory; or\n- Clone the [source code tree](https://github.com/google/j2objc) using [git](http://git-scm.com/). The advantage of a local source check out is that it's easier to stay current with the latest J2ObjC project changes, but it does require some knowledge of version control systems.\n\nThe source code can go anywhere on your local system. For the purposes of this document we'll use `/usr/local/src/j2objc`, but change that path as you prefer.\n\n### Install Build Tools\n\nXcode's command-line tools and Apache Maven need to be installed to build J2ObjC. Here are some tips:\n\n- [Install Xcode command-line tools](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=xcode%20command%20line%20tools)\n- [Install Maven on Mac](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=how%20to%20install%20maven%20on%20mac)\n\nThese are Google searches instead of static pages, because installation can often change with new Mac OS X and Xcode versions.\n\n### Build the Project\n\nFollow the [Building J2ObjC](/j2objc/guides/building-j2objc) steps. Command-line builds are optional, but easier to debug than when invoked inside Xcode.\n\nWhen debugging the JRE, it is recommended to add the following lines at the top\nof the [jre_emul/environment.mk](https://github.com/google/j2objc/blob/master/jre_emul/environment.mk) before\nrunning a clean build: \n\n DEBUGGING_SYMBOLS=YES\n OPTIMIZATION_LEVEL=0\n\n### The JreEmulation Xcode project\n\nIn Xcode, open `/usr/local/src/j2objc/jre_emul/JreEmulation.xcodeproj`. Its folders include:\n\n- **Classes**: the set of core JRE emulation classes, which are not created by translating Java source files.\n- **jre_emul_tests** : the set of unit tests which are built and run within Xcode. These do not include the translated JUnit tests, which are built and run from the command-line using `make test` in the `jre_emul` directory.\n- **Transpiled Classes**: these are the files created by translating the JRE library's Java source files. Notes:\n- Xcode marks missing files in red. Because these files are created during the build, they will initially all be red until the project is built.\n- We're adding new classes regularly to the JRE emulation library, so this list may be out of date. If so, right-click on this folder, click \"Add Files to JreEmulation.xcodeproj\", and add new `.m` and `.h` files from `jre_emul/build_result/Classes` and its sub-directories.\n\nTo build the JreEmulation project, select the `jre_emul` target and click Xcode's **Run** button. To build and run the unit tests, click on the down arrow next to the **Run** button and select **Test**.\n\n### Add the JreEmulation project to your project\n\n- In the Project Naviagator panel on the left, right-click on your project and select \"Add Files to *Project Name*\".\n- Find the `jre_emul/JreEmulation.xcodeproj` file and click the **Add** button.\n- Click your project and select its main target, then select the target's Build Phases tab.\n- Open the Target Dependencies section, click the **+** button, and select the `jre_emul` target.\n- Open the Link Binary With Libraries section, click the **+** button, and select `libjre_emul.a`.\n- Select the target's Build Settings tab, find Header Search Paths, and add the path to the `/usr/local/src/j2objc/dist/include` directory (substituting the actual location).\n\nNow when your project is built, the JreEmulation project is built as needed."]]