Solved

How to support visionOS via Cocoapods?

  • 27 October 2023
  • 6 replies
  • 269 views

Badge +4

I am having trouble getting RevenueCat to work properly in my project when building for visionOS, integrating via CocoaPods. The problem seems to come from lines like this:

#if os(iOS) || targetEnvironment(macCatalyst) || VISION_OS

where VISION_OS is not defined, even when building for visionOS, causing the code to take the wrong path.

How is this supposed to work? I can’t quite figure out where VISION_OS is supposed to be defined. Is there a reason this isn’t just using #if os(visionOS)? Any help or workaround you could provide would be much appreciated!

Using Xcode 15.1 beta 2.

icon

Best answer by cody 31 October 2023, 17:54

View original

6 replies

Badge +4

I was able to hack this in by adding the appropriate flag into the build settings, but it seems like this should be in the podspec:

config.build_settings['OTHER_SWIFT_FLAGS[sdk=xros*]'] = "$(inherited) -D VISION_OS"
config.build_settings['OTHER_SWIFT_FLAGS[sdk=xrsimulator*]'] = "$(inherited) -D VISION_OS"

 

Userlevel 5
Badge +8

Hey @chrisvasselli!

We’re looking at supporting this, currently blocked by CocoaPods: https://github.com/RevenueCat/purchases-ios/pull/3262

Any update on this? VisionOS launch is right around the corner...

And just as a follow-up, is this going to be supported through Unity? The external dependency manager doesn’t even attempt to run when targeting visionOS in Unity (iOS build target works fine). I’ve made a number of modifications to purchases-unity to get it to “appear” to work, but EDM doesn’t run the cocoapods part. Does something have to get updated in the dependencies xml in the RevenueCat plugin editor folder?

In any case, I tried to just skip this step by bringing over the generated Podfile created via an iOS build target Unity project. I modified the podfile to use visonos instead of ios, but upon running pod install / pod update, it fails because the purchases-hybrid-common isn’t published as having visionos support.

So, this is a dead end. I’ve looked at your PR which says it’s blocked by CocoaPods, but the referenced CocoaPods PR (https://github.com/CocoaPods/CocoaPods/pull/11965#issuecomment-1743878949) has been merged. So, what’s the hold up on getting the RevenueCat side of things merged in?

The website documentation (and the code repos) indicate VisionOS as a supported platform, but that doesn’t seem to be the case.

Userlevel 1
Badge +5

@chrisvasselli @dustin_tripp we just released updates to our iOS and visionOS SDKs with visionOS support on CocoaPods. Thank you for your patience!

Badge +4

Thanks! 🙏

Reply