[Csnd] Csound for iOS on simulator

Hi!

I was trying to learn using Csound for iOS libraries but could not get the code running on simulator since the included libraries libcsnd.a and libsndfile.a were built for arm64.

My goal is to work out a template for building build Qt+Csound apps that run both on android, dekstop and ios. iOs is still the only missing component…

Does anybody have experience with trying iOS library/apps on iphone simulator and can give some hints?

Thanks!
tarmo

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

I can get my iOS apps to load Ok in the simulator but I could not successfully get it to output any audio. On the other hand, they seem to run fine so maybe it’s a setting in the simulator that is the problem. But you will need x86_64 libraries too. And it looks like XCode wants to only deal with xcframeworks now. I assume you are working with XCode? I’ve attached an updated build.sh file that you can drop into the iOD folder that should create an xcframework for you. You can add the framework to your project and XCode will use the correct library for each platform. Let me know how it goes.

(Attachment build.sh is missing)

Sorry, that attachment didn’t go through, I’ll copy and paste:

Thanks, Rory!

I am not so experienced with builds on Mac.

I am trying it out on MacOS Ventura (MAcOS 13), Xcode 14.3.1. Just for feedback:

First I needed to remove ‘-T buildsystem=1’ that did not work with that version of Xcode. I installed libsndfile with brew, everything went fine but then I landed on an error:

CMake Error in CMakeLists.txt:

The custom command generating

/Users/m1/Documents/src/csound/iOS/cs6iOS/csound_orclex.c

is attached to multiple targets:

CsoundLib

CsoundLib-static

but none of these is a common dependency of the other(s). This is not

allowed by the Xcode “new build system”.

I was not able to find r how to solve this problem…

My cake command was:

cmake ../.. -G Xcode -DUSE_GETTEXT=0 -DUSE_DOUBLE=0 -DBUILD_STATIC_LIBRARY=1 -DBUILD_RELEASE=1 -DCMAKE_BUILD_TYPE=Release -DUSE_CURL=0 -DUSE_SSE=0 -DIOS=1 -DCUSTOM_CMAKE=“../custom.cmake.ios”

cmake version is 3.28.1

Maybe it affects also other Mac builds

tarmo

Kontakt Rory Walsh (<rorywalsh@ear.ie>) kirjutas kuupäeval R, 5. jaanuar 2024 kell 14:25:

Sorry, that attachment didn’t go through, I’ll copy and paste:


#!/bin/sh
set -x
rm -rf cs6iOS
mkdir cs6iOS
cd cs6iOS
cmake ../.. -G Xcode -T buildsystem=1 -DUSE_GETTEXT=0 -DUSE_DOUBLE=0 -DBUILD_STATIC_LIBRARY=1 -DBUILD_RELEASE=1 -DCMAKE_BUILD_TYPE=Release -DUSE_CURL=0 -DUSE_SSE=0 -DIOS=1 -DCUSTOM_CMAKE=“../custom.cmake.ios”

CMake was adding -mfpmath=sse which makes the build fail. The project needs to be edited in XCode to remove it before

the build for devices can continue.

clearing the CMAKE_C_FLAGS on custom.cmake seems to have solved this

xcodebuild -sdk iphoneos -xcconfig ../device.xcconfig -target CsoundLib-static -configuration Release -verbose

something goes wrong with the creation of the csound_prslex.c file and it fails to build so we

run it again to succeed. TODO: see why the build is out of order causing this problem

xcodebuild -sdk iphoneos -xcconfig ../device.xcconfig -target CsoundLib-static -configuration Release -verbose

cp Release/libCsoundLib.a ./libcsound-device.a
xcodebuild -sdk iphonesimulator -xcconfig ../simulator.xcconfig -target CsoundLib-static -configuration Release

xcodebuild -create-xcframework -library Release/libCsoundLib.a -headers include -library libcsound-device.a -headers include -output xcframeworks/CsoundiOS.xcframework

lipo -create libcsound-device.a Release/libCsoundLib.a -output ../libcsound.a

I can get my iOS apps to load Ok in the simulator but I could not successfully get it to output any audio. On the other hand, they seem to run fine so maybe it’s a setting in the simulator that is the problem. But you will need x86_64 libraries too. And it looks like XCode wants to only deal with xcframeworks now. I assume you are working with XCode? I’ve attached an updated build.sh file that you can drop into the iOD folder that should create an xcframework for you. You can add the framework to your project and XCode will use the correct library for each platform. Let me know how it goes.

Hi!

I was trying to learn using Csound for iOS libraries but could not get the code running on simulator since the included libraries libcsnd.a and libsndfile.a were built for arm64.

My goal is to work out a template for building build Qt+Csound apps that run both on android, dekstop and ios. iOs is still the only missing component…

Does anybody have experience with trying iOS library/apps on iphone simulator and can give some hints?

Thanks!
tarmo

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

That’s funny, it’s because of that particular error that I had to add buildSystem=1. FWIW, I’m using the latest version of XCode. But as with all things Apple, think twice before updating!