react-native-workers icon indicating copy to clipboard operation
react-native-workers copied to clipboard

Setup Workers in Objective C iOS Project

Open kinnarshah opened this issue 7 years ago • 6 comments

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!

kinnarshah avatar May 22 '17 06:05 kinnarshah

+1

dorthwein avatar Jun 13 '17 22:06 dorthwein

The readme is outdated, you can use the following line:

[[RNWorkersManager sharedInstance] initWorkerWithPort:8082 bundleRoot:@"index.worker" fallbackResouce:@"worker"]

or just:

[[RNWorkersManager sharedInstance] initWorker]

fabriciovergara avatar Jun 14 '17 10:06 fabriciovergara

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) 

guns2410 avatar Jun 15 '17 09:06 guns2410

Figured out to be

// for RNWorkersManager.sharedInstance().start(with: rootView) 
[[RNWorkersManager sharedInstance] startWorkersWithRootView:rootView];

Thanks to Xcode autocomplete 😉

guns2410 avatar Jun 15 '17 10:06 guns2410

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?

Traviskn avatar Sep 07 '17 17:09 Traviskn

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

Traviskn avatar Sep 12 '17 21:09 Traviskn