Merge pull request #152 from frenzibyte/ios-build

Add iOS platform support
This commit is contained in:
Dean Herbert 2023-03-08 18:18:18 +09:00 committed by GitHub
commit 32913b2335
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 3 deletions

View File

@ -101,7 +101,7 @@ jobs:
- name: Prepare release (Linux) - name: Prepare release (Linux)
run: cp install_output/lib/libSDL2-2.0.so.0 SDL2-CS/native/${{ matrix.platform.name }}/libSDL2.so run: cp install_output/lib/libSDL2-2.0.so.0 SDL2-CS/native/${{ matrix.platform.name }}/libSDL2.so
if: runner.os == 'Linux' if: runner.os == 'Linux'
- name: Prepare release (OSX) - name: Prepare release (macOS)
run: cp install_output/lib/libSDL2-2.0.dylib SDL2-CS/native/${{ matrix.platform.name }}/libSDL2.dylib run: cp install_output/lib/libSDL2-2.0.dylib SDL2-CS/native/${{ matrix.platform.name }}/libSDL2.dylib
if: runner.os == 'macOS' if: runner.os == 'macOS'
- name: Create pull request - name: Create pull request
@ -114,3 +114,38 @@ jobs:
path: 'SDL2-CS' path: 'SDL2-CS'
env: env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
build-ios:
name: ios
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
repository: 'libsdl-org/SDL'
ref: 'SDL2'
- uses: actions/checkout@v3
with:
path: 'SDL2-CS'
- name: Build (iOS)
run: xcodebuild -project Xcode/SDL/SDL.xcodeproj -scheme xcFramework-iOS -configuration Release
- name: Prepare release directory (iOS)
run: mkdir -p SDL2-CS/native/ios
- name: Prepare release (iOS)
run: |
mkdir -p SDL2-CS/native/ios/SDL2.xcframework/ios-arm64/SDL2.framework;
mkdir -p SDL2-CS/native/ios/SDL2.xcframework/ios-arm64_x86_64-simulator/SDL2.framework;
cp Xcode/SDL/Products/SDL2.xcframework/Info.plist SDL2-CS/native/ios/SDL2.xcframework/Info.plist;
cp Xcode/SDL/Products/SDL2.xcframework/ios-arm64/SDL2.framework/SDL2 SDL2-CS/native/ios/SDL2.xcframework/ios-arm64/SDL2.framework/SDL2;
cp Xcode/SDL/Products/SDL2.xcframework/ios-arm64/SDL2.framework/Info.plist SDL2-CS/native/ios/SDL2.xcframework/ios-arm64/SDL2.framework/Info.plist;
cp Xcode/SDL/Products/SDL2.xcframework/ios-arm64_x86_64-simulator/SDL2.framework/SDL2 SDL2-CS/native/ios/SDL2.xcframework/ios-arm64_x86_64-simulator/SDL2.framework/SDL2;
cp Xcode/SDL/Products/SDL2.xcframework/ios-arm64_x86_64-simulator/SDL2.framework/Info.plist SDL2-CS/native/ios/SDL2.xcframework/ios-arm64_x86_64-simulator/SDL2.framework/Info.plist;
- name: Create pull request
uses: peter-evans/create-pull-request@v4
with:
commit-message: Update iOS SDL binaries
title: Update iOS SDL binaries
body: This PR has been auto-genereated to update the iOS SDL binaries
branch: update-ios-binaries
path: 'SDL2-CS'
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyTitle>SDL2#</AssemblyTitle> <AssemblyTitle>SDL2#</AssemblyTitle>
@ -52,6 +52,11 @@
<PackagePath>runtimes/linux-x86/native</PackagePath> <PackagePath>runtimes/linux-x86/native</PackagePath>
<Pack>true</Pack> <Pack>true</Pack>
</Content> </Content>
<Content Include="$(MSBuildThisFileDirectory)native\ios\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PackagePath>runtimes/ios/native</PackagePath>
<Pack>true</Pack>
</Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="app.config"> <Content Include="app.config">

View File

@ -1,4 +1,4 @@
image: Visual Studio 2017 image: Visual Studio 2022
build_script: build_script:
- cmd: dotnet restore - cmd: dotnet restore
- cmd: dotnet pack SDL2-CS.csproj -c:Release --include-symbols /p:Version=%APPVEYOR_BUILD_VERSION% - cmd: dotnet pack SDL2-CS.csproj -c:Release --include-symbols /p:Version=%APPVEYOR_BUILD_VERSION%

View File

@ -37,6 +37,12 @@ namespace SDL2
{ {
public static class SDL public static class SDL
{ {
static SDL()
{
if (OperatingSystem.IsIOS())
NativeLibrary.SetDllImportResolver(typeof(SDL).Assembly, (_, assembly, path) => NativeLibrary.Load("@rpath/SDL2.framework/SDL2", assembly, path));
}
#region SDL2# Variables #region SDL2# Variables
private const string nativeLibName = "SDL2"; private const string nativeLibName = "SDL2";