Replies: 13 comments
-
First of all, I am a huge fan of Swift.
I am afraid, the reality is totally opposite.
🙄 Someone should tell them that's just wrong. What if I want to use two SDKs with same requirement? |
Beta Was this translation helpful? Give feedback.
-
I am not sure if there is any actionable work item from this. I am afraid that we may not be able to support this, and I am not aware of any plans to do this in the near future. Does it make sense to close this issue, and maybe re-open it is someone is interested in picking this up ? cc @hramos |
Beta Was this translation helpful? Give feedback.
-
(Personally I believe we can leave this open since the conversation of ‘moving to Swift’ comes up from time to time) |
Beta Was this translation helpful? Give feedback.
-
@shergin thanks for the feedback. I really wish I knew the native code better! FWIW: I have passed the feedback along to cisco/vmware and hopefully they will re-release their ObjC based SDK. |
Beta Was this translation helpful? Give feedback.
-
FWIW I have had great success both linking Swift libraries with RN and authoring new libraries in Swift. I don't think this requires changing the core code, and I've contributed tooling that might be relevant for @DaKaZ :
|
Beta Was this translation helpful? Give feedback.
-
@rhdeck wow - I wish I had found these and/or used them months ago - I slogged through converting my app to swift on my own and your I am curious about your thoughts for my implementation. As I said before, we are integrating the AirWatch SDK and it has a requirement to subclass it's delegate from the AppDelegate class. Am I right in thinking that the ONLY way I can support this is to first convert the AppDelegate to swift and then subclass it or is there another way that would work? I only ask because you clearly have a ton of experience here. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hit me with an issue on one of my repos (like RNSBase) so we don’t pollute
this more general purpose forum.
…On Tue, Jan 15, 2019 at 5:12 PM DaKaZ ***@***.***> wrote:
@rhdeck <https://github.com/rhdeck> wow - I wish I had found these and/or
used them months ago - I slogged through converting my app to swift on my
own and your react-native-swift-base would have done the job for me!
I am curious about your thoughts for my implementation. As I said before,
we are integrating the AirWatch SDK and it has a requirement to subclass
it's delegate from the AppDelegate class. Am I right in thinking that the
ONLY way I can support this is to first convert the AppDelegate to swift
and then subclass it or is there another way that would work? I only ask
because you clearly have a ton of experience here. Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#82 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALov_2Lh6rylB5bTz7tSrjSnySiizeEyks5vDlI5gaJpZM4Z3xw->
.
|
Beta Was this translation helpful? Give feedback.
-
What do folks think about at least allowing for an option to have the app delegate in Swift, as well as flipping the correct Xcode toggles to enable adding more Swift code in the future? As someone who has written a bunch of Swift and developed out a Swift-ish React Native app over the last two years, I believe this is something I could put a PR up for if folks were interested in it. The app delegate for a React Native app is fairly trivial (initializing the bridge, creating an RCTRootView, and slapping that root view onto a view controller, then the window). This could be accomplished with a second template, and an option in the react-native-cli to handle which template to install. The trickier part will be creating a bridging header and setting that in the xcodeproj, as well as setting the correct Swift config flags. This would be made a lot easier if we didn't use a hardcoded xcodeproj as the base and instead generated it on the fly using something like Buck/Bazel, What I don't think we should tackle as part of this discussion is enabling Swift-containing static libraries (while this should be easier with a Swift app delegate), or Swift-based view managers, etc. The resources @rhdeck linked to definitely help out with those things! |
Beta Was this translation helpful? Give feedback.
-
Related prior art: How |
Beta Was this translation helpful? Give feedback.
-
@eliperkins I was just recently introduced to @rhdeck 's react-native-swift-base which does exactly what you are proposing. If you add this package (and its peer deps) when you run |
Beta Was this translation helpful? Give feedback.
-
Oh neat! Sounds like a prime use-case for a |
Beta Was this translation helpful? Give feedback.
-
I think it's not a matter of what's better I already placed my thoughts on that here: react-native-community/cli#91 (comment) |
Beta Was this translation helpful? Give feedback.
-
The use cases for writing new code in Objective-C instead of Swift are slim to none nowadays. It could be a good boost for React-Native to be a bit more Swift / Kotlin minded. Swift now has a stable ABI and it is clear from this year’s WWDC that Objective-C is fading into the background. People that start off with a new React-Native project are dropped into Objective-C code. Not a great experience, that might scare off novice developers. Swift Packages support is another thing to consider. @rhdeck Thank you for that list of repositories! |
Beta Was this translation helpful? Give feedback.
-
Introduction
Hello, I have developing in ReactNative for over two years and have contributed to the core as well, I've seen the process and can only say THANK YOU to all who make this wonderful platform possible - its more then a full time job.
The purpose of this issue is to discuss the possibility of converting the core iOS app from Objective-C to Swift. I am not a native iOS developer nor do I have a lot of experience with ObjC nor Swift, but it seems to me that Swift can do everything ObjC can do and more, but ObjC cannot do what Swift can.
The Core of It
In my day job - I write cross platform apps for the government in ReactNative. We use AirWatch as an MDM have integrated the AirWatch SDK into our apps to provide security and management. Earlier in 2018, AirWatch stopped releasing ObjC code and only released their SDK in Swift. Since the SDK requires that we subclass AppDelegate from the Swift based AWControllerDelegate, I had to transform our app's main AppDelegate from ObjC to swift. ObjC does not support subclassing from swift (https://stackoverflow.com/questions/35244592/inherit-from-a-swift-class-in-objective-c)
Discussion points
I think there are several key discussion points we need to consider:
react-native eject
to output a swift app OR do we write scripts to convert the outputted app to swift?Once we've discussed this, I am happy to put together an initial PR that does the conversion and marshal through the code review / PR process, but I don't want to do this without a clear understanding of what the core team would find acceptable and advisable as this has the probability of being a large PR.
Reference
For reference, here is the AppDelegate.swift file that implements the AirWatch SDK in a minimal way (Note: this is only a minimal representation, in our real implementation I have a native-module bridge which provides information to/from the RN app and these stubbed functions):
Beta Was this translation helpful? Give feedback.
All reactions