0

I create a swift framework with objectiveC code which are translated by j2objc.

I have add java files to compile source, and use the following setting:

GENERATED_FILES_DIR = "${SRCROOT}/Generated";

HEADER_SEARCH_PATHS = "${J2OBJC_HOME}/frameworks/JRE.framework/Headers" "${GENERATED_FILES_DIR}" "${J2OBJC_HOME}/include" $(inherited);

LIBRARY_SEARCH_PATHS = ${J2OBJC_HOME}/lib;

OTHER_LDFLAGS = -ljre_emul

CLANG_ENABLE_OBJC_ARC = NO

and I got error:

include "J2ObjC_header.h" >> Include of non-modular header inside framework module 'XXXXX'

Then i do the following:

CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES

The error still exist.

I link 'JRE.framework' and set the HEADER_SEARCH_PATHS

The error still exist.

How to fix it?

Community
  • 1
  • 1
Leo
  • 835
  • 1
  • 12
  • 31

1 Answers1

0

You also want to set DEFINES_MODULE = NO;

Besides that, you don't need the "${J2OBJC_HOME}/include" in HEADER_SEARCH_PATHS and you can also remove LIBRARY_SEARCH_PATHS = ${J2OBJC_HOME}/lib; OTHER_LDFLAGS = -ljre_emul; since you are using the JRE framework now.

If you are translating the .java sources without the --no-package-directories flag and you want to preserve the directory structure, then you also want to do following:

  1. Add the generated files as a folder references in Xcode
  2. Remove them from Copy Bundle Resources phase
  3. Drop the folders in Public section of the Headers phase
  4. Add new Run Scrip phase to remove the .m files from Headers directory: find "$TARGET_BUILD_DIR/$PUBLIC_HEADERS_FOLDER_PATH" -name "*.m" -exec rm -f {} \;
  5. Now you can reference them in your umbrella header using #include <your-framework-name/path/to/header/Header.h>
CherryKuczery
  • 163
  • 2
  • 7