Skip to content

Instantly share code, notes, and snippets.

@gistya
Last active January 13, 2016 07:28
Show Gist options
  • Save gistya/6292bc9f57e9c56469b1 to your computer and use it in GitHub Desktop.
Save gistya/6292bc9f57e9c56469b1 to your computer and use it in GitHub Desktop.
clangFoo! Makes -ObjC flag unnecessary by faking clang into linking classes from a j2objc static library your transpiled code wants to dynamically load but otherwise can't during runtime
/** by Jon Gilbert gistya at gmail **/
/** NoObjCLinkerFlag.h **/
#import <Foundation/Foundation.h>
/*!@description Call this function once from somewhere in your lib, and the compiler
will be tricked into loading the classes mentioned in clangFoo below. */
void preloadXalanDynamicLoads();
@interface NoObjCLinkerFlag:NSObject
@end
/** NoObjCLinkerFlag.m **/
#import "NoObjCLinkerFlag.h"
#import "org/apache/xalan/processor/TransformerFactoryImpl.h"
#import "org/apache/xml/serializer/ToXMLStream.h"
void preloadXalanDynamicLoads(){}
@implementation NoObjCLinkerFlag:NSObject
/*! @description This method never actually gets called. */
- (void)clangFoo {
OrgApacheXalanProcessorTransformerFactoryImpl_class_();
OrgApacheXmlSerializerToXMLStream_class_();
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment