We have a fairly rich e-learning app, built mostly using cocos2d. Currently we are in alpha and want to setup our project structure so we can also build a Mac version to target the Mac App store. It is about 80% cocos2d with some intitial screens in UIKit which will have to be ported to Mac (re-written).
我们有一个相当丰富的电子学习应用程序,主要使用cocos2d构建。目前我们处于alpha状态并希望设置我们的项目结构,因此我们还可以构建一个Mac版本来定位Mac App商店。它是大约80%的cocos2d,在UIKit中有一些初始屏幕,必须移植到Mac(重写)。
What is the recommended setup for targeting both the Mac and iOS app stores from a single code base? I assume the choices are:
从单个代码库中定位Mac和iOS应用商店的建议设置是什么?我假设选择是:
- Create 2 xCode projects in the same application source code root folder and use each project to build a single target. This would be: Project.xcodeproj and ProjectMac.xcodeproj
- Add a new Mac target to our existing iPad application project and then fiddle with target membership to get the desired results. This would be just: Project.xcodeproj
在同一应用程序源代码根文件夹中创建2个xCode项目,并使用每个项目构建单个目标。这将是:Project.xcodeproj和ProjectMac.xcodeproj
将新的Mac目标添加到我们现有的iPad应用程序项目中,然后调整目标成员资格以获得所需的结果。这只是:Project.xcodeproj
Further complicating the situation is that we currently use cocos2d as a static library for the iOS app. We also have a library called CoreInfrastructure that has a lot of code we use across all our projects. Recently I have figured out that I can create a project to simultaneously build a framework targeting Mac and a library targeting iOS from the same code base. This is done by starting with a framework project and adding a target to build a static lib for iOS.
更复杂的是,我们目前使用cocos2d作为iOS应用程序的静态库。我们还有一个名为CoreInfrastructure的库,它包含我们在所有项目中使用的大量代码。最近我发现我可以创建一个项目来同时构建一个面向Mac的框架和一个基于相同代码库的iOS库。这是通过从框架项目开始并添加目标来为iOS构建静态库来完成的。
So just wanted to get everyone's opinion and insight. Anyone know of any caveats to watch out for in the above choices? Anyone who is building for Mac and iOS app stores simultaneously care to share their structure? Adding a target worked on our library code ... is that the way to go for the application as well?
所以只是想得到每个人的意见和见解。有人知道在上述选择中要注意的任何警告吗?任何为Mac和iOS应用程序商店构建的人都会同时分享他们的结构吗?在我们的库代码上添加一个目标...是应用程序的方法吗?
Are there any issues doing archive and distribution builds for either choice?
是否存在任何选择存档和分发版本的问题?
Thanks in advance.
提前致谢。
4 个解决方案
#1
3
For the applications use two separate projects. Using multiple targets for iOS and Mac in one project is very useful if they are sharing a library or framework. However, in your top level application almost nothing is shared. The UIKit code will need to be totally rewritten to use AppKit, the dependencies will be different, and even most of the project settings will vary.
对于应用程序,使用两个单独的项如果他们共享库或框架,则在一个项目中使用iOS和Mac的多个目标非常有用。但是,在您的*应用程序中几乎没有任何共享。 UIKit代码需要完全重写才能使用AppKit,依赖关系会有所不同,甚至大多数项目设置都会有所不同。
Of course if you really want to see everything at once you can put both platform specific application projects and all the shared dependent library/framework projects in a single workspace. This is more a question of work style. If you want to switch back and forth between the two frequently this makes the most sense. If you want to simplify what you are looking at you can put them in separate workspaces that share many of the same projects. Separate workspaces has the disadvantage that a project can only be open in one workspace at a time so you effectively can only work on one at a time.
当然,如果您真的想立即查看所有内容,可以将平台特定的应用程序项目和所有共享的依赖库/框架项目放在一个工作区中。这更像是一种工作作风的问题。如果你想经常在两者之间来回切换,这是最有意义的。如果您想简化您所看到的内容,可以将它们放在共享许多相同项目的单独工作区中。单独的工作空间的缺点是项目一次只能在一个工作空间中打开,因此您实际上只能一次处理一个项目。
#2
16
WWDC session "Sharing code between iOS and OS X" answers all the basic questions in this topic. iWork team presented how they have got away with creating Pages, Keynote and Numbers with shared code base for both iOS and OS X.
WWDC会话“在iOS和OS X之间共享代码”回答了本主题中的所有基本问题。 iWork团队介绍了如何使用iOS和OS X的共享代码库创建Pages,Keynote和Numbers。
The key for their project was using:
他们的项目的关键是使用:
- separate Xcode targets for iOS and OS X
- separate project for the shared code in a form of a .framework
- target dependency on the framework from the point above
为iOS和OS X分离Xcode目标
以.framework的形式分离共享代码的项目
从上面的角度看目标对框架的依赖性
I encourage to watch the video or read the transcript from this session:
我鼓励观看视频或阅读本次会议的成绩单:
WWDC 2014 Sharing code between iOS and OS X
WWDC 2014在iOS和OS X之间共享代码
#3
4
I recently used kstenerud's iOS Universal Framework to build a shared framework codebase that works for both iOS and Mac apps. I just needed to manually add a target for a Cocoa framework after I had created a project for an iOS framework. That way I can develop the sharable code once in the framework and link it in both the iOS and Mac apps. You can even make the framework contain UIKit-specific code for your iOS app and AppKit-specific code for your Mac apps. I wrote about it in my blog if you are interested.
我最近使用kstenerud的iOS Universal Framework来构建适用于iOS和Mac应用程序的共享框架代码库。在为iOS框架创建项目之后,我只需要为Cocoa框架手动添加目标。这样我就可以在框架中开发一次可共享代码,并将其链接到iOS和Mac应用程序中。您甚至可以使框架包含适用于iOS应用程序的UIKit特定代码和适用于Mac应用程序的AppKit特定代码。如果你有兴趣,我会在我的博客中写到这个。
#4
3
I just use multi-platform static library targets for the shared sources. You will need to expand that to the dependencies, however. If you have platform dependent implementations, you may want to create supplemental export libraries for those symbols.
我只是为共享源使用多平台静态库目标。但是,您需要将其扩展为依赖项。如果您具有依赖于平台的实现,则可能需要为这些符号创建补充导出库。
So your structure might take this form:
所以你的结构可能采用这种形式:
- CoreInfrastructure - cross platform static library.
- PlatShared - cross platform static library.
- PlatSpecific-OS X - OS X static library (or framework).
- PlatSpecific-iOS - iOS static library.
CoreInfrastructure - 跨平台静态库。
PlatShared - 跨平台静态库。
PlatSpecific-OS X - OS X静态库(或框架)。
PlatSpecific-iOS - iOS静态库。
The OS X app links to CoreInfrastructure, PlatShared, PlatSpecific-OSX, Cocos for OS X, and system libs.
OS X应用程序链接到CoreInfrastructure,PlatShared,PlatSpecific-OSX,OS X的Cocos和系统库。
The iOS app links to CoreInfrastructure, PlatShared, PlatSpecific-iOS, Cocos for iOS, and sys libs.
iOS应用程序链接到CoreInfrastructure,PlatShared,PlatSpecific-iOS,适用于iOS的Cocos和sys libs。
Problem (I've found) is, there are a lot of people who have not had much/any experience developing and maintaining complex project structures in Xcode. It's a pain (IMO) to setup duplicate targets, and properly maintain them as they grow -- even when they all refer to the same source files. That's why i prefer minimal targets and proper dependency structure.
问题(我发现)是,有很多人在Xcode中开发和维护复杂的项目结构没有太多/任何经验。设置重复目标并在它们增长时正确维护它们是一种痛苦(IMO) - 即使它们都引用相同的源文件也是如此。这就是为什么我更喜欢最小目标和适当的依赖结构。
#1
3
For the applications use two separate projects. Using multiple targets for iOS and Mac in one project is very useful if they are sharing a library or framework. However, in your top level application almost nothing is shared. The UIKit code will need to be totally rewritten to use AppKit, the dependencies will be different, and even most of the project settings will vary.
对于应用程序,使用两个单独的项如果他们共享库或框架,则在一个项目中使用iOS和Mac的多个目标非常有用。但是,在您的*应用程序中几乎没有任何共享。 UIKit代码需要完全重写才能使用AppKit,依赖关系会有所不同,甚至大多数项目设置都会有所不同。
Of course if you really want to see everything at once you can put both platform specific application projects and all the shared dependent library/framework projects in a single workspace. This is more a question of work style. If you want to switch back and forth between the two frequently this makes the most sense. If you want to simplify what you are looking at you can put them in separate workspaces that share many of the same projects. Separate workspaces has the disadvantage that a project can only be open in one workspace at a time so you effectively can only work on one at a time.
当然,如果您真的想立即查看所有内容,可以将平台特定的应用程序项目和所有共享的依赖库/框架项目放在一个工作区中。这更像是一种工作作风的问题。如果你想经常在两者之间来回切换,这是最有意义的。如果您想简化您所看到的内容,可以将它们放在共享许多相同项目的单独工作区中。单独的工作空间的缺点是项目一次只能在一个工作空间中打开,因此您实际上只能一次处理一个项目。
#2
16
WWDC session "Sharing code between iOS and OS X" answers all the basic questions in this topic. iWork team presented how they have got away with creating Pages, Keynote and Numbers with shared code base for both iOS and OS X.
WWDC会话“在iOS和OS X之间共享代码”回答了本主题中的所有基本问题。 iWork团队介绍了如何使用iOS和OS X的共享代码库创建Pages,Keynote和Numbers。
The key for their project was using:
他们的项目的关键是使用:
- separate Xcode targets for iOS and OS X
- separate project for the shared code in a form of a .framework
- target dependency on the framework from the point above
为iOS和OS X分离Xcode目标
以.framework的形式分离共享代码的项目
从上面的角度看目标对框架的依赖性
I encourage to watch the video or read the transcript from this session:
我鼓励观看视频或阅读本次会议的成绩单:
WWDC 2014 Sharing code between iOS and OS X
WWDC 2014在iOS和OS X之间共享代码
#3
4
I recently used kstenerud's iOS Universal Framework to build a shared framework codebase that works for both iOS and Mac apps. I just needed to manually add a target for a Cocoa framework after I had created a project for an iOS framework. That way I can develop the sharable code once in the framework and link it in both the iOS and Mac apps. You can even make the framework contain UIKit-specific code for your iOS app and AppKit-specific code for your Mac apps. I wrote about it in my blog if you are interested.
我最近使用kstenerud的iOS Universal Framework来构建适用于iOS和Mac应用程序的共享框架代码库。在为iOS框架创建项目之后,我只需要为Cocoa框架手动添加目标。这样我就可以在框架中开发一次可共享代码,并将其链接到iOS和Mac应用程序中。您甚至可以使框架包含适用于iOS应用程序的UIKit特定代码和适用于Mac应用程序的AppKit特定代码。如果你有兴趣,我会在我的博客中写到这个。
#4
3
I just use multi-platform static library targets for the shared sources. You will need to expand that to the dependencies, however. If you have platform dependent implementations, you may want to create supplemental export libraries for those symbols.
我只是为共享源使用多平台静态库目标。但是,您需要将其扩展为依赖项。如果您具有依赖于平台的实现,则可能需要为这些符号创建补充导出库。
So your structure might take this form:
所以你的结构可能采用这种形式:
- CoreInfrastructure - cross platform static library.
- PlatShared - cross platform static library.
- PlatSpecific-OS X - OS X static library (or framework).
- PlatSpecific-iOS - iOS static library.
CoreInfrastructure - 跨平台静态库。
PlatShared - 跨平台静态库。
PlatSpecific-OS X - OS X静态库(或框架)。
PlatSpecific-iOS - iOS静态库。
The OS X app links to CoreInfrastructure, PlatShared, PlatSpecific-OSX, Cocos for OS X, and system libs.
OS X应用程序链接到CoreInfrastructure,PlatShared,PlatSpecific-OSX,OS X的Cocos和系统库。
The iOS app links to CoreInfrastructure, PlatShared, PlatSpecific-iOS, Cocos for iOS, and sys libs.
iOS应用程序链接到CoreInfrastructure,PlatShared,PlatSpecific-iOS,适用于iOS的Cocos和sys libs。
Problem (I've found) is, there are a lot of people who have not had much/any experience developing and maintaining complex project structures in Xcode. It's a pain (IMO) to setup duplicate targets, and properly maintain them as they grow -- even when they all refer to the same source files. That's why i prefer minimal targets and proper dependency structure.
问题(我发现)是,有很多人在Xcode中开发和维护复杂的项目结构没有太多/任何经验。设置重复目标并在它们增长时正确维护它们是一种痛苦(IMO) - 即使它们都引用相同的源文件也是如此。这就是为什么我更喜欢最小目标和适当的依赖结构。