2

I am using j2objc.

I have 2 classes:

  • LabelPosition.java

  • Event.java

In Event I have references to LabelPostion

I could translate the standalone Class Labelposition without problems. Packagestructure and the File .h & -m are created.

Now I try to translate the Event.java, which has references to LabelPosition as follow:

./j2objc --verbose -d objective-c -sourcepath . Event.java

I get errors:

error: Event.java:79: LabelPosition cannot be resolved to a type
error: Event.java:79: LabelPosition cannot be resolved to a type
error: Event.java:284: LabelPosition cannot be resolved to a type
error: Event.java:285: LabelPosition cannot be resolved to a type
error: Event.java:287: LabelPosition cannot be resolved to a type
error: Event.java:288: LabelPosition cannot be resolved to a type

Following screens shows my Folderstructur: enter image description here

What am I doing wrong ?

1 Answer 1

1

Xcode can't handle headers in sub-directories -- everything has to be in the same directory. This is easy to fix: add the --no-package-directories flag and rebuild everything.

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

2 Comments

i just added the --no-package-directories to my existing command, but I got the same error again. You mentoined it has to be all in the same folder. That do you mean with all regarding my folderstructur in the screenshot ? -> "Events.ava" and "LabelPositon.java" are in the same folder as the command j2objc. Anything else to do ?
Sorry, I thought you were building in Xcode. Does "javac -d objective-c -sourcepath . Event.java" succeed? j2objc's front-end is a Java compiler, and it needs the same paths that javac does. My guess is that one or both of these sources have a package statement, and so should be in sub-directories that match that statement. For example, if LabelPosition has "package foo.bar;" then the source needs to be in foo/bar/LabelPosition.java. In any event, the general trick is to first define a javac command that works, then change "javac" to "j2objc".

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.