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

Commit

Permalink
Fix some data path bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
dwlnetnl committed Feb 9, 2015
1 parent 76c2d69 commit 430caae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions SwissEphemeris-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,7 @@
EXECUTABLE_PREFIX = "";
GCC_DYNAMIC_NO_PIC = NO;
GCC_PREPROCESSOR_DEFINITIONS = (
"STATIC_LIBRARY=1",
"DEBUG=1",
"$(inherited)",
);
Expand All @@ -1244,6 +1245,10 @@
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
EXECUTABLE_PREFIX = "";
GCC_PREPROCESSOR_DEFINITIONS = (
"STATIC_LIBRARY=1",
"$(inherited)",
);
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
14 changes: 10 additions & 4 deletions SwissEphemeris/SwissEphGlue.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@
#import "sweph.h"

static NSBundle *_SWEDataFilesGetBundle() {
#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
return [NSBundle bundleWithIdentifier:@"com.astro.SwissEphemeris"];
#else
#if STATIC_LIBRARY
return [NSBundle mainBundle];
#else
return [NSBundle bundleWithIdentifier:@"com.astro.SwissEphemeris"];
#endif
}

static NSURL *SWEDataFilesGetFrameworkURL() {
return _SWEDataFilesGetBundle().resourceURL;
}

#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
static NSURL *SWEDataFilesGetExternalURL() {
static NSURL *pathURL;
static dispatch_once_t token;
Expand All @@ -37,6 +38,7 @@

return pathURL;
}
#endif

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

void _SEGDataFilesCopyPathForFile(char *datapath, const char *fname, const char *ephepath) {
#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
#if !STATIC_LIBRARY
NSFileManager *fm = [NSFileManager defaultManager];
NSString *fileName = @(fname);

#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
// Application Support path
// This is the escape hatch for code signing (immutable resources)
NSURL *pathURL = SWEDataFilesGetExternalURL();
Expand All @@ -57,6 +60,7 @@ void _SEGDataFilesCopyPathForFile(char *datapath, const char *fname, const char
strcat(datapath, "/");
return;
}
#endif

// Given data path
// There are no ast directories in the framework resources directory
Expand All @@ -74,6 +78,7 @@ void _SEGDataFilesCopyPathForFile(char *datapath, const char *fname, const char
void _SEGLibraryInitialize() {
swe_set_ephe_path((char *)SWEDataFilesGetFrameworkURL().fileSystemRepresentation);

#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
NSURL *externalURL = SWEDataFilesGetExternalURL();
if (![[NSFileManager defaultManager] fileExistsAtPath:externalURL.path]) {
NSError *error;
Expand All @@ -83,6 +88,7 @@ void _SEGLibraryInitialize() {
NSLog(@"Error creating Application Support directory: %@", error);
}
}
#endif
}

void _SEGLibraryFinalize() {
Expand Down

0 comments on commit 430caae

Please sign in to comment.