Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Samples for the SwiftAndroid toolchain.

NotificationsYou must be signed in to change notification settings

SwiftJava/swift-android-samples

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 

Repository files navigation

Requires a build of the latest Android toolchain downloadablehere.The gradle plugin used to build is now part of the toolchain which is installed by runningswift-install/setup,sh.On Linux, make sure theusr/bin driectory of the toolchain you want to use is in your path when yourun this script.The phone must be api 21 aka Android v5+ aka Lollipop or better (I used an LG K4.)The example app now uses SQLite which requires Beta III of the toolchain released 27/08/2017.

To create a new application, decide on a pair of interfaces to connect to and from your Swiftcode and place them in aJava Source.Use the command./genswift.sh in theSwiftJava Projectto generate Swift (& Java) sources to include in your application or adapt thegenhello.sh script.If you only use interfaces/protocols, your app's onlyPackage.swiftdependency should be the core JNI interfacing codejava_swift.

This example is coded to work with version 4 of the toolchain which has some additional requirementsto work around requirements of the Swift port of Foundation. The cache directory used by web operationsneeds to be setup in the enironment variable "TMPDIR". This would usually be the value ofContext.getCacheDir().getPath() from the java side. In addition, to be able to use SSL youneed to add aCARoot info file to the application'sraw resources and copy it to this cache directory to be picked up by Foundation as follows:

setenv("URLSessionCertificateAuthorityInfoFile", cacheDir! + "/cacert.pem", 1)setenv("TMPDIR", cacheDir!, 1)

If you don't want peer validation you have the following option (not recommended at all)

setenv("URLSessionCertificateAuthorityInfoFile", “INSECURE_SSL_NO_VERIFY”, 1)

Simple demo of Swift code accessed over JNI.

To build, setup the Gradle plugin, then run./gradlew installDebug

This demo is licensed under the Creative Commons CC0 license:do whatever you want.

About

Samples for the SwiftAndroid toolchain.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift78.6%
  • Java21.4%

[8]ページ先頭

©2009-2025 Movatter.jp