1212#import " sweph.h"
1313
1414static NSBundle *_SWEDataFilesGetBundle () {
15- #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
16- return [NSBundle bundleWithIdentifier: @" com.astro.SwissEphemeris" ];
17- #else
15+ #if STATIC_LIBRARY
1816 return [NSBundle mainBundle ];
17+ #else
18+ return [NSBundle bundleWithIdentifier: @" com.astro.SwissEphemeris" ];
1919#endif
2020}
2121
2222static NSURL *SWEDataFilesGetFrameworkURL () {
2323 return _SWEDataFilesGetBundle ().resourceURL ;
2424}
2525
26+ #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
2627static NSURL *SWEDataFilesGetExternalURL () {
2728 static NSURL *pathURL;
2829 static dispatch_once_t token;
3738
3839 return pathURL;
3940}
41+ #endif
4042
4143#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
4244void _SEGDataFilesCopyFrameworkPath (char *ephepath, __unused char *empty) {
@@ -45,10 +47,11 @@ void _SEGDataFilesCopyFrameworkPath(char *ephepath, __unused char *empty) {
4547#endif
4648
4749void _SEGDataFilesCopyPathForFile (char *datapath, const char *fname, const char *ephepath) {
48- #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
50+ #if !STATIC_LIBRARY
4951 NSFileManager *fm = [NSFileManager defaultManager ];
5052 NSString *fileName = @(fname);
5153
54+ #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
5255 // Application Support path
5356 // This is the escape hatch for code signing (immutable resources)
5457 NSURL *pathURL = SWEDataFilesGetExternalURL ();
@@ -57,6 +60,7 @@ void _SEGDataFilesCopyPathForFile(char *datapath, const char *fname, const char
5760 strcat (datapath, " /" );
5861 return ;
5962 }
63+ #endif
6064
6165 // Given data path
6266 // There are no ast directories in the framework resources directory
@@ -74,6 +78,7 @@ void _SEGDataFilesCopyPathForFile(char *datapath, const char *fname, const char
7478void _SEGLibraryInitialize () {
7579 swe_set_ephe_path ((char *)SWEDataFilesGetFrameworkURL ().fileSystemRepresentation );
7680
81+ #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
7782 NSURL *externalURL = SWEDataFilesGetExternalURL ();
7883 if (![[NSFileManager defaultManager ] fileExistsAtPath: externalURL.path]) {
7984 NSError *error;
@@ -83,6 +88,7 @@ void _SEGLibraryInitialize() {
8388 NSLog (@" Error creating Application Support directory: %@ " , error);
8489 }
8590 }
91+ #endif
8692}
8793
8894void _SEGLibraryFinalize () {
0 commit comments