Skip to content

Commit 574da1a

Browse files
authored
Merge pull request #2411 from joliver82/ios-2024_2
iOS support
2 parents 34e58ee + efefbd4 commit 574da1a

23 files changed

+4311
-2
lines changed

.github/workflows/main.yml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ on:
5151
- v3.5
5252
- v3.4
5353
- v3.3
54+
- ios-2024_2
5455
pull_request:
5556
release:
5657
types: [published]
@@ -94,6 +95,46 @@ jobs:
9495
**/build/reports/**
9596
**/build/changed-images/**
9697
**/build/test-results/**
98+
99+
# Build iOS natives
100+
BuildIosNatives:
101+
name: Build natives for iOS
102+
runs-on: macOS-14
103+
104+
steps:
105+
- name: Check default JAVAs
106+
run: echo $JAVA_HOME --- $JAVA_HOME_8_X64 --- $JAVA_HOME_11_X64 --- $JAVA_HOME_17_X64 --- $JAVA_HOME_21_X64 ---
107+
108+
- name: Setup the java environment
109+
uses: actions/setup-java@v4
110+
with:
111+
distribution: 'temurin'
112+
java-version: '11.0.26+4'
113+
114+
- name: Setup the XCode version to 15.1.0
115+
uses: maxim-lobanov/setup-xcode@v1
116+
with:
117+
xcode-version: '15.1.0'
118+
119+
- name: Clone the repo
120+
uses: actions/checkout@v4
121+
with:
122+
fetch-depth: 1
123+
124+
- name: Validate the Gradle wrapper
125+
uses: gradle/actions/wrapper-validation@v3
126+
127+
- name: Build
128+
run: |
129+
./gradlew -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true \
130+
:jme3-ios-native:build
131+
132+
- name: Upload natives
133+
uses: actions/upload-artifact@master
134+
with:
135+
name: ios-natives
136+
path: jme3-ios-native/template/META-INF/robovm/ios/libs/jme3-ios-native.xcframework
137+
97138
# Build the natives on android
98139
BuildAndroidNatives:
99140
name: Build natives for android
@@ -139,7 +180,7 @@ jobs:
139180

140181
# Build the engine, we only deploy from ubuntu-latest jdk21
141182
BuildJMonkey:
142-
needs: [BuildAndroidNatives]
183+
needs: [BuildAndroidNatives, BuildIosNatives]
143184
name: Build on ${{ matrix.osName }} jdk${{ matrix.jdk }}
144185
runs-on: ${{ matrix.os }}
145186
strategy:
@@ -180,6 +221,12 @@ jobs:
180221
name: android-natives
181222
path: build/native
182223

224+
- name: Download natives for iOS
225+
uses: actions/download-artifact@master
226+
with:
227+
name: ios-natives
228+
path: jme3-ios-native/template/META-INF/robovm/ios/libs/jme3-ios-native.xcframework
229+
183230
- name: Validate the Gradle wrapper
184231
uses: gradle/actions/wrapper-validation@v3
185232
- name: Build Engine
@@ -372,6 +419,12 @@ jobs:
372419
name: android-natives
373420
path: build/native
374421

422+
- name: Download natives for iOS
423+
uses: actions/download-artifact@master
424+
with:
425+
name: ios-natives
426+
path: jme3-ios-native/template/META-INF/robovm/ios/libs/jme3-ios-native.xcframework
427+
375428
- name: Rebuild the maven artifacts and upload them to Sonatype's maven-snapshots repo
376429
run: |
377430
if [ "${{ secrets.CENTRAL_PASSWORD }}" = "" ];
@@ -429,6 +482,12 @@ jobs:
429482
name: android-natives
430483
path: build/native
431484

485+
- name: Download natives for iOS
486+
uses: actions/download-artifact@master
487+
with:
488+
name: ios-natives
489+
path: jme3-ios-native/template/META-INF/robovm/ios/libs/jme3-ios-native.xcframework
490+
432491
- name: Rebuild the maven artifacts and upload them to Sonatype's Central Publisher Portal
433492
run: |
434493
if [ "${{ secrets.CENTRAL_PASSWORD }}" = "" ];

jme3-ios-native/build.gradle

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import org.apache.tools.ant.taskdefs.condition.Os
2+
3+
task deleteXcframework(type: Delete) {
4+
delete 'template/META-INF/robovm/ios/libs/jme3-ios-native.xcframework'
5+
}
6+
7+
task buildNativeLibIos(type: Exec) {
8+
executable "xcodebuild"
9+
args 'archive', '-project', 'jme3-ios-native.xcodeproj', '-scheme', 'jme3-ios-native', '-configuration', 'release', '-destination', 'generic/platform=iOS', '-archivePath', 'build/archives/jme3-ios-native_iOS', 'SKIP_INSTALL=NO', 'BUILD_LIBRARY_FOR_DISTRIBUTION=YES'
10+
}
11+
12+
task buildNativeLibSimulator(type: Exec) {
13+
executable "xcodebuild"
14+
args 'archive', '-project', 'jme3-ios-native.xcodeproj', '-scheme', 'jme3-ios-native', '-configuration', 'release', '-destination', 'generic/platform=iOS Simulator', '-archivePath', 'build/archives/jme3-ios-native_iOS-Simulator', 'SKIP_INSTALL=NO', 'BUILD_LIBRARY_FOR_DISTRIBUTION=YES'
15+
}
16+
17+
task buildNativeLib(type: Exec) {
18+
dependsOn 'deleteXcframework'
19+
dependsOn 'buildNativeLibIos'
20+
dependsOn 'buildNativeLibSimulator'
21+
executable "xcodebuild"
22+
args '-create-xcframework', '-framework', 'build/archives/jme3-ios-native_iOS.xcarchive/Products/Library/Frameworks/jme3_ios_native.framework', '-framework', 'build/archives/jme3-ios-native_iOS-Simulator.xcarchive/Products/Library/Frameworks/jme3_ios_native.framework', '-output', 'template/META-INF/robovm/ios/libs/jme3-ios-native.xcframework'
23+
}
24+
25+
// buildNativeProjects is a string set to "true"
26+
if (Os.isFamily(Os.FAMILY_MAC) && buildNativeProjects == "true") {
27+
// build native libs and update stored pre-compiled libs to commit
28+
compileJava.dependsOn { buildNativeLib }
29+
} else {
30+
// TODO: (like android natives?) use pre-compiled native libs (not building new ones)
31+
// compileJava.dependsOn { copyPreCompiledLibs }
32+
println "Native build disable or not running on OSX"
33+
}
34+
35+
jar.into("") { from "template" }

jme3-ios-native/export.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
rm -rf intermediate-builds release template/META-INF/robovm/ios/libs/jme3-ios-native.xcframework
2+
mkdir intermediate-builds release
3+
xcodebuild archive -project jme3-ios-native.xcodeproj -scheme jme3-ios-native -destination generic/platform=iOS -archivePath intermediate-builds/jme3-ios-native_iOS SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES
4+
xcodebuild archive -project jme3-ios-native.xcodeproj -scheme jme3-ios-native -destination generic/platform="iOS Simulator" -archivePath intermediate-builds/jme3-ios-native_iOS-Simulator SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES
5+
6+
xcodebuild -create-xcframework -framework intermediate-builds/jme3-ios-native_iOS.xcarchive/Products/Library/Frameworks/jme3_ios_native.framework -framework intermediate-builds/jme3-ios-native_iOS-Simulator.xcarchive/Products/Library/Frameworks/jme3_ios_native.framework -output template/META-INF/robovm/ios/libs/jme3-ios-native.xcframework
7+
8+
cd template
9+
zip -r ../release/jme3-ios-native.jar META-INF
10+
cd ..
11+

0 commit comments

Comments
 (0)