How to create a single shared framework between iOS and OS X

后端 未结 2 367
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 12:29

I am attempting to create a framework to hold the common entity classes for an app that runs on iOS and OS X. Currently I am just including the files in each target but that

2条回答
  •  春和景丽
    2020-12-02 12:53

    It turns out the answer is super simple but not very obvious, at least not until after I posted this question and worked on something else.

    All that needs to be done is to make a framework target for each platform but then set the product names to be the same. As this is also the module name in Swift you can then set the class field in the Core Data model to one value and have it work on both platforms.

    The setup I'm using is to include the model files in both frameworks but to include the model itself directly into each app target.

    You should also be able to set both apps to have the same product name and have everything work but I didn't test it and the frameworks allow you to have MyApp and MyAppMobile if you want.

提交回复
热议问题