TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Cloudkit app with same codebase, macOS uses development database, iOS uses production

Forums > Swift

I have this situation where I released an app with the same code base for iOS and macOS. I use Xcode-cloud for the processing of the apps and let Xcode and Xcode-cloud handle all my signing.

However, the resulting apps, both retrieved from the App Stores, cannot share data together via Cloudkit as the iOS version is using the correct production version and the macOS version is using the wrong development version of the application.

I already embedded cloudkit.framework as mentioned here: https://developer.apple.com/forums/thread/717838

How can I fix this?

1      

Hey Vithanco,

I feel your frustration! Having the wrong CloudKit environment for your macOS app can definitely cause issues. Here are a couple of solutions to get your CloudKit app working seamlessly with the same codebase:

Use Xcode entitlements for macOS development environment:

You can configure Xcode to use the development CloudKit container for your macOS app during development, even if the codebase is the same as the production iOS app. This involves creating an entitlements file and specifying the development container environment variable. You can find detailed instructions in Apple's documentation: https://developer.apple.com/documentation/cloudkit

Separate Code Paths for CloudKit Environment:

If you prefer to keep the development and production environments completely separate, you can introduce a conditional statement within your code that checks the running platform (macOS or iOS) and uses the appropriate CloudKit container identifier. This approach requires minor code changes but ensures complete isolation between development and production environments.

   

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.