Skip to content

Commit 6116109

Browse files
authored
Merge pull request #1 from swiftlang/gradle-examples
Add Gradle examples
2 parents d24aaef + 6f511bb commit 6116109

File tree

92 files changed

+3025
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+3025
-1
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea
5+
.DS_Store
6+
/build
7+
/captures
8+
.externalNativeBuild
9+
.cxx
10+
local.properties
11+
jniLibs

.idea/icon.svg

Lines changed: 1 addition & 0 deletions
Loading

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
# swift-android-examples
1+
# Swift Android Examples
2+
3+
This repository contains sample apps that use the [Swift Android SDK](https://www.swift.org/).
4+
5+
# Build and run
6+
7+
1. Setup Swift Android SDK
8+
2. Clone this repository
9+
3. Open the whole project in Android Studio
10+
4. Select the sample you want to run in the top bar (you may need to sync gradle first)
11+
5. Click the play button to run the sample
12+
13+
You can also build the samples from the command line if you prefer. Use `./gradlew` build to build everything. For individual tasks, see `./gradlew tasks`. To see the tasks for an individual sample, run the tasks task for that directory. For example, `./gradlew :hello-swift:tasks` will show the tasks for the hello-swift app.
14+
15+
You can build all sample apps for both the debug and release build types by running `./gradlew assemble`.

build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
plugins {
3+
alias(libs.plugins.android.application) apply false
4+
alias(libs.plugins.kotlin.android) apply false
5+
alias(libs.plugins.android.library) apply false
6+
}

gradle.properties

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Project-wide Gradle settings.
2+
# IDE (e.g. Android Studio) users:
3+
# Gradle settings configured through the IDE *will override*
4+
# any settings specified in this file.
5+
# For more details on how to configure your build environment visit
6+
# http://www.gradle.org/docs/current/userguide/build_environment.html
7+
# Specifies the JVM arguments used for the daemon process.
8+
# The setting is particularly useful for tweaking memory settings.
9+
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10+
# When configured, Gradle will run in incubating parallel mode.
11+
# This option should only be used with decoupled projects. For more details, visit
12+
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
13+
# org.gradle.parallel=true
14+
# AndroidX package structure to make it clearer which packages are bundled with the
15+
# Android operating system, and which are packaged with your app's APK
16+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
17+
android.useAndroidX=true
18+
# Kotlin code style for this project: "official" or "obsolete":
19+
kotlin.code.style=official
20+
# Enables namespacing of each library's R class so that its R class includes only the
21+
# resources declared in the library itself and none from the library's dependencies,
22+
# thereby reducing the size of the R class for that library
23+
android.nonTransitiveRClass=true

gradle/libs.versions.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[versions]
2+
agp = "8.13.0"
3+
kotlin = "2.0.21"
4+
coreKtx = "1.16.0"
5+
junit = "4.13.2"
6+
junitVersion = "1.3.0"
7+
espressoCore = "3.7.0"
8+
appcompat = "1.7.1"
9+
material = "1.12.0"
10+
constraintlayout = "2.2.1"
11+
12+
[libraries]
13+
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
14+
junit = { group = "junit", name = "junit", version.ref = "junit" }
15+
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
16+
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
17+
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
18+
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
19+
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
20+
21+
[plugins]
22+
android-application = { id = "com.android.application", version.ref = "agp" }
23+
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
24+
android-library = { id = "com.android.library", version.ref = "agp" }
25+

gradle/wrapper/gradle-wrapper.jar

57.8 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Sat Aug 09 13:51:11 EEST 2025
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

gradlew

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
#!/usr/bin/env sh
2+
3+
##############################################################################
4+
##
5+
## Gradle start up script for UN*X
6+
##
7+
##############################################################################
8+
9+
# Attempt to set APP_HOME
10+
# Resolve links: $0 may be a link
11+
PRG="$0"
12+
# Need this for relative symlinks.
13+
while [ -h "$PRG" ] ; do
14+
ls=`ls -ld "$PRG"`
15+
link=`expr "$ls" : '.*-> \(.*\)$'`
16+
if expr "$link" : '/.*' > /dev/null; then
17+
PRG="$link"
18+
else
19+
PRG=`dirname "$PRG"`"/$link"
20+
fi
21+
done
22+
SAVED="`pwd`"
23+
cd "`dirname \"$PRG\"`/" >/dev/null
24+
APP_HOME="`pwd -P`"
25+
cd "$SAVED" >/dev/null
26+
27+
APP_NAME="Gradle"
28+
APP_BASE_NAME=`basename "$0"`
29+
30+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
32+
33+
# Use the maximum available, or set MAX_FD != -1 to use that value.
34+
MAX_FD="maximum"
35+
36+
warn () {
37+
echo "$*"
38+
}
39+
40+
die () {
41+
echo
42+
echo "$*"
43+
echo
44+
exit 1
45+
}
46+
47+
# OS specific support (must be 'true' or 'false').
48+
cygwin=false
49+
msys=false
50+
darwin=false
51+
nonstop=false
52+
case "`uname`" in
53+
CYGWIN* )
54+
cygwin=true
55+
;;
56+
Darwin* )
57+
darwin=true
58+
;;
59+
MINGW* )
60+
msys=true
61+
;;
62+
NONSTOP* )
63+
nonstop=true
64+
;;
65+
esac
66+
67+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68+
69+
70+
# Determine the Java command to use to start the JVM.
71+
if [ -n "$JAVA_HOME" ] ; then
72+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73+
# IBM's JDK on AIX uses strange locations for the executables
74+
JAVACMD="$JAVA_HOME/jre/sh/java"
75+
else
76+
JAVACMD="$JAVA_HOME/bin/java"
77+
fi
78+
if [ ! -x "$JAVACMD" ] ; then
79+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80+
81+
Please set the JAVA_HOME variable in your environment to match the
82+
location of your Java installation."
83+
fi
84+
else
85+
JAVACMD="java"
86+
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87+
88+
Please set the JAVA_HOME variable in your environment to match the
89+
location of your Java installation."
90+
fi
91+
92+
# Increase the maximum file descriptors if we can.
93+
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
94+
MAX_FD_LIMIT=`ulimit -H -n`
95+
if [ $? -eq 0 ] ; then
96+
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97+
MAX_FD="$MAX_FD_LIMIT"
98+
fi
99+
ulimit -n $MAX_FD
100+
if [ $? -ne 0 ] ; then
101+
warn "Could not set maximum file descriptor limit: $MAX_FD"
102+
fi
103+
else
104+
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105+
fi
106+
fi
107+
108+
# For Darwin, add options to specify how the application appears in the dock
109+
if $darwin; then
110+
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111+
fi
112+
113+
# For Cygwin or MSYS, switch paths to Windows format before running java
114+
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
115+
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116+
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117+
118+
JAVACMD=`cygpath --unix "$JAVACMD"`
119+
120+
# We build the pattern for arguments to be converted via cygpath
121+
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
122+
SEP=""
123+
for dir in $ROOTDIRSRAW ; do
124+
ROOTDIRS="$ROOTDIRS$SEP$dir"
125+
SEP="|"
126+
done
127+
OURCYGPATTERN="(^($ROOTDIRS))"
128+
# Add a user-defined pattern to the cygpath arguments
129+
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
130+
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
131+
fi
132+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
133+
i=0
134+
for arg in "$@" ; do
135+
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
136+
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
137+
138+
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
139+
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
140+
else
141+
eval `echo args$i`="\"$arg\""
142+
fi
143+
i=`expr $i + 1`
144+
done
145+
case $i in
146+
0) set -- ;;
147+
1) set -- "$args0" ;;
148+
2) set -- "$args0" "$args1" ;;
149+
3) set -- "$args0" "$args1" "$args2" ;;
150+
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
151+
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
152+
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
153+
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
154+
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
155+
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
156+
esac
157+
fi
158+
159+
# Escape application args
160+
save () {
161+
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
162+
echo " "
163+
}
164+
APP_ARGS=`save "$@"`
165+
166+
# Collect all arguments for the java command, following the shell quoting and substitution rules
167+
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
168+
169+
exec "$JAVACMD" "$@"

gradlew.bat

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
@if "%DEBUG%" == "" @echo off
2+
@rem ##########################################################################
3+
@rem
4+
@rem Gradle startup script for Windows
5+
@rem
6+
@rem ##########################################################################
7+
8+
@rem Set local scope for the variables with windows NT shell
9+
if "%OS%"=="Windows_NT" setlocal
10+
11+
set DIRNAME=%~dp0
12+
if "%DIRNAME%" == "" set DIRNAME=.
13+
set APP_BASE_NAME=%~n0
14+
set APP_HOME=%DIRNAME%
15+
16+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
17+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
18+
19+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
20+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
21+
22+
@rem Find java.exe
23+
if defined JAVA_HOME goto findJavaFromJavaHome
24+
25+
set JAVA_EXE=java.exe
26+
%JAVA_EXE% -version >NUL 2>&1
27+
if "%ERRORLEVEL%" == "0" goto execute
28+
29+
echo.
30+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
31+
echo.
32+
echo Please set the JAVA_HOME variable in your environment to match the
33+
echo location of your Java installation.
34+
35+
goto fail
36+
37+
:findJavaFromJavaHome
38+
set JAVA_HOME=%JAVA_HOME:"=%
39+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
40+
41+
if exist "%JAVA_EXE%" goto execute
42+
43+
echo.
44+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
45+
echo.
46+
echo Please set the JAVA_HOME variable in your environment to match the
47+
echo location of your Java installation.
48+
49+
goto fail
50+
51+
:execute
52+
@rem Setup the command line
53+
54+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
55+
56+
57+
@rem Execute Gradle
58+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
59+
60+
:end
61+
@rem End local scope for the variables with windows NT shell
62+
if "%ERRORLEVEL%"=="0" goto mainEnd
63+
64+
:fail
65+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
66+
rem the _cmd.exe /c_ return code!
67+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
68+
exit /b 1
69+
70+
:mainEnd
71+
if "%OS%"=="Windows_NT" endlocal
72+
73+
:omega

0 commit comments

Comments
 (0)