Permalink
Browse files

fixed CocoaPods build

  • Loading branch information...
1 parent 1c726aa commit 5bfcc9c1915910e41b4e00a1bf56cd0c4ebe1b69 @explicitcall committed Jan 20, 2013
Showing with 2 additions and 1 deletion.
  1. +2 −1 Source/TDRouter.m
View
@@ -30,12 +30,13 @@
#import <objc/message.h>
#endif
-
+#ifndef COCOAPODS_BUILD
#ifdef GNUSTEP
static double TouchDBVersionNumber = 0.7;
#else
extern double TouchDBVersionNumber; // Defined in Xcode-generated TouchDB_vers.c
#endif
+#endif
@interface TDRouter (Handlers)

4 comments on commit 5bfcc9c

snej replied Jan 22, 2013

Where does TouchDBVersionNumber get declared, then? It's used farther down in the +versionString method, but you've removed the place it's declared. (And why is this necessary?)

Owner

explicitcall replied Jan 22, 2013

ok, I've got it, latest available podspec has this:

    if path =~ /TDServer\.m/
      f.puts "const unsigned char TouchDBVersionString[] __attribute__ ((used)) = \"@(#)PROGRAM:TouchDB  PROJECT:TouchDB-#{version}\";"
      f.puts "const double TouchDBVersionNumber __attribute__ ((used)) = (double)#{version};"
    end

but TDServer.m is not available at all in 1.01. Where and in which way TouchDBVersionNumber should be defined at all? Because TouchDB_vers.c isn't generated when building from CocoaPods.

Owner

explicitcall replied Jan 22, 2013

#ifndef COCOAPODS_BUILD was introduced essentially to solve this exact problem: in my updated podspec `static double TouchDBVersionNumber = #{version}' was written directly, like this:

if path =~ /TDRouter\.m/
    f.puts "static double TouchDBVersionNumber = #{version};"
end

because TouchDB_vers.c isn't generated when building from CocoaPods. Making this #ifndef and code injection is much easier than transplanting TouchDB_vers.c generation from origin Xcode project file.

snej replied Jan 22, 2013

but TDServer.m is not available at all in 1.01.

It was renamed to TD_Server.m.

Making this #ifndef and code injection is much easier than transplanting TouchDB_vers.c generation from origin Xcode project file.

Sure, but you won't get an accurate version number. This is part of why I'm skeptical of CocoaPods; there is more to a project than just its source files. I don't think it's a wise idea to just dump all the source files of all the libraries you want to use into your Xcode project and expect them to build and run correctly.

Please sign in to comment.