SDL
SDL copied to clipboard
IOS: Compilation of SDL and satellite libraries
I have this very simple script: ios_build_libs.sh.txt
That helps me to re-build all SDL, SDL_image, SDL_mixer and SDL_ttf libraries in release, debug,device,simulator. for iOS or tvOS. In one command. Now, it fails with mysterious messages. see below. (it may not be relevant).
I see that the "scheme" a now more homogeneous. For SDL the are "Static Library-iOS" or "-TV". But no differentiation for other libraries. Is this ok ? Same thing for "framework" scheme: there is a "Framework-iOS" scheme for SDL. And only "Framework"for other libs.
I wonder which scheme should be used to build for ios. Thanks.
It seems this script should be legitimate to run correctly since it only triggers the Xcode build. with some parameter. Any help is appreciated :)
/Users/s/Library/Developer/Xcode/DerivedData/SDL-dgdwwfogariedibsiqbkveftrenw/Build/Intermediates.noindex/SDL.build/Debug-iphonesimulator/Framework-iOS.build/Objects-normal/i386/SDL_surface.dia:1:1: warning: Could not read serialized diagnostics file: error("Failed to open diagnostics file") (in target 'Framework-iOS' from project 'SDL')
,,,
note: Building targets in dependency order
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'Framework' from project 'SDL_ttf')
/Users/s/release/Release_SDL_IOS/SDL_ttf/Xcode/SDL_ttf.xcodeproj: error: Building for iOS, but the linked framework 'SDL2.framework' was built for macOS. (in target 'Framework' from project 'SDL_ttf')
** BUILD FAILED **
it's difficult to say what's causing the error without seeing full compile output.
haven't seen any issues when building static library target, you can check my script here: https://github.com/kambala-decapitator/vcmi-ios-depends/blob/main/build_depends.sh#L171
You might just need to clean before running this script?
@kambala-decapitator Have you tried your script with SDL2_image v2.6.2? Your script references v2.0.5. I believe v2.0.5 still uses Xcode-iOS which does not exist anymore in the latest versions.
My own similar xcodebuild command fails when building the simulator version with
error: ApplicationServices is not available when building for iOS Simulator. (in target 'Static Library' from project 'SDL_image')
And when building for an iOS device:
error: ApplicationServices is not available when building for iOS. (in target 'Static Library' from project 'SDL_image')
It's not the same error as @1bsyl, but it seems related in that SDL_image seems to want to build the iOS project as a Mac project, unless we are building it wrong? ApplicationServices is for MacOS, not for iOS.
My original xcodebuild command:
xcodebuild -scheme "Static Library" -configuration Release -sdk iphoneos SKIP_INSTALL=NO BUILD_DIR=build/SDL2_image-iphoneos
And I tried this change based partly on @kambala-decapitator's script:
xcodebuild -target "Static Library" -configuration Release -sdk iphonesimulator ENABLE_BITCODE=NO IPHONEOS_DEPLOYMENT_TARGET=10.0 PLATFORM=iOS BUILD_DIR=build/SDL2_image-iphonesimulator
And when I check what schemes/targets are available, there isn't anything iOS-specific, so I don't know how else to build it as an iOS project unless I specify the SDK, which doesn't seem to impact how the library's Xcode project knows what to depend upon.
xcodebuild -version
Xcode 12.4
Build version 12D4e
xcodebuild -list shows:
Targets:
Framework
Static Library
Create DMG
Schemes:
avif
Create DMG
dav1d
dav1d-16bit
dav1d-8bit
Framework
jxl
Static Library
webp
@gbgames if I recall correctly, Xcode project has been changed to multi-platform support, but unfortunately it requires Xcode 13 (you use 12.4 as I see)
you can also build with CMake and https://github.com/leetal/ios-cmake
I fixed my script: ios_build_libs.sh.txt
It seems I have to "force" the PLATFORM variable so that the HEADER_SEARCH_PATHS is correct. eg: adding 'PLATFORM=iOS' to the xcodebuild command line.