Преглед на файлове

simulator app groups workaround for when entitlements are not correctly added for a simulator build

Tobias Conradi преди 10 години
родител
ревизия
fd2e5ff461
променени са 2 файла, в които са добавени 18 реда и са изтрити 1 реда
  1. 9 1
      Sources/VLCAppDelegate.m
  2. 9 0
      VLC for iOS WatchKit Extension/VLCPlaylistInterfaceController.m

+ 9 - 1
Sources/VLCAppDelegate.m

@@ -218,7 +218,15 @@
 
     MLMediaLibrary *mediaLibrary = [MLMediaLibrary sharedMediaLibrary];
     NSURL *groupURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"group.org.videolan.vlc-ios"];
-
+#if TARGET_IPHONE_SIMULATOR
+    // if something went wrong with the entitlements in the Simulator
+    if (!groupURL) {
+        NSArray *pathComponents = [[[NSBundle mainBundle] bundlePath] pathComponents];
+        pathComponents = [pathComponents subarrayWithRange:NSMakeRange(0, pathComponents.count-4)];
+        NSString *groupPath = [[NSString pathWithComponents:pathComponents] stringByAppendingPathComponent:@"Shared/AppGroup/fake-group.org.videolan.vlc-ios"];
+        groupURL = [NSURL fileURLWithPath:groupPath];
+    }
+#endif
     NSString *oldBasePath = [mediaLibrary libraryBasePath];
     NSString *oldPersistentStorePath = [oldBasePath stringByAppendingPathComponent: @"MediaLibrary.sqlite"];
 

+ 9 - 0
VLC for iOS WatchKit Extension/VLCPlaylistInterfaceController.m

@@ -44,6 +44,15 @@ static NSString *const VLCDBUpdateNotificationRemote = @"org.videolan.ios-app.db
     [super awakeWithContext:context];
 
     NSURL *groupURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"group.org.videolan.vlc-ios"];
+#if TARGET_IPHONE_SIMULATOR
+    // if something went wrong with the entitlements in the Simulator
+    if (!groupURL) {
+        NSArray *pathComponents = [[[NSBundle mainBundle] bundlePath] pathComponents];
+        pathComponents = [pathComponents subarrayWithRange:NSMakeRange(0, pathComponents.count-4)];
+        NSString *groupPath = [[NSString pathWithComponents:pathComponents] stringByAppendingPathComponent:@"Shared/AppGroup/fake-group.org.videolan.vlc-ios"];
+        groupURL = [NSURL fileURLWithPath:groupPath];
+    }
+#endif
     MLMediaLibrary *mediaLibrary = [MLMediaLibrary sharedMediaLibrary];
     mediaLibrary.libraryBasePath = groupURL.path;
     mediaLibrary.additionalPersitentStoreOptions = @{NSReadOnlyPersistentStoreOption : @YES};