2

How to add the j2objc generated .o files in xcode?

I'm having Apple Mach-O Linker Errors when compile with Xcode.

my .h file has added to Xcode in build setting/header search paths/{my .m files destination}

kaneyip
  • 1,237
  • 1
  • 17
  • 21

2 Answers2

1

I've never needed to add .o files. When a j2objc build rule is used, just add the Java source files to the project and they are automatically built with the project (here is a sample project). Otherwise, add the translated .m and .h files to the project. In either case, the translated .m files are compiled using the same compilation flags as the rest of your project.

I find it easiest to add a "Transpiled Classes" group to the project (right-click on the project, select "New Group"), then right-click on the new group and select "Add Files to ". Select the translated files (use click and shift-click to add them in bulk), and select the target where they should be added.

tball
  • 1,984
  • 11
  • 21
0

You need to setting about path finding and link to binary

  • Path setting: with .o files go to Build Settings-> Search Path-> Library Search Paths and add path (relative path) of directory content .o files.
  • Link Binary: go to Build Phases-> Link Binary With Libraries-> +(add new)-> [Add Other...] and add lib.a to here

Done it should work. Some time U need add '-ObjC' in Other Linker Flags too

larva
  • 4,687
  • 1
  • 24
  • 44
  • i need to generate the library .a file too? Can't i link the external .o files only? – kaneyip Oct 14 '14 at 04:50
  • try do it with .o, <.o> is the same with <.a>. <.o> file content binary code of one class and <.a> is can content more than one – larva Oct 14 '14 at 04:56
  • Still the same error Apple Mach-O Linker error with <.o> file added to link binary with library – kaneyip Oct 14 '14 at 05:02
  • I can resolve the apple mach-o linker error with static lib method or include the header files and then add the .m files manually into Xcode using drag and drop or with add button. But is that any other ways i can link to the external .m or .o files without manually add them into Xcode – kaneyip Oct 14 '14 at 05:20