-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set icudt.dat file path at runtime when loading library
- Loading branch information
Showing
5 changed files
with
78 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
Samples/Beyond.NET.Sample.Swift/Source/LibraryInit/__LibraryInit.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#import <Foundation/Foundation.h> | ||
#import <TargetConditionals.h> | ||
|
||
#import <Generated_C.h> | ||
|
||
@interface __DNLibraryInit : NSObject | ||
@end | ||
|
||
@implementation __DNLibraryInit | ||
|
||
+ (void)load { | ||
#if TARGET_OS_IOS | ||
// iOS/iOS Simulator | ||
NSBundle* bundle = [NSBundle bundleForClass:__DNLibraryInit.class]; | ||
|
||
if (!bundle) { | ||
return; | ||
} | ||
|
||
System_Exception_t ex = NULL; | ||
System_String_t name = DNStringFromC("ICU_DAT_FILE_PATH"); | ||
|
||
if (!name) { | ||
return; | ||
} | ||
|
||
NSString* icuPath = [bundle pathForResource:@"icudt" ofType:@"dat"]; | ||
|
||
if (!icuPath) { | ||
return; | ||
} | ||
|
||
System_String_t icuPathDN = DNStringFromC(icuPath.UTF8String); | ||
|
||
System_AppContext_SetData(name, | ||
icuPathDN, | ||
&ex); | ||
|
||
System_String_Destroy(name); | ||
System_String_Destroy(icuPathDN); | ||
|
||
if (ex) { | ||
NSLog(@"Error: Setting icudt.dat path failed."); | ||
} | ||
#elif TARGET_OS_MAC && !TARGET_OS_IPHONE | ||
// macOS | ||
#else | ||
// Other platform | ||
#endif | ||
} | ||
|
||
@end |