[sword-devel] patch to stringmgr.cpp for iOS (iPhone, etc)...

Nic Carter niccarter at mac.com
Wed Jun 30 19:13:30 MST 2010


Hi all,

Due to some changes in iOS 4 (aka iPhone OS 4), I've had to change how PocketSword uses ICU.  I can go into the details off-list if required, but basically I can only use a cut-down version of ICU unless I want to (?) bundle a full copy of ICU into PocketSword myself.  I've chosen to use Apple's included version, which is easier for the time being (especially given that I've had v1.3.0 waiting to be released for a couple of weeks now!).

But that means I've had to introduce a #ifdef for the iPhone, which I've called _APPLE_IOS_ (Apple's iOS).  So to compile SWORD for use on the iPhone using the built-in version of ICU, you need to compile with -D_APPLE_IOS_ and it'll work.  Alternatively, you could probably (?) bundle up your own ICU and compile with the usual -D_ICU_ -- but you cannot use the _ICU_ if you wish to use the built-in Apple-supplied ICU (which I was recently made aware of, and looking back at how I got ICU stuff to work in the first place on the iPhone, alarm bells should have been ringing in my head!!!)...  :)


Thanks heaps, ybic
	nic...  :)

ps: Basically, by using _APPLE_IOS_ you aren't using the transliteration features of ICU that you would get if you were using _ICU_.  Perhaps we could better name the #defines but I think this works fairly well atm, and I may find other instances where I want to use a #ifdef _APPLE_IOS_ so it's probably nice having this available.  :)

----
Nic Carter
PocketSword Developer - an iPhone Bible Study app
www: http://crosswire.org/pocketsword
iTunes: http://itunes.apple.com/app/Pocketsword/id341046078
Twitter: http://twitter.com/pocketsword







diff -r 32448dd619a3 externals/sword/src/mgr/stringmgr.cpp
--- a/externals/sword/src/mgr/stringmgr.cpp	Thu Jun 24 14:26:28 2010 +1000
+++ b/externals/sword/src/mgr/stringmgr.cpp	Thu Jul 01 11:59:56 2010 +1000
@@ -36,6 +36,10 @@
 
 #include <unicode/locid.h>
 
+#elif defined (_APPLE_IOS_)
+
+#include <unicode/ustring.h>
+
 #endif
 
 SWORD_NAMESPACE_START
@@ -115,7 +119,7 @@
 }
 
 
-#ifdef _ICU_
+#if defined (_ICU_) || defined (_APPLE_IOS_)
 
 //here comes our ICUStringMgr reimplementation
 class ICUStringMgr : public StringMgr {
@@ -164,7 +168,7 @@
 */
 StringMgr* StringMgr::getSystemStringMgr() {
 	if (!systemStringMgr) {
-#ifdef _ICU_
+#if defined (_ICU_) || defined (_APPLE_IOS_)
 		systemStringMgr = new ICUStringMgr();
 // 		SWLog::getSystemLog()->logInformation("created default ICUStringMgr");
 #else
@@ -237,7 +241,7 @@
 }
 
 
-#ifdef _ICU_
+#if defined (_ICU_) || (_APPLE_IOS_)
 
 char *ICUStringMgr::upperUTF8(char *buf, unsigned int maxlen) const {
 	char *ret = buf;




More information about the sword-devel mailing list