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 support for exporting Swift modules #982

Closed
wants to merge 2 commits into from
Closed

Add support for exporting Swift modules #982

wants to merge 2 commits into from

Conversation

robertjpayne
Copy link
Contributor

External modules are any Objective-C class in which the implementation is private. This currently will be most useful for Swift classes but also has potential to allow exposing methods on 3rd party libraries to the bridge.

External modules are any Objective-C class in which the implementation is private. This currently will be most useful for Swift classes but also has potential to allow exposing methods on 3rd party libraries to the bridge.
@robertjpayne
Copy link
Contributor Author

@nicklockwood in reference to #207. I was adding some tests but can't add Swift files to the project because it's a static lib. Any recommendations on how to best write tests? Maybe just an external Objective-C module?

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 23, 2015
@nicklockwood
Copy link
Contributor

@robertjpayne I have some work to do in order to support this.

Because of the data segment registration mechanism, right now, even if you pass a module in explicitly via the moduleProvider block, it won't work if the class is defined outside the main binary because it can't pick up the metadata. That's why the RCTTest module must be included in the app target right now instead of just the test target.

Shouldn't be too hard to fix this though.

@robertjpayne
Copy link
Contributor Author

@nicklockwood yeah, I managed to kind of hack a small test together with Objective-C but it does't really validate much other than the fact the small macro works. Testing Swift integration is much more key as it's way more likely to break.

Let me know if I can help with anything else.

@vjeux
Copy link
Contributor

vjeux commented Apr 25, 2015

Awesome! Would be nice to update the documentation to explain how to use it :)

http://facebook.github.io/react-native/docs/nativemodulesios.html#content

@robertjpayne
Copy link
Contributor Author

@vjeux ok, I'll get the docs going for NativeModules, I missed getting Native UI Components via Swift support which would be awesome too.

@robertjpayne
Copy link
Contributor Author

@vjeux documentation added via #1021. It's brief but gets it done and the Objective-C documentation is still very relevant.

@kristianmandrup
Copy link

Most of the RN docs still seem very old school, using Objective C and ES5 syntax for most examples...
I couldn't find a Swift example in the official docs.

@tirrorex
Copy link

tirrorex commented Nov 3, 2017

It's been a year and a half and things haven't changed documentation side, that's a bummer.

ayushjainrksh pushed a commit to MLH-Fellowship/react-native that referenced this pull request Jul 2, 2020
update ActivityIndicator.md
dannyvv pushed a commit to dannyvv/react-native that referenced this pull request Feb 10, 2022
mganandraj pushed a commit to mganandraj/react-native that referenced this pull request Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants