react-native-workers
react-native-workers copied to clipboard
Setup Workers in Objective C iOS Project
Hi Fabricio, Thanks for the useful library - we have integrated it successfully in our production app for Android but are facing a syntactical issue on iOS.
Can anyone please convert the following set-up code to Objective C?
RNWorkersManager.sharedInstance().initWorker(withBundleRoot: "index.worker", fallbackResouce: "worker", moduleName: "rnapp")
Our team has very little experience with iOS and any help is appreciated.
Thanks!
+1
The readme is outdated, you can use the following line:
[[RNWorkersManager sharedInstance] initWorkerWithPort:8082 bundleRoot:@"index.worker" fallbackResouce:@"worker"]
or just:
[[RNWorkersManager sharedInstance] initWorker]
Hey @fabriciovergal can you also help with an objective c equivalent of these as well please
RNWorkersManager.sharedInstance().simulationEnabled = true
RNWorkersManager.sharedInstance().start(with: rootView)
Figured out to be
// for RNWorkersManager.sharedInstance().start(with: rootView)
[[RNWorkersManager sharedInstance] startWorkersWithRootView:rootView];
Thanks to Xcode autocomplete 😉
I'm having some trouble importing the RNWorkersManager in my AppDelegate.m
file. Adding this to the list of imports: #import "RNWorkersManager.h"
gives an error RNWorkersManager.h file not found
. I've already run react-native link rn-workers
and confirmed that RNWorkers.xcodeproj is in my Libraries and that libRNWorkers.a
is in my projects Build Phases > Link Binary With Libraries config. Can anyone share how they have imported RNWorkersManager to use in their AppDelegate.m
file?
I should probably mention that I was running into the above issue while trying to use this library in a create-react-native-app, ejected with ExpoKit. I think that perhaps the cocoa pods dependency management was messing me up, because when moving to a vanilla react-native project I have no issues