3

I use J2Objc by Xcode build rules in Xcode(swift).

  1. Write a java file(People.java) 2.make settings for build rules, and add the custom script as the following:

    "${J2OBJC_HOME}/j2objc" -d ${DERIVED_FILES_DIR} -sourcepath "${PROJECT_DIR}/iOSApp-Swift" --no-package-directories -use-arc ${INPUT_FILE_PATH};

Note: i enable the ARC

  1. add the bridging-header file and import People.h file.
  2. call some function from People class in viewcontroller file.

When I build the project ,failed:'People.h not found'.

And When i build before importing and using the People.h, then implement to import People.h file and calling some function from People class in viewcontroller file, and build the project. It works.

I think the problem caused by J2objc not convert java file to .h/.m file before build the bridging-header file. Who knows how to fix it?

Thanks

0

1 Answer 1

1

You'll want to add People.java to your Xcode target's "Compile Sources" build phase. When that phase run, it will compile each file using either built-in rules for Objective C files, or your custom build rule for Java files.

Sign up to request clarification or add additional context in comments.

2 Comments

The file has been in 'Compile Sources'.
If you add a .java file to Compile Sources, then there needs to be a Build Rule that invokes j2objc (otherwise Xcode doesn't know how to build that file, and ignores it). Otherwise, add the People.m file generated by j2objc to Compile Sources.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.