Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add --swift language option #353

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

add --swift language option #353

wants to merge 7 commits into from

Conversation

brodycj
Copy link
Owner

@brodycj brodycj commented May 11, 2020

  • add --swift CLI option
  • add swift option to library API (not documented at this point)
  • update iOS template to generate native module with Swift language implementation, if --swift option is enabled
  • update CLI test snapshots

resolves #221

only tested with React Native 0.62 at this point

I would like to give thanks to the following resources for some extremely helpful guidance for a Swift beginner like myself:

and some other interesting resources I found:

TODO items:

  • resolve an ugly "main queue setup" warning message from the Metro bundler
  • add test cases with swift option enabled
  • support native view with Swift language option
  • explicitly reject combination of Swift & Apple Networking options
  • test with tvOS
  • test with other supported React Native versions (0.60, 0.61, 0.63-rc)
  • use Stryker Mutator to check for any missing test cases
  • add documentation

/cc @dlowder-salesforce

@shaikhaffan
Copy link

Hi when are you planning to merge this changes?

@brodycj
Copy link
Owner Author

brodycj commented Jul 7, 2021

I will try to finish and merge this in the near future.

Copy link
Owner Author

@brodycj brodycj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A static requiresMainQueueSetup method or some other solution is needed to help avoid an ugly message like this:

Module AwesomeNativeModule requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.

ref:

I think the next step would be to understand why we need to specify this queue setup for Swift but not for Objective-C.

I would also like to see some documentation here: https://reactnative.dev/docs/native-modules-ios#exporting-swift

@fatlinesofcode
Copy link

ive been using this via npx brodybits/create-react-native-module#add-swift-option react-native-swift-module --swift --generate-example and works pretty well, i think you should merge it

adding

  static func requiresMainQueueSetup() -> Bool {
    return true
  }

to the Swift file

resolved the requiresMainQueueSetup issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How can we use swift instead of objective Objective-C ?
3 participants