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 ?

mcfly soft
  • 11,289
  • 26
  • 98
  • 202

1 Answers1

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.

tball
  • 1,984
  • 11
  • 21
  • 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 ? – mcfly soft Feb 12 '15 at 07:03
  • 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". – tball Feb 13 '15 at 15:14