Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build iOS/MacOS with Project Catalyst and XCode 11 #268

Open
cerupcat opened this issue Jun 16, 2019 · 23 comments
Open

Build iOS/MacOS with Project Catalyst and XCode 11 #268

cerupcat opened this issue Jun 16, 2019 · 23 comments

Comments

@cerupcat
Copy link

cerupcat commented Jun 16, 2019

I'm curious if there are any insights on how we might add libpd to both iOS and MacOS using the new project catalyst feature Apple announced.

There is a new XCFramework support in Xcode 11 for distributing frameworks for multiple platforms (specifically UIKit for Mac) that would be super useful for clients porting their iPad apps to macOS. I imagine, creating this would solve the issues currently seen when trying to build UIKit for Mac.

Has anyone else tried this yet or is it too early?

@danomatika
Copy link
Member

danomatika commented Jun 16, 2019 via email

@virusys
Copy link

virusys commented Jul 26, 2019

I can confirm that libpd works the same on Xcode 11 and iOS13/MacOS Catalina, however as of iOS 13 Inter App Audio is deprecated in favour of AUv3.

@cerupcat
Copy link
Author

cerupcat commented Jul 26, 2019 via email

@o-g-sus
Copy link

o-g-sus commented Jul 4, 2020

Thanks virusys. I’m specifically referring to the new UIKit for Mac though. So not building for Mac target specifically and instead using the same iOS codebase for Mac which is the new feature that Apple announced.

I am actually trying the same. While I (still) get audio on my iPad with the Catalyst project, I get just a crackle sound when the app starts, but then no further audio.

These are the reported logs:

[plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600000273080> ...
HALC_ShellDriverPlugIn::Open: Can't get a pointer to the Open routine
[avas] AVAudioSession_MacOS.mm:258:-[AVAudioSession getChannelsFromAU:PortName:PortID:]: ERROR in getting channel layout for auScope 1768845428 element 1
[avas] AVAudioSession_MacOS.mm:258:-[AVAudioSession getChannelsFromAU:PortName:PortID:]: ERROR in getting channel layout for auScope 1869968496 element 0

@o-g-sus
Copy link

o-g-sus commented Jul 4, 2020

Ah, well, just tried with PdTest01 demo project and it instantly ran (after adding the Micro key) on my mac via Catalyst ... cool :)

@cerupcat
Copy link
Author

cerupcat commented Jul 5, 2020

I get errors in "AudioHelpers.m" when trying to compile with Catalyst. I'm not sure if it's due to me using cocoapods though.

@o-g-sus
Copy link

o-g-sus commented Jul 5, 2020

It might be releated to cocoapods indeed. I just found out that the PdTest01 demo project does not work on my Mac anymore, when I move the PD file out of the resources folder, to the bundle folder, where my PD files are in all my other projects. So maybe Catalyst Macs apps need their resources offered in certain structure, PD files in the Resources folder in this case ?

@cerupcat
Copy link
Author

cerupcat commented Jul 5, 2020

@o-g-sus, I don't see how you're even able to compile. I checked out both the libpd repo and the pd-for-ios repo, opened the xcode project, and enabled Mac catalyst and it won't compile. It errors in "AudioHelpers.m."

I tried creating an xcframework which combines the ios/osx/simulator libraries into a framework to work cross platform, but was unable to get a build working for catalyst. https://medium.com/swift-sections/xcframeworks-afd0b151d111

@o-g-sus
Copy link

o-g-sus commented Jul 5, 2020

Hm, which errors do you get?
Could you compile for iOS at least?

@cerupcat
Copy link
Author

cerupcat commented Jul 5, 2020 via email

@virusys
Copy link

virusys commented Oct 8, 2020

Experienced this issue today with a libpd project using Cocoapods (errors in AudioHelpers.m as @cerupcat mentioned). Has it been decided what the best path forward would involve modifying the project file/xcframeworks? I'm available to take a look at this if needed.

@cerupcat
Copy link
Author

cerupcat commented Oct 8, 2020 via email

@virusys
Copy link

virusys commented Oct 21, 2020

@cerupcat Do you happen to have a working blank sample project with that setup you'd be willing to share? I'm working on a client project right now that wants this done "as fast as possible" — but I will eventually look into the xcframework at some point for my personal projects.

@cerupcat
Copy link
Author

cerupcat commented Oct 22, 2020 via email

@virusys
Copy link

virusys commented Oct 22, 2020

No worries at all — thank you for your instructions!

@virusys
Copy link

virusys commented Nov 2, 2020

Hi again — I managed to setup a Catalyst project in the way @cerupcat described, but I was unaware of issue #93 (I guess up until now all of my libpd work has been on iOS 🙃). @o-g-sus You were able to get PdTest01 running with sound on Mac right? @o-g-sus (or @cerupcat), did you replace PdAudioController with RtAudio or something similar (as per this example linked in #93https://github.com/libpd/libpd/tree/master/samples/cpp/pdtest_rtaudio)? That's the current trajectory I'm on and I just wanted to know if I'm on the right path.

@virusys
Copy link

virusys commented Nov 9, 2020

It was actually fairly straightforward to adapt PdTest01 for Catalyst using RtAudio on osx as suggested. I've attached a zip with the project file if anyone finds it useful 👍

https://drive.google.com/file/d/1-8aDYEQSxaFgxzS2s9FRmTTBYi6rTZks/view?usp=sharing

@danomatika
Copy link
Member

danomatika commented Dec 30, 2020

It might be more useful to contribute an example project either to this repo or to a "pd-for-mac" repo, similar to the "pd-for-ios" repo, via a Pull Request.

@virusys
Copy link

virusys commented Feb 11, 2021

Sounds good, I can contribute what I have but I'm currently experiencing this issue when unplugging/switching audio devices: thestk/rtaudio#194. In the meantime I have been trying other strategies; but had no luck so far trying to import jack or portaudio into my Mac Catalyst project. Does anyone have a working example of portaudio + libpd on the Mac by chance? I also started a new branch with an attempt to setup my own Audio Unit, if I end up getting it to work I can contribute that as well 👍

@danomatika
Copy link
Member

but I'm currently experiencing this issue when unplugging/switching audio devices

FYI: As far as I know, neither RtAudio nor portaudio support dynamic device hot-plugging.

I'd suggest using a different solution like Novocaine or rolling your own using CoreAudio directly.

@virusys
Copy link

virusys commented Feb 12, 2021

@danomatika Thanks for that suggestion! — I cloned Novocaine and was able to get their sample projects to run except I ran into this error if I try to start the Novocaine audio manager in either "iOS" or "Mac" mode within my Catalyst project; exiting the app on launch:

[as] AudioSessionClientImpl.mm:232:-[AudioSessionClientImpl AudioSessionGetPropertyImpl:size:data:]: Error: AudioSession not initialized
Error: Couldn't check the audio route ('!ini')

Looking at their repo it seems like the latest updates were around 4-5 years ago so I feel like they didn't have Catalyst in mind as a target — I feel like a lot of these issues stem from Catalyst being its own unique platform which is essentially just trying to emulate iOS on the Mac.

I've started some work trying to setup my own Audio Unit handler but I'm experiencing similar issues and its taking more time than I currently can devote to this project — I'll file a bug report on the Novocaine repository and if I make any more progress on my CoreAudio code down the line I'll post it here 👍

@danomatika
Copy link
Member

danomatika commented Feb 12, 2021

Well, if Novocaine is out of date, then some other CoreAudio wrapper. My point was mainly that, unless you add functionality to RtAudio or Portaudio, they are not going to handle your use cases as is.

@virusys
Copy link

virusys commented Feb 12, 2021

@danomatika Cool, thanks again for confirming the lack of hotplug functionality; forgot to mention that in my last comment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants