1 Reply
      Latest reply: Dec 3, 2016 6:07 AM by eskimo RSS
      WatchDev2015 Level 1 Level 1 (0 points)

        Hello all:

         

        I have an app that tracks tennis shot stats on the Watch, writes those stats to an FMDB database, and then the user used to be able to check those stats on the phone. That was in watch OS1, and the watch wrote to a DB and then the phone read from that same DB. With the changes in OS2/3 the code used to determine the paths to the DB, which runs on both the Watch and Phone and used to return the same value, now produces different paths. I changed the code to use a Shared Instance in the phone app for the DB path and file creation, but the Path is still different when the code is called from the watch vs. the phone.

         

        Can anyone offer any assistance and/or make a suggestion for sharing data? I need the watch app to track the data and then write it out to the DB on the phone, and then at some later point in time when the user runs the app on the phone, the data needs to be accessible.

         

        Thanks for any and all input.

         

        the code:

         

         

         

            let identifier = "group.johnstraumann.ScoreItData"

            let sharedContainerURL: URL? = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: identifier)

            if let sharedContainerURL = sharedContainerURL

            {

              let databasePath = sharedContainerURL.appendingPathComponent("scoreit_tennis.db")

              SharedData.gameData.databaseURL = databasePath

              SharedData.gameData.updateDatabasePath(databasePath.path as NSString!)

             }

         

        When I run the Watch app the path I get is:

        /Users/johnstraumann/Library/Developer/CoreSimulator/Devices/A0F94F7C-4066-45F3-95F9-79ED71D6029F/data/Containers/Shared/AppGroup/F1AC5989-3078-44FE-BD1D-E995DB9D190F/scoreit_tennis.db

         

        and when I run the phone app the path I get is:


        /Users/johnstraumann/Library/Developer/CoreSimulator/Devices/2D1BE8F2-39CE-4077-A2AC-B7A806C9CBD3/data/Containers/Shared/AppGroup/05960AD1-8087-44B7-B60B-5667875A91A2/scoreit_tennis.db