2014-01-14 4 views
9

ich das Tutorial folgte für die Erstellung SQLCipher auf iOS-Geräten eine binäre hier befindet sich mit: http://sqlcipher.net/sqlcipher-binaries-ios-and-osx/ARC Fehler mit FMDB Klasse, nachdem Änderungen an Gebäude Einstellungen SQLCipher kompilieren

ich mehrere Änderungen vorgenommen haben Einstellungen zu bauen, Header Suche Hinzufügen Pfad- und C-Flags. Dann, nach einer Kompilierung des sqlcipher testen, erhalte ich habe keine Fehler mit dem binären, aber Fehler, die nicht existierten, bevor sie mit FMDB wie dies zeigt sich der Autor:

FMDatabaseAdditions.m: 137: 19: Implizite Erklärung der Funktion 'NSFileTypeForHFSTypeCode' ist ungültig in C99`

FMDatabaseAdditions.m: 137: 19: Implizite Umwandlung von 'int' to 'NSString *' mit ARC` unzulässig

FMDatabaseAdditions.m: 137: 15 : Inkompatible Integer-to-Pointer-Konvertierung, die 'NSString * __ strong' mit einem Ausdruck vom Typ 'int'` initialisiert

FMDatabaseAdditions.m: 158: 96: Werte vom Typ 'NSUInteger' sollten nicht als Formatargumente verwendet werden; eine explizite Umwandlung zu 'unsigned long' instead`

FMDatabaseAdditions.m hinzufügen: 161: 28: Implizite Deklaration der Funktion 'NSHFSTypeCodeFromFileType' ist ungültig in C99`

+0

Hey, @LibanAbdulle, überprüfen Sie die Antwort unten als Lösung geändert! Weil diese Antwort mein Problem löst! –

Antwort

19

Dieser Fehler tritt auf, wenn Sie mit Zielen in Ihrem Projekt spielen. Der NSFileTypeForHFSTypeCode wird nur benötigt, wenn Sie das Projekt gegen das Mac OS-Ziel kompilieren, und sollte nicht verwendet werden, wenn das Ziel ein iPhone ist. Tatsächlich scheint der Fehler bei den neuen Versionen von XCode zu passieren, selbst wenn Ihr Projekt als iPhone ausgerichtet ist. Alte Antwort:

So schreiben wir müssen Implementierung applicationIDString und bedingte Flaggen setzen:

#if TARGET_OS_MAC && !TARGET_OS_IPHONE 
    - (NSString*)applicationIDString { 
     NSString *s = NSFileTypeForHFSTypeCode([self applicationID]); 

     assert([s length] == 6); 

     s = [s substringWithRange:NSMakeRange(1, 4)]; 


     return s; 

    } 
#endif 

Die Bedingung, wenn TARGET_OS_MAC wird die Notwendigkeit von TARGET_OS_IPHONE nicht ersetzen, weil TARGET_OS_IPHONE eigentlich eine Variante des TARGET_OS_MAC ist. So zu vermeiden Fehler kompilieren, fügen #if TARGET_OS_MAC & & TARGET_OS_IPHONE

Auch unter diesem Teil des Codes:

- (void)setApplicationIDString:(NSString*)s { 

     if ([s length] != 4) { 
      NSLog(@"setApplicationIDString: string passed is not exactly 4 chars long. (was %ld)", [s length]); 
     } 
     #if TARGET_OS_MAC && !TARGET_OS_IPHONE 
     [self setApplicationID:NSHFSTypeCodeFromFileType([NSString stringWithFormat:@"'%@'", s])]; 
     #endif 
    } 

Neue Antwort:

ich den Code und neu geordnet Methoden aktualisiert in FMDatabaseAdditions.m mehr dem Bereich (Bedingungen) zugeordnet sein.:

 #if SQLITE_VERSION_NUMBER >= 3007017 

     - (uint32_t)applicationID { 

      uint32_t r = 0; 

      FMResultSet *rs = [self executeQuery:@"pragma application_id"]; 

      if ([rs next]) { 
       r = (uint32_t)[rs longLongIntForColumnIndex:0]; 
      } 

      [rs close]; 

      return r; 
     } 

     - (void)setApplicationID:(uint32_t)appID { 
      NSString *query = [NSString stringWithFormat:@"pragma application_id=%d", appID]; 
      FMResultSet *rs = [self executeQuery:query]; 
      [rs next]; 
      [rs close]; 
     } 


     #if TARGET_OS_MAC && !TARGET_OS_IPHONE 
     - (NSString*)applicationIDString { 
      NSString *s = NSFileTypeForHFSTypeCode([self applicationID]); 

      assert([s length] == 6); 

      s = [s substringWithRange:NSMakeRange(1, 4)]; 


      return s; 

     } 

     - (void)setApplicationIDString:(NSString*)s { 

      if ([s length] != 4) { 
       NSLog(@"setApplicationIDString: string passed is not exactly 4 chars long. (was %ld)", [s length]); 
      } 

      [self setApplicationID:NSHFSTypeCodeFromFileType([NSString stringWithFormat:@"'%@'", s])]; 
     } 


     #endif 

     #endif 

auch andere Warnungen zu vermeiden ich FMDatabaseAdditions.h

 #if SQLITE_VERSION_NUMBER >= 3007017 

     ///----------------------------------- 
     /// @name Application identifier tasks 
     ///----------------------------------- 

     /** Retrieve application ID 

     @return The `uint32_t` numeric value of the application ID. 

     @see setApplicationID: 
     */ 

     - (uint32_t)applicationID; 

     /** Set the application ID 

     @param appID The `uint32_t` numeric value of the application ID. 

     @see applicationID 
     */ 

     - (void)setApplicationID:(uint32_t)appID; 

     #if TARGET_OS_MAC && !TARGET_OS_IPHONE 
     /** Retrieve application ID string 

     @return The `NSString` value of the application ID. 

     @see setApplicationIDString: 
     */ 


     - (NSString*)applicationIDString; 

     /** Set the application ID string 

     @param string The `NSString` value of the application ID. 

     @see applicationIDString 
     */ 

     - (void)setApplicationIDString:(NSString*)string; 
     #endif 

     #endif 
+0

Aktualisierte Antwort. – user3344236

+0

Vielleicht aktualisieren Sie Ihre Antwort, weil dies eine neue Warnung verursacht, dass die Methodendeklaration für "applicationIDString" nicht gefunden wird.Ich denke, dass das If-Endif verschoben werden könnte, und wir sonst nur eine Standardzeichenfolge zurückgeben? – dwsolberg

+2

Aktualisierte Antwort. – user3344236