My game engine is currently in beta phase. I have not released the engine to the public yet. Part of it is due to unresolved bugs present in the engine. Although the engine can handle a full blown game, such as a soccer game , I'm afraid that it is not ready for prime time.
Regardless if I release the engine to the public or not, I am interested in knowing how I would create my engine into a distributable framework using Xcode. It turns out that creating a framework using Xcode is very simple.
These are the steps to create a framework in Xcode:
Creating a framework
Create a new project and select "Cocoa Touch Framework."
Give your framework a name and select "Objective-C" as the language. Make sure the "Include Unit Tests" box is unchecked.
Xcode will generate a header file with the name of your framework. In this header file, we will include the header files of your API. So let's create the API.
Create a file representing your API and give it a name. I called the files "MyAPI."
Step 4 (Optional):
You don't have to do this if you code in Objective-C. But I like to code in C++; thus I need to change the extension of the files to ".mm" as shown in the image below.
Declare and implement your API files. In this example, I created a class with a "printHello" method.
Your users will not be able to use your framework unless you make the API header files Public. If you select the MyAPI header file and open up Xcode Utility pane, you will notice that under "Target Membership" the header file is set to "Project."
Make sure to set the header file to "Public."
Now, we need to import all the public header files of your API. To do so, open up the framework header file "MyFirstFramework.h" and import all public header files of your API. See highlighted line in the image below:
Here is a larger image. See line 20.
Select Product->Build to build the framework. You can also use Command+B to build it.
At this point, the framework is ready to be distributed to your users.
If you need to locate your framework, right-click on the framework and click "Show in Finder." See the image below.
Testing your Framework
Let's test your framework in a new project. Create a new "Single View Application" project in Xcode.
Give it a name and select "Objective-C" as the language.
Copy your framework into the new project. To locate your framework, see Step 9 above.
We need to make sure that the new project has the proper settings before it can use the framework.
Click on Build Phases and make sure that your framework is in the Link Binary With Libraries section.
Click on General. You will notice that the Embedded Binaries section doesn't include the framework.
Add the framework in the Embedded Binaries section.
You will notice that the Linked Frameworks and Libraries section contains a duplicate copy of the framework. Remove one of the copies.
Step 7 (Optional):
Since I use C++ in the framework, I need to change the extension of the AppDelegate and ViewController files to use the ".mm" extension.
Now you are ready to use the framework in the new project. Import the framework as shown in line 11 in the image below. You can now call the API classes as shown in the "viewDidLoad" method in the image below.
Build and run the project. And that is it.
Hope this helps.