简体   繁体   中英

How can I get React Native to put JS bundle in Share Extension when compiling for Release?

I can load via jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"]; when developing, but using jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; in Extension doesn't work by default.

I can get the file from main app's bundle through getting parent directory of parent directory but prob. not the best way to ensure it works long-term...

Ok it's simple enough -- I just copied Bundle React Native code and images in Build Phases from app into Extension's Build Phases. It does double the work, so there's prob. a way to get it to reuse what it did before in the extension, but this works for me for now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM