Can I use the combination of both swift and objective c in react native custom module, IOS? - ios

Is it feasible to code some files in swift and some files in objective c while creating a custom module for IOS in react native. I need this because I know swift but I want to use already created code in objective c, while working on react native project?

Yes you can use both. You need to have a bridging header so that the the Swift code can access the Objective-C code
These tutorials show you how to create native components using swift
https://teabreak.e-spres-oh.com/swift-in-react-native-the-ultimate-guide-part-1-modules-9bb8d054db03
https://teabreak.e-spres-oh.com/swift-in-react-native-the-ultimate-guide-part-2-ui-components-907767123d9e
This tutorial shows you how to use Objective-C code in Swift and vice versa.
https://www.ios-blog.com/tutorials/objective-c/how-to-use-objective-c-classes-in-swift/

Related

Started React Native With Swift Instead Of Objective C

So I started a react native app using create-react-native-app and it created a lot of boilerplate code. Android is in JAVA which I am fine with. But the iOS is in Objective-C and I am more familiar with Swift. Is there anything I can do about that? I know most of my code is going to be in JavaScript anyways, but just wondering anyways.
Unfortunately, there is not a simple or one command way to convert your iOS code in your React Native project from Objective-C to Swift. However if you want to write a Native Module, which you'll need to eject from CRN or start a new project with react-native init, you can write new code in Swift.
You might also be interested in this post on how to bridge Swift and Objective-C code. Basically when you create a new swift file you need to make sure to select “Create Bridging Header” when prompted.
You're problem is not that clear. But lemme say this if you wanted to work on cross platform then react native is a good choice to that if you wanted to use javscript. Regarding on your question which is , lemme quote "But the IOS is in Objective C" which is you're wrong you can write an iOS native using both objective c , even c and c++ , ..and swift which you say your familiar with and if you're avoiding objective c then you can write iOS app purely in swift. Hope that helps.
Tips
1 for cross platform - and you want js (react native)
2. cross platform and you wanted to use c# (Xamarine)
3. iOS app which is native (Swift or objective c) or both
4. hybrid , you can try framework like ionic, cordova etc.
5. let us include android , you can use java(kotlin
You can convert swift to objective c or objective c to swift.
There are bunch of options for that, If you want to use javascript for converting than use obj2swift.js: https://github.com/okaxaki/objc2swift.
If you want to convert your code online than you can use online language converter like swiftify:
https://swiftify.com/#/converter/code/

DJI SDK - Sample tutorials in Swift

I was going through the DJI SDK and looking through the sample tutorials like TapFly and ActiveTrack Missions etc. but could only find the code in Objective C. Although they have mentioned that the code is available in Swift but I couldn't find it. Also, if it's only available in obj c, can I use the bridging header for the code using without making many changes in obj c while running my app coded in swift?
Everything in the MSDK-iOS is compatible with your Swift app

Importing TZStackView in an objective - c project

I am trying to use TZStackView due to limitations of UIStackView but since it's written in swift, I can't add it to my project which is Objective-c project. I've added swift class to objective-c projects before but this doesn't seem to work. I've copied TZStackView files to my project directory and got like hundreds of error messages. How do I use it ( I don't wanna use pods)?
Use the TZStackView v1.2.0, TZStackView v1.3.0 supports swift 3 it will works only in xcode8. for xcode7 use TZStackView v1.2.0.

Is it possible to write iPhone app in both objective c and swift

My existing iOS app is in objective c language and i want to add more functionality in my app and i want to do that code in swift language.
So is it possible to create an app which contains both the languages(i.e. in objective c & swift) and Is my app will work fine?
In short answer, Yes.
If you have existing project written in objective-c then you can add new classes written in swift. You still have choice if you want to use swift 3.0 ot swift 2.0.
You have to use bridge class in order to achieve that. You will get more guide on Link provided on Apple website.
https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html
However going forward it would make sense that you spend more time on Learning Swift as Apple is now leaning towards Swift 3.0.
Here is link quick guide.

Integrate Swift into an exported Unity project instead of using Objective C?

I am currently starting an iOS project and I want to use Unity as the primary drive for the project. Currently when you export Unity as an exported project, I am only given Objective-C.
How do I make a Unity based project using primarily Swift?
This seems extremely complicated as Objective-C can develop in top level and most of Unity is involved with the top level, how can I use Swift in this project? I am planning on using most of the Unity in Objective C and most of the front end GUI on Swift.
After a good couple of days hammering at this, it is possible. The main pitfalls was of course how the linking and the compilation process that Objective-C and Swift have to interact in order to do so:
Create an AppDelegate in Swift, subclassing UnityAppController and utilizing startUnity instead of Application(..)
Bridge between Swift and ObjectiveC using Unity's generated main.mm and the bridging headers
Create an Objective-C wrapper whose sole responsibility is to communicate between the Swift project and the Unity project
As follows here: https://apollowprogrammingblog.wordpress.com/2015/08/17/how-the-heck-do-you-integrate-swift-and-unity/
UPDATE July 11th 2016: There is also another guide, which I have since started using for my app development moving forward: https://github.com/blitzagency/ios-unity5. This is a different approach and also largely more maintainable due to the easily configurable unity.xcconfig (To get through most of the project config headaches) strat used here

Resources