nevans-iphone_testify 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,26 @@
1
+ == 0.0.1 / 2009-02-25
2
+
3
+ * Getting started
4
+
5
+ == 0.0.6 / 2009-02-25
6
+
7
+ * Tidy up.
8
+
9
+ * Adding growl pass/fail images for autotesting
10
+ * Adding UnitTests directory as part of skeleton
11
+
12
+ == 0.0.7
13
+
14
+ * added .gitignore
15
+ * detects more failure conditions in growl message: segmentation faults, more build errors
16
+ * moved bulk of Rake into separate file
17
+ * changed tasks to auto:test, an auto:test:all
18
+
19
+ == 0.1.10
20
+
21
+ * ./autoiphonetest.rb no longer goes through rake
22
+
23
+ == 0.1.11
24
+
25
+ * Default task added to Rakefile
26
+ * fix to .gitignore to ignore build
@@ -0,0 +1,90 @@
1
+ iphone_testify
2
+ by Paul Wilson
3
+ http://merecomplexities.com
4
+
5
+ == DESCRIPTION:
6
+
7
+ Utility to help set up and iPhone project for testing using code from {The Google Toolbox for Mac}[http://code.google.com/p/google-toolbox-for-mac/].
8
+
9
+ == FEATURES:
10
+
11
+ * Copies google test files into the "google_testing" directory
12
+ * Creates a UnitTests directory
13
+ * Adds Rakefile for compiling (via xcode) and reporting test failures (on console and via Growl)
14
+ * Adds an 'autoiphonetest.rb' file for _autotest_ style running of all tests when a change has been detected.
15
+
16
+ == TODO:
17
+
18
+ There are a few more things I'd like this gem to do.
19
+
20
+ * Generation of test stubs
21
+ * Automatic setup of _Unit Test_ target through XCode (via automation?)
22
+ * Automatic addition of test files to _Unit Test_ target
23
+
24
+ == SYNOPSIS:
25
+
26
+ From console cd to your project root directory. Type
27
+ % iphone_testify
28
+
29
+ Unfortunately there are some manual stages needed to add a _Unit Test_ target to your Xcode project. This is based on the {Google Toolbox Wiki instructions}[http://code.google.com/p/google-toolbox-for-mac/wiki/iPhoneUnitTesting]
30
+
31
+ 1. Create a new iPhone Target (Cocoa Touch Application) via "Project Menu > New Target..." called "Unit Test".
32
+ 2. Add all the ObjectiveC files that have been copied to your 'google_testing' directory to this target
33
+ 3. Add your project files to this target
34
+ 4. Add a new 'run script' build phase as the last step of your target build via "Project Menu > New Build Phase > New Run Script Build Phase", and dragging it to the end of the build steps if needed.
35
+ 5. Edit your Run Script Build Phase by double clicking it, and set the shell to "/bin/sh" and the script to "google_testing/RunIPhoneUnitTest.sh"
36
+
37
+
38
+ To autocompile/autorun all tests every time code changes
39
+
40
+ % ./autoiphonetest.rb
41
+
42
+
43
+ To compile and run tests if code has changed since the last run
44
+
45
+ % rake auto:test
46
+
47
+ To compile and run all tests even if nothing has changed since the last time
48
+
49
+ % rake auto:test:all
50
+
51
+
52
+
53
+ == REQUIREMENTS:
54
+
55
+ * OS X Leopard
56
+ * XCode 3.1 (containing the iPhone SDK)
57
+ * Ruby (comes on Leopard)
58
+
59
+ == INSTALL:
60
+
61
+ % sudo gem sources -a http://gems.github.com # (you only need to do this once)
62
+ % sudo gem install paulanthonywilson-iphone_testify
63
+
64
+ == LICENSE:
65
+
66
+ Contains file taken from {The Google Toolbox for Mac}[http://code.google.com/p/google-toolbox-for-mac/]. See skeleton/google_testing/GoogleToolboxForMac.license which is also copied into the google_testing directory.
67
+
68
+
69
+ (The MIT License)
70
+
71
+ Copyright (c) 2009
72
+
73
+ Permission is hereby granted, free of charge, to any person obtaining
74
+ a copy of this software and associated documentation files (the
75
+ 'Software'), to deal in the Software without restriction, including
76
+ without limitation the rights to use, copy, modify, merge, publish,
77
+ distribute, sublicense, and/or sell copies of the Software, and to
78
+ permit persons to whom the Software is furnished to do so, subject to
79
+ the following conditions:
80
+
81
+ The above copyright notice and this permission notice shall be
82
+ included in all copies or substantial portions of the Software.
83
+
84
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
85
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
86
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
87
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
88
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
89
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
90
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,34 @@
1
+ # Look in the tasks/setup.rb file for the various options that can be
2
+ # configured in this Rakefile. The .rake files in the tasks directory
3
+ # are where the options are used.
4
+
5
+ begin
6
+ require 'bones'
7
+ Bones.setup
8
+ rescue LoadError
9
+ begin
10
+ load 'tasks/setup.rb'
11
+ rescue LoadError
12
+ raise RuntimeError, '### please install the "bones" gem ###'
13
+ end
14
+ end
15
+
16
+ ensure_in_path 'lib'
17
+ require 'iphone_testify'
18
+
19
+ task :default => 'test:run'
20
+
21
+ PROJ.name = 'iphone_testify'
22
+ PROJ.authors = 'Paul Wilson'
23
+ PROJ.email = 'paul.wilson@merecomplexities.com'
24
+ PROJ.url = 'http://github.com/paulanthonywilson/iphone_testify/'
25
+ PROJ.version = IphoneTestify::VERSION
26
+
27
+ PROJ.exclude += ['\.gitignore', '\.DS_Store', '\.gem']
28
+ PROJ.notes.exclude = %w(^README\.txt$ ^data/)
29
+ PROJ.readme_file = 'README.rdoc'
30
+
31
+ depend_on "paulanthonywilson-osx_watchfolder"
32
+ depend_on "rake"
33
+
34
+ # EOF
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(
4
+ File.join(File.dirname(__FILE__), %w[.. lib iphone_testify]))
5
+
6
+ # Put your code here
7
+ IphoneTestify::Setup::setup
8
+
9
+ # EOF
@@ -0,0 +1,49 @@
1
+
2
+ module IphoneTestify
3
+ GEMDIR = File.expand_path(File.dirname(__FILE__) + "/..")
4
+ # :stopdoc:
5
+ VERSION = '0.1.12'
6
+ LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
+ PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
+ # :startdoc:
9
+
10
+ # Returns the version string for the library.
11
+ #
12
+ def self.version
13
+ VERSION
14
+ end
15
+
16
+ # Returns the library path for the module. If any arguments are given,
17
+ # they will be joined to the end of the libray path using
18
+ # <tt>File.join</tt>.
19
+ #
20
+ def self.libpath( *args )
21
+ args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
22
+ end
23
+
24
+ # Returns the lpath for the module. If any arguments are given,
25
+ # they will be joined to the end of the path using
26
+ # <tt>File.join</tt>.
27
+ #
28
+ def self.path( *args )
29
+ args.empty? ? PATH : ::File.join(PATH, args.flatten)
30
+ end
31
+
32
+ # Utility method used to require all files ending in .rb that lie in the
33
+ # directory below this file that has the same name as the filename passed
34
+ # in. Optionally, a specific _directory_ name can be passed in such that
35
+ # the _filename_ does not have to be equivalent to the directory.
36
+ #
37
+ def self.require_all_libs_relative_to( fname, dir = nil )
38
+ dir ||= ::File.basename(fname, '.*')
39
+ search_me = ::File.expand_path(
40
+ ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
41
+
42
+ Dir.glob(search_me).sort.each {|rb| require rb}
43
+ end
44
+
45
+ end # module IphoneTestify
46
+
47
+ IphoneTestify.require_all_libs_relative_to(__FILE__)
48
+
49
+ # EOF
@@ -0,0 +1,14 @@
1
+ require 'fileutils'
2
+
3
+ module IphoneTestify
4
+
5
+ module Setup
6
+ SKELETONDIR = GEMDIR + "/skeleton"
7
+ extend FileUtils
8
+ def self.setup
9
+ cp_r "#{SKELETONDIR}/.", "."
10
+ mv 'gitignore', '.gitignore', :force=>true
11
+ mkdir_p "UnitTests"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/autotest'
2
+
3
+ BUILD_STATUS_FILE=".built"
4
+
5
+
6
+ file BUILD_STATUS_FILE => Dir.glob("Classes/*.[hm]") + Dir.glob("UnitTests/*.m") do
7
+ notice = AutoTest::test_and_report
8
+ File.open(BUILD_STATUS_FILE, 'w') {|f| f.write(notice * ": ")}
9
+ end
10
+
11
+
12
+ task 'auto:remove_built_file' do
13
+ FileUtils.rm_f(BUILD_STATUS_FILE)
14
+ end
15
+
16
+ desc "build and run the tests "
17
+ task 'auto:test:all'=>['auto:remove_built_file', 'auto:test']
18
+
19
+ desc "build and run the tests if changed"
20
+ task 'auto:test'=>[BUILD_STATUS_FILE] do
21
+ out = File.open('.built') {|f| f.read}
22
+ print out.coloured(out =~ /Pass/ ? :green : :red) + "\n"
23
+ end
24
+
25
+
26
+
@@ -0,0 +1,4 @@
1
+ load 'Autotest.rake'
2
+
3
+
4
+ task :default => ['auto:test']
@@ -0,0 +1 @@
1
+ Put unit tests in this directory.
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + '/autotest'
4
+
5
+ require 'rubygems'
6
+
7
+ gem 'paulanthonywilson-osx_watchfolder'
8
+ gem 'rake'
9
+
10
+ require 'osx_watchfolder'
11
+
12
+ ARGV.clear
13
+ ARGV << 'auto:test:all'
14
+
15
+
16
+ AutoTest::test_and_report
17
+
18
+ OsxWatchfolder::FolderWatcher.new("Classes", "UnitTests") do
19
+ AutoTest::test_and_report
20
+ end.start
@@ -0,0 +1,76 @@
1
+ SIMULATOR_VERSION = "3.0"
2
+ class String
3
+ attr_accessor :colour
4
+ RESET="\e[00;m"
5
+
6
+ def coloured(colour = nil)
7
+ colour||=@colour
8
+ "#{colour_code(colour)}#{self}#{RESET}"
9
+ end
10
+
11
+ private
12
+ def colour_code colour
13
+ case colour
14
+ when :red : "\e[01;31m"
15
+ when :green : "\e[01;32m"
16
+ end
17
+ end
18
+ end
19
+
20
+ module AutoTest
21
+ def self.test_and_report
22
+ failure_line = test
23
+ report failure_line
24
+ end
25
+
26
+ def self.report failure_line
27
+ if failure_line
28
+ notice = ['Fail', failure_line.chomp]
29
+ else
30
+ notice = ['Pass']
31
+ end
32
+ AutoTest::growl *notice
33
+ puts failure_line.coloured if failure_line
34
+ notice
35
+ end
36
+
37
+ def self.run_test
38
+ puts "Build: #{Time::now}"
39
+ output = `xcodebuild -target "Unit Test" -configuration Debug -sdk iphonesimulator#{SIMULATOR_VERSION} 2>&1`
40
+ failure_line = nil
41
+ output.each do |line|
42
+ if line =~ /error:|^Executed.*(\d+) failures|Undefined symbols|PurpleSystemEventPort|FAILED|Segmentation fault/
43
+ if $1.nil? || $1.to_i > 0
44
+ failure_line||= line
45
+ line.colour = :red
46
+ else
47
+ line.colour = :green
48
+ end
49
+ end
50
+ print line.coloured unless line =~/Merge mismatch|setenv/
51
+ end
52
+ failure_line
53
+ end
54
+
55
+ def self.unable_to_run_test
56
+ "Unable to run tests as the simulator is already running"
57
+ end
58
+
59
+ def self.simulator_running?
60
+ !`ps -AO command`.split("\n").grep(/iPhoneSimulator.platform\/Developer\/Applications\/iPhone Simulator\.app/).empty?
61
+ end
62
+
63
+ def self.test
64
+ if simulator_running?
65
+ unable_to_run_test
66
+ else
67
+ run_test
68
+ end
69
+ end
70
+
71
+ def self.growl title, msg =""
72
+ img = "~/.autotest_images/#{title.downcase}.png"
73
+ `growlnotify -H localhost -n autotest --image #{img} -p 0 -m #{msg.inspect} #{title}`
74
+ end
75
+
76
+ end
@@ -0,0 +1,20 @@
1
+ .built
2
+ *tm_build_errors
3
+ # xcode noise
4
+
5
+ build/*
6
+ *.pbxuser
7
+ *.mode2v3
8
+ *.mode1v3
9
+ *.perspective
10
+ *.perspectivev3
11
+
12
+
13
+ # osx noise
14
+ .DS_Store
15
+ profile
16
+
17
+
18
+ *.swp
19
+ *~.nib
20
+
@@ -0,0 +1,268 @@
1
+ //
2
+ // GTMDefines.h
3
+ //
4
+ // Copyright 2008 Google Inc.
5
+ //
6
+ // Licensed under the Apache License, Version 2.0 (the "License"); you may not
7
+ // use this file except in compliance with the License. You may obtain a copy
8
+ // of the License at
9
+ //
10
+ // http://www.apache.org/licenses/LICENSE-2.0
11
+ //
12
+ // Unless required by applicable law or agreed to in writing, software
13
+ // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+ // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+ // License for the specific language governing permissions and limitations under
16
+ // the License.
17
+ //
18
+
19
+ // ============================================================================
20
+
21
+ #include <AvailabilityMacros.h>
22
+ #include <TargetConditionals.h>
23
+
24
+ // Not all MAC_OS_X_VERSION_10_X macros defined in past SDKs
25
+ #ifndef MAC_OS_X_VERSION_10_5
26
+ #define MAC_OS_X_VERSION_10_5 1050
27
+ #endif
28
+ #ifndef MAC_OS_X_VERSION_10_6
29
+ #define MAC_OS_X_VERSION_10_6 1060
30
+ #endif
31
+
32
+ // These definitions exist to allow headerdoc to parse this file.
33
+ // Headerdoc 8.6 gives warnings about misuses of MAC_OS_X_VERSION_MIN_REQUIRED
34
+ // and MAC_OS_X_VERSION_MAX_ALLOWED if you use them directly.
35
+ // By defining GTM versions with slightly different names (MIN vs MINIMUM)
36
+ // we get around headerdoc's issues. Hopefully we can work around this in the
37
+ // future and get rid of the GTM versions, so please use the default ones
38
+ // wherever you can.
39
+ #ifndef GTM_MAC_OS_X_VERSION_MINIMUM_REQUIRED
40
+ #define GTM_MAC_OS_X_VERSION_MINIMUM_REQUIRED MAC_OS_X_VERSION_MIN_REQUIRED
41
+ #endif
42
+
43
+ #ifndef GTM_MAC_OS_X_VERSION_MAXIMUM_ALLOWED
44
+ #define GTM_MAC_OS_X_VERSION_MAXIMUM_ALLOWED MAC_OS_X_VERSION_MAX_ALLOWED
45
+ #endif
46
+
47
+ // ----------------------------------------------------------------------------
48
+ // CPP symbols that can be overridden in a prefix to control how the toolbox
49
+ // is compiled.
50
+ // ----------------------------------------------------------------------------
51
+
52
+
53
+ // By setting the GTM_CONTAINERS_VALIDATION_FAILED_LOG and
54
+ // GTM_CONTAINERS_VALIDATION_FAILED_ASSERT macros you can control what happens
55
+ // when a validation fails. If you implement your own validators, you may want
56
+ // to control their internals using the same macros for consistency.
57
+ #ifndef GTM_CONTAINERS_VALIDATION_FAILED_ASSERT
58
+ #define GTM_CONTAINERS_VALIDATION_FAILED_ASSERT 0
59
+ #endif
60
+
61
+ // Give ourselves a consistent way to do inlines. Apple's macros even use
62
+ // a few different actual definitions, so we're based off of the foundation
63
+ // one.
64
+ #if !defined(GTM_INLINE)
65
+ #if defined (__GNUC__) && (__GNUC__ == 4)
66
+ #define GTM_INLINE static __inline__ __attribute__((always_inline))
67
+ #else
68
+ #define GTM_INLINE static __inline__
69
+ #endif
70
+ #endif
71
+
72
+ // Give ourselves a consistent way of doing externs that links up nicely
73
+ // when mixing objc and objc++
74
+ #if !defined (GTM_EXTERN)
75
+ #if defined __cplusplus
76
+ #define GTM_EXTERN extern "C"
77
+ #else
78
+ #define GTM_EXTERN extern
79
+ #endif
80
+ #endif
81
+
82
+ // Give ourselves a consistent way of exporting things if we have visibility
83
+ // set to hidden.
84
+ #if !defined (GTM_EXPORT)
85
+ #define GTM_EXPORT __attribute__((visibility("default")))
86
+ #endif
87
+
88
+ // _GTMDevLog & _GTMDevAssert
89
+ //
90
+ // _GTMDevLog & _GTMDevAssert are meant to be a very lightweight shell for
91
+ // developer level errors. This implementation simply macros to NSLog/NSAssert.
92
+ // It is not intended to be a general logging/reporting system.
93
+ //
94
+ // Please see http://code.google.com/p/google-toolbox-for-mac/wiki/DevLogNAssert
95
+ // for a little more background on the usage of these macros.
96
+ //
97
+ // _GTMDevLog log some error/problem in debug builds
98
+ // _GTMDevAssert assert if conditon isn't met w/in a method/function
99
+ // in all builds.
100
+ //
101
+ // To replace this system, just provide different macro definitions in your
102
+ // prefix header. Remember, any implementation you provide *must* be thread
103
+ // safe since this could be called by anything in what ever situtation it has
104
+ // been placed in.
105
+ //
106
+
107
+ // We only define the simple macros if nothing else has defined this.
108
+ #ifndef _GTMDevLog
109
+
110
+ #ifdef DEBUG
111
+ #define _GTMDevLog(...) NSLog(__VA_ARGS__)
112
+ #else
113
+ #define _GTMDevLog(...) do { } while (0)
114
+ #endif
115
+
116
+ #endif // _GTMDevLog
117
+
118
+ // Declared here so that it can easily be used for logging tracking if
119
+ // necessary. See GTMUnitTestDevLog.h for details.
120
+ @class NSString;
121
+ GTM_EXTERN void _GTMUnitTestDevLog(NSString *format, ...);
122
+
123
+ #ifndef _GTMDevAssert
124
+ // we directly invoke the NSAssert handler so we can pass on the varargs
125
+ // (NSAssert doesn't have a macro we can use that takes varargs)
126
+ #if !defined(NS_BLOCK_ASSERTIONS)
127
+ #define _GTMDevAssert(condition, ...) \
128
+ do { \
129
+ if (!(condition)) { \
130
+ [[NSAssertionHandler currentHandler] \
131
+ handleFailureInFunction:[NSString stringWithUTF8String:__PRETTY_FUNCTION__] \
132
+ file:[NSString stringWithUTF8String:__FILE__] \
133
+ lineNumber:__LINE__ \
134
+ description:__VA_ARGS__]; \
135
+ } \
136
+ } while(0)
137
+ #else // !defined(NS_BLOCK_ASSERTIONS)
138
+ #define _GTMDevAssert(condition, ...) do { } while (0)
139
+ #endif // !defined(NS_BLOCK_ASSERTIONS)
140
+
141
+ #endif // _GTMDevAssert
142
+
143
+ // _GTMCompileAssert
144
+ // _GTMCompileAssert is an assert that is meant to fire at compile time if you
145
+ // want to check things at compile instead of runtime. For example if you
146
+ // want to check that a wchar is 4 bytes instead of 2 you would use
147
+ // _GTMCompileAssert(sizeof(wchar_t) == 4, wchar_t_is_4_bytes_on_OS_X)
148
+ // Note that the second "arg" is not in quotes, and must be a valid processor
149
+ // symbol in it's own right (no spaces, punctuation etc).
150
+
151
+ // Wrapping this in an #ifndef allows external groups to define their own
152
+ // compile time assert scheme.
153
+ #ifndef _GTMCompileAssert
154
+ // We got this technique from here:
155
+ // http://unixjunkie.blogspot.com/2007/10/better-compile-time-asserts_29.html
156
+
157
+ #define _GTMCompileAssertSymbolInner(line, msg) _GTMCOMPILEASSERT ## line ## __ ## msg
158
+ #define _GTMCompileAssertSymbol(line, msg) _GTMCompileAssertSymbolInner(line, msg)
159
+ #define _GTMCompileAssert(test, msg) \
160
+ typedef char _GTMCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ]
161
+ #endif // _GTMCompileAssert
162
+
163
+ // Macro to allow fast enumeration when building for 10.5 or later, and
164
+ // reliance on NSEnumerator for 10.4. Remember, NSDictionary w/ FastEnumeration
165
+ // does keys, so pick the right thing, nothing is done on the FastEnumeration
166
+ // side to be sure you're getting what you wanted.
167
+ #ifndef GTM_FOREACH_OBJECT
168
+ #if TARGET_OS_IPHONE || (GTM_MAC_OS_X_VERSION_MINIMUM_REQUIRED >= MAC_OS_X_VERSION_10_5)
169
+ #define GTM_FOREACH_ENUMEREE(element, enumeration) \
170
+ for (element in enumeration)
171
+ #define GTM_FOREACH_OBJECT(element, collection) \
172
+ for (element in collection)
173
+ #define GTM_FOREACH_KEY(element, collection) \
174
+ for (element in collection)
175
+ #else
176
+ #define GTM_FOREACH_ENUMEREE(element, enumeration) \
177
+ for (NSEnumerator *_ ## element ## _enum = enumeration; \
178
+ (element = [_ ## element ## _enum nextObject]) != nil; )
179
+ #define GTM_FOREACH_OBJECT(element, collection) \
180
+ GTM_FOREACH_ENUMEREE(element, [collection objectEnumerator])
181
+ #define GTM_FOREACH_KEY(element, collection) \
182
+ GTM_FOREACH_ENUMEREE(element, [collection keyEnumerator])
183
+ #endif
184
+ #endif
185
+
186
+ // ============================================================================
187
+
188
+ // ----------------------------------------------------------------------------
189
+ // CPP symbols defined based on the project settings so the GTM code has
190
+ // simple things to test against w/o scattering the knowledge of project
191
+ // setting through all the code.
192
+ // ----------------------------------------------------------------------------
193
+
194
+ // Provide a single constant CPP symbol that all of GTM uses for ifdefing
195
+ // iPhone code.
196
+ #if TARGET_OS_IPHONE // iPhone SDK
197
+ // For iPhone specific stuff
198
+ #define GTM_IPHONE_SDK 1
199
+ #if TARGET_IPHONE_SIMULATOR
200
+ #define GTM_IPHONE_SIMULATOR 1
201
+ #else
202
+ #define GTM_IPHONE_DEVICE 1
203
+ #endif // TARGET_IPHONE_SIMULATOR
204
+ #else
205
+ // For MacOS specific stuff
206
+ #define GTM_MACOS_SDK 1
207
+ #endif
208
+
209
+ // Some of our own availability macros
210
+ #if GTM_MACOS_SDK
211
+ #define GTM_AVAILABLE_ONLY_ON_IPHONE UNAVAILABLE_ATTRIBUTE
212
+ #define GTM_AVAILABLE_ONLY_ON_MACOS
213
+ #else
214
+ #define GTM_AVAILABLE_ONLY_ON_IPHONE
215
+ #define GTM_AVAILABLE_ONLY_ON_MACOS UNAVAILABLE_ATTRIBUTE
216
+ #endif
217
+
218
+ // Provide a symbol to include/exclude extra code for GC support. (This mainly
219
+ // just controls the inclusion of finalize methods).
220
+ #ifndef GTM_SUPPORT_GC
221
+ #if GTM_IPHONE_SDK
222
+ // iPhone never needs GC
223
+ #define GTM_SUPPORT_GC 0
224
+ #else
225
+ // We can't find a symbol to tell if GC is supported/required, so best we
226
+ // do on Mac targets is include it if we're on 10.5 or later.
227
+ #if GTM_MAC_OS_X_VERSION_MAXIMUM_ALLOWED <= MAC_OS_X_VERSION_10_4
228
+ #define GTM_SUPPORT_GC 0
229
+ #else
230
+ #define GTM_SUPPORT_GC 1
231
+ #endif
232
+ #endif
233
+ #endif
234
+
235
+ // To simplify support for 64bit (and Leopard in general), we provide the type
236
+ // defines for non Leopard SDKs
237
+ #if GTM_MAC_OS_X_VERSION_MAXIMUM_ALLOWED <= MAC_OS_X_VERSION_10_4
238
+ // NSInteger/NSUInteger and Max/Mins
239
+ #ifndef NSINTEGER_DEFINED
240
+ #if __LP64__ || NS_BUILD_32_LIKE_64
241
+ typedef long NSInteger;
242
+ typedef unsigned long NSUInteger;
243
+ #else
244
+ typedef int NSInteger;
245
+ typedef unsigned int NSUInteger;
246
+ #endif
247
+ #define NSIntegerMax LONG_MAX
248
+ #define NSIntegerMin LONG_MIN
249
+ #define NSUIntegerMax ULONG_MAX
250
+ #define NSINTEGER_DEFINED 1
251
+ #endif // NSINTEGER_DEFINED
252
+ // CGFloat
253
+ #ifndef CGFLOAT_DEFINED
254
+ #if defined(__LP64__) && __LP64__
255
+ // This really is an untested path (64bit on Tiger?)
256
+ typedef double CGFloat;
257
+ #define CGFLOAT_MIN DBL_MIN
258
+ #define CGFLOAT_MAX DBL_MAX
259
+ #define CGFLOAT_IS_DOUBLE 1
260
+ #else /* !defined(__LP64__) || !__LP64__ */
261
+ typedef float CGFloat;
262
+ #define CGFLOAT_MIN FLT_MIN
263
+ #define CGFLOAT_MAX FLT_MAX
264
+ #define CGFLOAT_IS_DOUBLE 0
265
+ #endif /* !defined(__LP64__) || !__LP64__ */
266
+ #define CGFLOAT_DEFINED 1
267
+ #endif // CGFLOAT_DEFINED
268
+ #endif // GTM_MAC_OS_X_VERSION_MAXIMUM_ALLOWED <= MAC_OS_X_VERSION_10_4