Как совместно использовать/распределить скомпилированный код Objective C (как JAR в Java)?

Можно просто скорректировать ограничения:

where T : class

Тогда пустой указатель возврата позволяется.

7
задан Community 23 May 2017 в 11:47
поделиться

5 ответов

A framework is almost certainly the way to go. One of the really nice things about Frameworks on OS X is that they can bundle the executable code, headers, metadata, images, icons, etc. in a single package. Further, frameworks can be included in */Library/Frameworks/ or even inside your app bundle to completely decouple from any other app's dependency on a given version of the framework.

Apple's Framework Programming Guide is the best place to get started with frameworks.

Creating a framework is simple. Basically, in Xcode you choose File > New Project... and select Framework, then Cocoa Framework. This will set up a new project with framework target and automatically package everything up for you when you build.

Don't forget that documentation and unit tests are a Good Thing™, especially for frameworks, which are inherently more likely to be used by multiple clients than most end-user code. You can add more targets to your framework Xcode project to document and test it.

Since you're looking for examples, check out CHDataStructures.framework (a project which I develop) and PSMTabBarControl.framework (which includes lots of extra resources in the framework). Both are open-source, and should provide adequate examples for rolling your own.

One word of advice to save you some head-scratching: your header files will not be copied to the built framework unless you click on the framework target and change the Role to "Public" (or "Private").

7
ответ дан 6 December 2019 в 21:18
поделиться

Вы хотите создать Framework. В Xcode есть отправная точка для нового проекта по созданию одного из них. Есть несколько предостережений и ошибок, но в целом процесс прост.

Изменить: Для пояснения: если вы планируете распространять его как FOSS; упаковать это в рамки могло бы быть излишним; просто распространение исходного кода могло бы быть более разумным и простым вариантом. Но если вы хотите сохранить исходный код при себе или распространять его вместе с набором соответствующих ресурсов, фреймворк определенно может быть хорошей идеей.

Reedit: для введения см. http://developer.apple .com / documentation / MacOSX / Conceptual / BPFrameworks /

5
ответ дан 6 December 2019 в 21:18
поделиться

Вы не сказали, было ли это для iPhone или нет. На iPhone это должна быть .sa (статически связанная библиотека), но я думаю, что нормальным распределением будет .dylib или .so

1
ответ дан 6 December 2019 в 21:18
поделиться

Java programs run in the context of a virtual machine. Jar contains abstract bytecodes which must be converted into native machine code by the VM.

Objective-C, like C, is compiled into native machine code, such as a Win .exe file, directly runnable by the operating system.

Most programs of any complexity consist of more than a single file and include DLLs, icon files, etc. The configuration of your files for distribution would usually be handled by a setup utility.

-1
ответ дан 6 December 2019 в 21:18
поделиться

Вы можете скомпилировать его как фреймворк или как статическую библиотеку (как я полагаю).

0
ответ дан 6 December 2019 в 21:18
поделиться
Другие вопросы по тегам:

Похожие вопросы: