Game Development Reference
In-Depth Information
you can also differentiate between iOS device and iOS Simulator by using the macros
KK_PLATFORM_IOS_DEVICE and KK_PLATFORM_IOS_SIMULATOR .
The real reason for not using preprocessor macros and why conditional compilation
with #ifdef should be used only as a last-resort measure is this: the compiler is your
friend! Every time your code is compiled, the compiler lets you know that everything is
in order or tells you whatever is technically or syntactically wrong with your code. It
may be annoying at times, but the compiler is only letting you know that you made a
mistake or forgot something. Allowing as much code as possible to be compiled by the
compiler every time you build the code is so important for cross-platform development
that the added overhead of platform and device runtime tests are entirely negligible.
Once you do cross-platform development, you'll likely spend a lot of time working on
and compiling code for only one platform. Any code that's within an #ifdef for the
other platform is invisible to the compiler, and it won't complain about errors. Now as
soon as you switch targets and compile for the other platform, you'll likely run into er-
rors that were thus far ignored due to the use of #ifdef . These errors may be related
to code changes that you made an hour ago, a day ago, or maybe even a week ago.
Not only does it cause a lot of mental load to figure out which code change caused the
error and what the correct fix will be, it's also frustrating because you'll frequently find
that switching target platforms results in build failures. Either you'll spend more time
than necessary building code regularly for both target platforms or you'll simply give
up, maybe with the good intention of porting the project when it's finished. However,
porting a completed project is much more work than developing it for both platforms
from the beginning.
Code that compiles works. At least it's technically correct. Immediate build errors are
more likely to be corrected right away and easier to fix because you still have the most
recent code changes in your short-term memory.
Running Hello World with iSimulate
To enable iSimulate you have to open the BuildSettings-iOS.xcconfig file,
which is located in the BuildSettings group of your Kobold2D project. The only
thing you have to do is to remove the comment from this line:
OTHER_LDFLAGS[sdk = iphonesimulator*][arch = *] = $(OTHER_LDFLAGS) $(FORCE_LOAD_ISIMULATE)
Search Nedrilad ::




Custom Search