Files
xash3d-fwgs/engine/platform/ios/lib_ios.c
ksagameng2 a9bf700da4 Restore iOS build support (#2352)
* initial commit

* initial commit

* add port files

* ios: Changes to allow creating app bundle without xcode projects

* ios: Added mic perms request

* ios: Very basic app bundle creation script

* ios: Fix -log parameter

* ios: Sdk no longer hardcoded and option to compile for simulator

* general: Update gitignore

* ios: Enable game mode for the app

* ios: Compile instructions and updated ipa creation script

* ios: Code cleanup

* ios: Remove dylibs

* general: Remove extra submodules

* ios: Remove dylibs again

* ios: Implement suggested changes

* ios: Fix building as dylib instead of binary

* ios: Scripts for building mods

* ios: Move 'ios' contents to engine/platform/ios/bundle and modify scripts

* ios: Update createipa.sh to use waf install

* ios: Clean script and updated README

* general: Fix spelling mistake and outdated instructions

* ios: Clean up in xcompile.py

* ios: Fix createipa.sh generating an invalid ipa

* ios: Temporary fix for launch dialog textfield colors in dark mode
2025-11-01 18:32:00 +05:00

72 lines
2.1 KiB
C

/*
ios_lib.c - dynamic library code for iOS
Copyright (C) 2017-2018 mittorn
This program is free software: you can redistribute it and/sor modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include <string.h>
#include <SDL.h>
#include "common.h"
#include "library.h"
#include "filesystem.h"
#include "server.h"
#include "platform/ios/lib_ios.h"
#include <dlfcn.h>
static void *IOS_LoadLibraryInternal( const char *dllname )
{
void *pHandle;
string errorstring = "";
char path[MAX_SYSPATH];
// load frameworks from Documents directory
// frameworks should be signed with same key with application
// Useful for debug to prevent rebuilding app on every library update
// NOTE: Apple polices forbids loading code from shared places
#ifdef ENABLE_FRAMEWORK_SIDELOAD
Q_snprintf( path, MAX_SYSPATH, "%s.framework/lib", dllname );
if( pHandle = dlopen( path, RTLD_LAZY ) )
return pHandle;
Q_snprintf( errorstring, MAX_STRING, dlerror() );
#endif
#ifdef DLOPEN_FRAMEWORKS
// load frameworks as it should be located in Xcode builds
Q_snprintf( path, MAX_SYSPATH, "%s%s.framework/lib", SDL_GetBasePath(), dllname );
#else
// load libraries from app root to allow re-signing ipa with custom utilities
Q_snprintf( path, MAX_SYSPATH, "%s%s", SDL_GetBasePath(), dllname );
#endif
pHandle = dlopen( path, RTLD_LAZY );
if( !pHandle )
{
COM_PushLibraryError(errorstring);
COM_PushLibraryError(dlerror());
}
return pHandle;
}
char *g_szLibrarySuffix;
void *IOS_LoadLibrary( const char *dllname )
{
string name;
char *postfix = g_szLibrarySuffix;
char *pHandle;
if( !postfix ) postfix = "";
Q_snprintf( name, MAX_STRING, "%s%s", dllname, postfix );
pHandle = IOS_LoadLibraryInternal( name );
if( pHandle )
return pHandle;
return IOS_LoadLibraryInternal( dllname );
}