敏捷大拇指 首页 资讯 查看内容

居然可以用Swift来开发Android应用!!!

快来登录
获取优质的苹果资讯内容
收藏热门的iOS等技术干货
拷贝下载Swift Demo源代码
订阅梳理好了的知识点专辑


哈哈,爆炸性新闻!

Swift居然可以用来开发Android应用!!!

这下学了一门语言,就可以开发两种客户端,找工作起来是不是更香饽饽了?

RemObjects 公司利用自己编译器的开发经验,推出了全新 Silver 项目。Silver 允许开发者使用苹果 Swift 编程语言进行 Android 开发。此前这家公司曾经对 C#编程语言推出过相似的项目。现在,RemObjects 又看中了 Swift。Silver 允许应用开发者使用 Swift 编程语言,为非苹果平台框架编写应用。

软件并没有将 Cocoa Touch 移植到 Android,所以并不能编写一次代码,在所有平台上运行。不过,Silver 允许开发团队使用一种语言为 iOS 和 Android 平台编写原生应用。此外,团队也支持.NET,这意味着 Swift 也可以编写 Windows Phone 应用。

欢迎注册Swifthumb.com 敏捷大拇指全球最早也是最大的Swift开发者社区!




2016年4月最近新动向:

Google Android或采纳苹果的Swift编程语言



2016年WWDC新动向:

Swift之父Chris宣布Swift支持如上所有平台。

从Android到Swift iOS开发:语言与框架对比



Swift语言的应用领域进军路线图:



淘帖专辑

全球最大的Swift开发者社区敏捷大拇指 Swifthumb.com整理的淘帖:

  1. Swift开发安卓Android App
  2. Swift Linux Server服务后端
  3. Swift开发微软Windows .Net
  4. Swift和其它语言对比
  5. 开源Swift Open Source
  6. Swift 3
  7. Swift游戏开发
  8. Swift源代码 App/后台/OS
  9. Swift 高仿App源代码库
  10. Swift笔试面试题库宝典
  11. 第三方库SDK
  12. 软件工具
  13. LLVM编译器
  14. Xcode使用技巧
  15. App市场推广下载
  16. Growth Hack 黑客增长



外文资料:


How to Use Apple Swift to Make an Android App


Since WWDC (The Apple Worldwide Developers Conference) and Apple’s announcement of Swift, I’ve become increasingly impressed with the new language. For iOS developers, it’s a no-brainer to use Swift instead of Objective-C. Writing code is easier and faster than ever with Swift, making you more productive. And being able to write code and test it more efficiently will ultimately save developers like us time and cost.

Can You Use Apple Swift To Create Cross-Platform Apps?

The obvious benefits of Swift got me thinking: Could you use Swift to create an Android app? And, could you use Swift to write an app once for iOS and Android at the same time?

At ArcTouch, our clients regularly ask us to create both the iOS and Android version of their app. Where possible (and a good fit for the type of app), we like to use a unified code-base to bring cross-platform apps to market faster. We’ve had great success to date using Xamarin and HTML5, and if we can do the same with Swift, we’d have another great option for our customers.

After WWDC, we created a skunkworks team (led by two of our app developers, Diego Santiviago and Felipe Homma) to try building a simple app that works on both iOS and Android, written in Swift. And we succeeded with a proof-of-concept calculator app. Here’s how we did it.


Picking an IDE to Start

The first challenge was to determine which IDE (independent development environment) to use. We didn’t want to build one from scratch. And we couldn’t plug Swift code directly into Android Studio. So we started with Xcode 6. We think the best approach for a future commercial solution is to build a compiler for Swift code that you’d plug into Xcode, and that compiler would translate Swift into ready-to-run Java byte-code and an Android Package (APK) ready to install.

For the sake of our proof of concept, we took a shortcut.

Compiling to Java Source Code from Swift

Our best course of action to get something working quickly was to take Swift code and compile it into Java source code — and then take it into the Android development environment to finish building it into an installable app. So we started in Xcode, where we wrote the Swift code. Then we tested it, including running it on an iPhone or in the iPhone Simulator, and ran a custom compiler that parsed the Swift code and output Java source code (adjusting any necessary syntax, and substituting appropriate Android calls for any iOS native ones). Then we moved it into Android Studio to finish the build process and produced the Android APK.

The downside of using this approach: You need both Xcode and Android Studio on your desktop, along with our tool chain to get from one to the other. But you still see a tremendous efficiency gain by being able to use the same base code — and you get the overall benefits of using Swift.

Developing a Single UI Layer

Another challenge in building our proof of concept was the need to have a UI abstraction or conversion layer, so you can see something on screen. In iOS, you can create the user interface by writing code that displays UI features, or you can use Interface Builder or Storyboards. With Android, it’s similar: You can write custom code or define the UI by using XML or a visual layout tool.

But how do you have a single UI that translates? Tools like Xamarin allow you to take business logic and carry it over across platforms, saving a lot time, but still require the development of two native UIs. (Side note: Xamarin recently introduced Xamarin.Forms, which allows developers to create their UI once. We like this approach for apps that provide the same experience regardless of platform.)

With many cross-platform apps, you would want to take advantage of UI features specific to Android and iOS — but for this this proof of concept, we wanted to develop the UI for Android within Swift. And with our calculator, we were able to do just that, using native iOS UI calls made in Swift, then translating them to corresponding Android UI calls. It all worked beautifully.

More Exploration

We’re excited about the proof of concept and the problem our engineers solved, but there’s more work to be done if we’re going to use this type of compiler commercially. We’d love to know what you think: Would you want to write apps for Android, or for both iOS and Android at the same time, using Swift? Comment below or Tweet to us.

Eric N. Shapiro is the founder and CEO of ArcTouch. His days of working with mobile technology goes all the way back to his time at Apple, when (among other things) he was involved in the launch of the Newton. He also knows how to program in NewtonScript, which was one of Apple’s earlier forays in creating a new programming language.

都看到这里了,就把这篇资料推荐给您的好朋友吧,让他们也感受一下。

回帖是一种美德,也是对楼主发帖的尊重和支持。您的赞赏是我前进的方向。

*声明:敏捷大拇指是全球最大的Swift开发者社区、苹果粉丝家园、智能移动门户,所载内容仅限于传递更多最新信息,并不意味赞同其观点或证实其描述;内容仅供参考,并非绝对正确的建议。本站不对上述信息的真实性、合法性、完整性做出保证;转载请注明来源并加上本站链接,敏捷大拇指将保留所有法律权益。如有疑问或建议,邮件至marketing@swifthumb.com

*联系:微信公众平台:“swifthumb” / 腾讯微博:@swifthumb / 新浪微博:@swifthumb / 官方QQ一群:343549891(满) / 官方QQ二群:245285613 ,需要报上用户名才会被同意进群,请先注册敏捷大拇指

发表评论

最新评论

引用 bioswift 2016-11-21 18:34
十分经典的一篇文章,我问过身边的安卓工程师,几乎都看过大拇指的这篇文章。
引用 1起来 2016-10-15 22:38
这些淘帖专辑不错!
引用 瑶池 2016-9-10 06:34
很经典的一篇文章!
引用 Yole 2016-1-12 14:10
我擦,这安卓要被冲击了?
引用 rightnow 2015-6-7 03:56
能开发arduino上的应用不?
引用 h5lover 2015-3-4 22:58
可以用来开发HTML5不??
引用 cocoaswift 2015-1-15 01:59
跟Apportable是什么关系?
《Apportable 用swift和objective-C开发Android应用》
http://www.swifthumb.com/thread-2557-1-1.html
引用 firefighter 2014-10-15 13:01
还可以用来开发Windows Phone应用?!
引用 Anewczs 2014-10-15 12:42
还是我大swift威武!
引用 sunshineclt 2014-10-15 12:37
屌爆
引用 swifter 2014-10-15 12:18
赞一个!swift一招鲜,打遍天!
引用 hopeany 2014-10-15 09:38
国内前几年的易语言编译器也可以尝试一下这个功能

查看全部评论(12)

相关阅读

淘帖专辑
我要发帖

全部专栏

文章精选
广告位招租

分享扩散

都看到这里了,就把这资料推荐给您的好朋友吧,让他们也感受一下。
您的每一位朋友访问此永久链接后,您都将获得相应的金钱积分奖励
关闭

One More Thing 上一条 /1 下一条

热门推荐

合作伙伴

Swift小苹果

  • 北京治世天下科技有限公司
  • ©2014-2017 敏捷大拇指
  • 京ICP备14029482号
  • Powered by Discuz! X3.1 Licensed
  • swifthumb Wechat Code
  •   
返回顶部