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

Request: Support for Apple TV (tvOS) with Unity #3161

Closed
muZZkat opened this issue Jan 9, 2023 · 10 comments · Fixed by #3174
Closed

Request: Support for Apple TV (tvOS) with Unity #3161

muZZkat opened this issue Jan 9, 2023 · 10 comments · Fixed by #3174
Assignees

Comments

@muZZkat
Copy link

muZZkat commented Jan 9, 2023

Description

We are developing a cross platform game with Apple TV support and it doesn't look like the current version ships with tvOS support.

We will also be looking at Playstation and Switch support, so maybe I need to look at building from source?

Can anyone maybe point me in the right direction?

Thanks

How important is this improvement for you?

Dealbreaker

@nirinchev
Copy link
Member

@muZZkat can you clarify whether you need just the local database or also sync/functions support?

@fealebenpae sounds like building for Apple TV should be simple enough - perhaps we can add preview support for the platform where we build the binaries but we don't setup the testing infrastructure for CI?

@muZZkat
Copy link
Author

muZZkat commented Jan 9, 2023

@nirinchev I'm looking for the full setup, local & sync.

I was just looking at the build scripts, it seems to be a pretty simple change to produce a realm-wrappers.framework for tvOS and then drop that into my project.

Playstation/Switch support I'm not sure about yet, although with the realm-core source, I can't really see anything that might stop me adding those targets?

@nirinchev
Copy link
Member

Yes, just dropping the framework for tvOS should be sufficient, though there were some special casing we needed to do for iOS builds - e.g. here - I suspect we may need to do something similar for tvOS.

@muZZkat
Copy link
Author

muZZkat commented Jan 9, 2023

Correct, the Dll imports need to be "__Internal" on tvOS as well.

@muZZkat
Copy link
Author

muZZkat commented Jan 10, 2023

So I managed to hack things together today and got it working,

I Duplicated build-ios.ps1 and changed it to tvOS, this got me my realm-wrappers.framework for tvOS. Worked out of the box on Mac.

Updated and rebuilt the UnityWeaver dll, this wasn't so easy, I struggled with the developer environment on both Mac and Windows, but in the end, somehow got the Realm.UnityWeaver.dll build, although I was sure something was wrong when it was only 98K vs 250K in the latest release.

Added the new framework to a tvOS folder in downloaded package tarball

Replaced the Realm.UnityWeaver.dll and imported the tarball into Unity, I had errors around the Mono.Cecil reference, I assume this is why my dll was much smaller, does the packaged one include this? I worked around the issue by adding the Mono.Cecil package in unity.

I did try just adding the block of code from the UnityWeaver into my own build scripts but I had a access permissions issue on the Mono.Cecil, it was showing as a internal class.

So in the end, I now have it integrated and working (current just a read-only database) with OSX, Windows, Xbox, iOS, tvOS and Android. Awesome stuff.

Happy to work on submitting a PR if you are interested, outside the build environments it didn't require many changes.

Thanks for the help, I think I would have had no issues with the framework but the __Internal weaver would have stumped me.

@nirinchev
Copy link
Member

Hey, yeah, we're bundling all dependencies (notably Mono.Cecil) into the Realm.UnityWeaver.dll in order to avoid conflicts with other packages. Since Unity doesn't support NuGet or a similar package management system, if two libraries bring Mono.Cecil at different versions, Unity wouldn't be able to resolve this and you'd get build errors. By bundling the dependencies together, we get a slightly larger binary, but at least we know we're compatible with all other 3rd party products.

I think we'll try and add 1st party support for Apple TV in the near future, but if you've already done it and don't mind putting up a PR, that'll definitely speed up the process.

@fealebenpae
Copy link
Member

Hey @muZZkat I played around with our build scripts and also got a tvOS framework building. Thank you for offering but you don't need to submit a PR.

@muZZkat
Copy link
Author

muZZkat commented Jan 10, 2023

@fealebenpae nice one, I figured it was probably something that was just easier for someone on your team to add. Thanks again and my next challenge will be Playstation 4/5 support...

@ianpward
Copy link

@muZZkat Product for Realm here. I would be interested to learn a little about your app and use case and perhaps I can answer some questions on future projects we may take up. If you could drop me a line at [email protected] we can find a time to chat

@muZZkat
Copy link
Author

muZZkat commented Jan 26, 2023

FYI, I hit a little roadblock when i went to use a read/write database on tvOS as you don't have access to a file store (only key/value and CloudKit). For now, I've found using the cache directory works well and I store the user login information in the tvOS keystore, if the cache is deleted by tvOS, I simply re-sync the users data on launch.

@nirinchev nirinchev mentioned this issue Feb 1, 2023
2 tasks
@sync-by-unito sync-by-unito bot assigned nirinchev and unassigned fealebenpae Feb 1, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants