开发者

Sharing business logic code between iOS and Mac OS applications

开发者 https://www.devze.com 2023-02-03 16:17 出处:网络
I have an iOS application which I am considering porting to also run on Mac O开发者_Python百科S and sell via the Mac App Store. However I would like to have as much code re-use as possible for the bus

I have an iOS application which I am considering porting to also run on Mac O开发者_Python百科S and sell via the Mac App Store. However I would like to have as much code re-use as possible for the business logic, so that if I fix a bug in one product I won't have to re-code everything for the other product. What is the best way to do this? With a universal iPad/iPhone app, there are simply two targets, but obviously for a Mac OS app the whole structure is different and it uses an entirely different SDK. Any suggestions? Thank you!


The best way to do this would be to add a Cocoa application target to your project. Go to Project>New Target and choose Cocoa>Application from the Mac OS X section. Then, with your new target selected, click the checkboxes to include the shared files.


Another thing you can do is simply add the files from one project as references to the other one. Simply drag them from the source project (where the actual files reside) into the other project. The dialog will ask you whether you want to copy the files. Choose no. This will make the second project point to the files in the first project. Edits go into both projects.

Be careful with this, though, as there are a few differences between APIs in iOS and MacOS, even if they are called the same.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号