Using XSDE with iOS and XCode 4
From Code Synthesis Wiki
Revision as of 19:19, 21 March 2012 Boris (Talk | contribs) (→Building XSD/e runtime library for iOS - cosmetic changes) ← Previous diff |
Revision as of 19:21, 21 March 2012 Boris (Talk | contribs) (→Building XSD/e runtime library for iOS) Next diff → |
||
Line 32: | Line 32: | ||
: 5. Start XCode and perform the following steps: | : 5. Start XCode and perform the following steps: | ||
- | :: 5.1. Select "File"->"New"->"New Project" | + | :: 5.1. Select "File"->"New"->"New Project". |
:: 5.2. In the opened dialog select "iOS"-> "Framework & Library"->"Cocoa Touch Static Library". Click "Next". | :: 5.2. In the opened dialog select "iOS"-> "Framework & Library"->"Cocoa Touch Static Library". Click "Next". |
Revision as of 19:21, 21 March 2012
This page is a collection of notes on using XSD/e in iOS applications built with XCode 4. If you have useful information not listed on this page, please consider adding it.
Building XSD/e runtime library for iOS
To build the XSD/e runtime library (libxsde) for iOS with XCode 4 we use the config-xcode.make configuration file provided in the etc/ios/ directory in the XSD/e distribution. It implements a split build procedure where the XSD/e build system is used to generate the XSD/e configuration header (libxsde/xsde/config.h) as well as the list of source files that need to be compiled. Then the XCode project is created to compile the source files and build the libxsde.a library.
The following step-by-step instructions show how to build the XSD/e runtime library using this method. The next section shows how to integrate XSD/e into your application. To build the XSD/e runtime library (libxsde.a), perform the following steps:
- 1. Unpack the pre-compiled XSD/e package for Mac OS X. In the rest of the steps we will refer to the resulting XSD/e directory as xsde-x.y.z.
- 2. Start a new terminal window and run the following commands:
cd xsde-x.y.z cp etc/ios/config-xcode.make config/config.make
- Don't close the terminal.
- 3. Edit config/config.make and adjust the XSD/e configuration to suit your requirements.
- 4. In the terminal, execute:
cd libxsde make
- If the make command is not found, try /Developer/usr/bin/make (or your alternative XCode installation directory). Note that newer versions of XCode (e.g., 4.3) no longer come with Command Line Tools (which provide make) bundled by default. As a result, you may have to install them as a separate component during the XCode installation or as a separate download. Refer to the Apple developer site for more information.
- 5. Start XCode and perform the following steps:
- 5.1. Select "File"->"New"->"New Project".
- 5.2. In the opened dialog select "iOS"-> "Framework & Library"->"Cocoa Touch Static Library". Click "Next".
- 5.3. Enter "libxsde" for "Product Name" and "codesynthesis" for "Company Identifier". Uncheck "Include Unit Tests" and "Use Automatic Reference Counting". Click "Next".
- 5.4. In the opened dialog uncheck "Create local git repository for this project" and navigate to the xsde-x.y.z/libxsde directory. Click "Create".
- 5.5. In the Project Navigator delete the libxsde.h and libxsde.m files from the project.
- 5.6. In the Project Navigator Click on the libxsde project while holding the Ctrl key and select "Add files to libxsde" menu item.
- 5.7. In the opened dialog uncheck "Copy items into destination group's folder" and select "Create Groups for any added folders". Then navigate to xsde-x.y.z/libxsde/src directory and Click "Add". Now you should see multiple source files (.cxx and .c) listed in the "src" group.
- 5.8. Next open the Build Settings pane for the libxsde project and switch to the "All" view.
- 5.9. Scroll down to the "Search Paths" section and add .. (double dot) to the "Header Search Paths" fields for both Debug and Release.
- 5.10. Scroll down to the "Apple LLVM compiler 3.0 - Code Generation" section and change the "Symbols Hidden by Default" to yes for both Debug and Release.
- 5.11. Build the project for all the desired configurations (for example, Debug/Release, Device/Simulator, ARMv6/ARMv7, etc).
- 6. In the terminal window copy the libraries created by XCode and give them appropriate names, such as libxsde-dev.a, libxsde-dev-d.a, and libxsde-sim-d.a To find out the locations where XCode placed the built libraries look at the last line in the build log window. For example:
cp ~/Library/Developer/Xcode/DerivedData/libxsde-.../Build/Products/Release-iphoneos/liblibxsde.a libxsde-dev.a cp ~/Library/Developer/Xcode/DerivedData/libxsde-.../Build/Products/Debug-iphoneos/liblibxsde.a libxsde-dev-d.a cp ~/Library/Developer/Xcode/DerivedData/libxsde-.../Build/Products/Debug-iphonesimulator/liblibxsde.a libxsde-sim-d.a
If at some point you need to change the XSD/e configuration then it is best to start from scratch (step 1 above) since the set of files that is added to the XCode project may vary from configuration to configuration.
Integrating XSD/e into iOS application
Once the runtime library is built, to integrate XSD/e into your application perform the following steps:
- 1. Compile your schemas to C++ with the XSD/e compiler (xsde-x.y.z/bin/xsde) and add the resulting generated C++ files to your project.
- 2. To link your application to the XSD/e runtime library (libxsde), perform the following steps in your project:
- 2.1. Open the Build Settings pane for your project and switch to the "All" view.
- 2.2. Scroll down to the "Linking" section and in the "Other Linker Flags" add the -lxsde-dev-d, -lxsde-sim-d, and -lxsde-dev flags as shown below:
Debug Any iOS SDK: -lxsde-dev-d Any iOS Simulator SDK: -lxsde-sim-d Release Any iOS SDK: -lxsde-dev
- 2.3. Scroll down to the "Search Paths" section and add the path to the xsde-x.y.z/libxsde directory to both "Header Search Paths" and "Library Search Paths" fields for both Debug and Release.
- 3. Build the application.