Skip to content
This repository was archived by the owner on Jul 23, 2018. It is now read-only.

Commit 430caae

Browse files
committed
Fix some data path bugs
1 parent 76c2d69 commit 430caae

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

SwissEphemeris-iOS.xcodeproj/project.pbxproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,7 @@
12271227
EXECUTABLE_PREFIX = "";
12281228
GCC_DYNAMIC_NO_PIC = NO;
12291229
GCC_PREPROCESSOR_DEFINITIONS = (
1230+
"STATIC_LIBRARY=1",
12301231
"DEBUG=1",
12311232
"$(inherited)",
12321233
);
@@ -1244,6 +1245,10 @@
12441245
buildSettings = {
12451246
CLANG_ENABLE_OBJC_ARC = YES;
12461247
EXECUTABLE_PREFIX = "";
1248+
GCC_PREPROCESSOR_DEFINITIONS = (
1249+
"STATIC_LIBRARY=1",
1250+
"$(inherited)",
1251+
);
12471252
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
12481253
OTHER_LDFLAGS = "-ObjC";
12491254
PRODUCT_NAME = "$(TARGET_NAME)";

SwissEphemeris/SwissEphGlue.m

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212
#import "sweph.h"
1313

1414
static 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

2222
static NSURL *SWEDataFilesGetFrameworkURL() {
2323
return _SWEDataFilesGetBundle().resourceURL;
2424
}
2525

26+
#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
2627
static NSURL *SWEDataFilesGetExternalURL() {
2728
static NSURL *pathURL;
2829
static dispatch_once_t token;
@@ -37,6 +38,7 @@
3738

3839
return pathURL;
3940
}
41+
#endif
4042

4143
#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
4244
void _SEGDataFilesCopyFrameworkPath(char *ephepath, __unused char *empty) {
@@ -45,10 +47,11 @@ void _SEGDataFilesCopyFrameworkPath(char *ephepath, __unused char *empty) {
4547
#endif
4648

4749
void _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
7478
void _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

8894
void _SEGLibraryFinalize() {

0 commit comments

Comments
 (0)