ios - Linking to J2ObjC from another CocoaPod -


we use j2objc , trying make switch xcode 6's dynamic frameworks in order incorporate swift project. adding use_frameworks! our podfile works great in case we're just using j2objc, problem comes when adding other libraries reference it.

in particular example, have 2 pods in podfile, j2objc , other pod uses it. let's call whatever. current j2objc podspec can found here. here's podspec whatever:

pod::spec.new |s|   s.ios.deployment_target = '8.0'   s.requires_arc = true   s.source_files = '**/*.{h,m}'   s.dependency 'j2objc'   s.xcconfig = { 'header_search_paths' => '${pods_root}/j2objc/dist/include',   'library_search_paths' => '${pods_root}/j2objc/dist/lib' } end 

so far good. now, if want reference java class, javautilarraylist inside app, can that.

@implementation viewcontroller  - (void)viewdidload {     [super viewdidload];     javautilarraylist *arraylist = [[javautilarraylist alloc]init];     nsstring *whatever = @"o hai";     [arraylist addwithid:[whatever copy]];     nslog(@"%@", arraylist); } 

awesome, j2objc works inside main target. if try same thing inside whatever, though compiler thinks fine (j2objc imports work, classes available, etc.), linker error:

#import "someclass.h" #import "java/util/arraylist.h"  @implementation someclass    // inside 'whatever' -(javautilarraylist *)arraylist {     nsstring *athing = @"o hai";     javautilarraylist *mylist = [[javautilarraylist alloc]init];     [mylist addwithid:athing];     nslog(@"%@", mylist);     return mylist; } 

leads to:

undefined symbols architecture x86_64:   "_objc_class_$_javautilarraylist", referenced from:       objc-class-ref in someclass.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) 

i've been going crazy reading cocoapods guides, man ld, , j2objc guides , still not getting anywhere. has built pod on top of j2objc , installed using use_frameworks!? advice super appreciated.

any symbol begging "_objc_class" j2objc. if begins "_objc_class_$_java" it's java runtime environment (jre). if doesn't have "$_java" see this answer.

the linker missing out libjre_emul.a library j2objc (jre emulation library). need configure following:

  1. library_search_paths: j2objc_home/lib
  2. other_ldflags: -l"jre_emul"

i'd suggest trying out j2objc gradle plugin automatically configure you. alternatively, see xcode build rules.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -