<commit_before>Contents:  
[Introduction](#introduction)  
[Development Status](#development-status)  

# Introduction

SMSyncServer has the following general goals:  

1. Giving end-users permanent access to their mobile app data,  
1. Synchronizing mobile app data across end-user devices,  
1. Reducing data storage costs for app developers/publishers,  
1. Allowing sharing of data with other users,  
1. Cross-platform synchronization (e.g., iOS, Android), and  
1. Synchronized devices need only be [Occasionally Connected](https://msdn.microsoft.com/en-us/library/ff650163.aspx) to a network.

More detailed characteristics of the SMSyncServer:

1. The large majority of file information (i.e., all of the file content information) is stored in end-user cloud storage accounts. Only meta data for files, locks, and some user credentials information is stored in the mySQL database on the server.
1. Client apps can operate offline. The client API queues operations (e.g., uploads) until network access is available.
1. Interrupted operations are retried. For example, if network access is lost during a series of file uploads, then those uploads are retried when network access is available.

Contact: <<EMAIL>> (primary developer)

# Development Status

* Previously, the server side of this project was implemented in Javascript and MongoDb. I'm now in the process of rewriting the server in Swift, and using mySQL.
* Google Drive is supported in terms of cloud storage systems.

# Standing up a Server

1. Each separate mobile app (i.e., for iOS, each app with a separate bundle id) needs its own server.

1. The server needs to run using the `GoogleServerClientId` (see below) and associated (server) client secret specific to the mobile app.

# Installation in a new iOS app

1. Setup your `Podfile`. 

    The SyncServer iOS client API is used as a Cocoapod, and because it hasn't been released yet, you will need to access the project files directly. E.g., the example apps supplied with the project use the following `Podfile`. Google SignIn is the only option currently for cloud storage, and thus the Google SignIn Cocoapod is required.

    ```
    source 'https://github.com/CocoaPods/Specs.git'
    source 'https://github.com/crspybits/Specs.git'

    use_frameworks!

    target 'SharedImages' do
        pod 'SyncServer', :path => '../Client/'
        pod 'SMCoreLib'
        pod 'Google/SignIn'
    end
    ```

1. Call the following when your app first starts (e.g., in `didFinishLaunchingWithOptions`):

    ```
    SyncServer.session.appLaunchSetup(withServerURL: serverURL, cloudFolderName:cloudFolderName)
    ```

    `serverURL` is the URL of your SyncServer server.
    `cloudFolderName` is the folder (i.e., directory) that you want your app's files to be stored in your cloud storage service (i.e., Google Drive at this point)

1. Enable your app to work with Google Drive

  1. Create Google App/Developer Credentials
  
  To enable access to user Google Drive accounts, you must create Google Developer credentials for your iOS app using the SyncServer Framework and server. These credentials need to be installed in your app making use of the Framework. See https://developers.google.com/identity/sign-in/ios/start and click on `GET A CONFIGURATION FILE`. You need to generate a configuration file-- this will typically be named: `GoogleService-Info.plist`, and add that file to your Xcode project.
   
   Amongst other information, this .plist file contains your Google `CLIENT_ID` for your iOS app.
   
   You also need to make sure you enable the Google Drive API for your Google project. You can do this by going to https://console.developers.google.com, and look for `ENABLE API`, and within that `Drive API`.
   
   Within https://console.developers.google.com, you also need to obtain your `OAuth 2.0 client IDs` for your `Web client` (see under "Credentials). I call this the `GoogleServerClientId`. You will need both the `CLIENT_ID` (for your iOS app) and the `GoogleServerClientId` in order to sign in to Google Drive from your iOS app.

  1. Add URL scheme for Google Sign in to your app.

    You do this in XCode under the "Info" tab. Look for "URL Types" and paste the CLIENT_ID into the "URL Schemes" field of a new URL Type (press the "+" button).
  
  1. Use SMGoogleUserSignIn.swift to initialze Google sign in.
  
    Drag `iOS/Client/SignIn/SMGoogleUserSignIn.swift` into your Xcode project.
    
    Add the following code into your AppDelegate or someother app launch time code:
    
    ```
    let googleSignIn =  SMGoogleUserSignIn(serverClientId: GoogleServerClientId, appClientId: CLIENT_ID)
    googleSignIn.appLaunchSetup(silentSignIn: true)
    ```
    
    You will need to keep a reference to the googleSignIn object for the duration of your app running. E.g., it could be a member variable of the AppDelegate.
    
    Additionally, add the following into your AppDelegate:
    <commit_msg>Edits to docs.<commit_after>Contents:  
[Introduction](#introduction)  
[Development Status](#development-status)  

# Introduction

SMSyncServer has the following general goals:  

1. Giving end-users permanent access to their mobile app data,  
1. Synchronizing mobile app data across end-user devices,  
1. Reducing data storage costs for app developers/publishers,  
1. Allowing sharing of data with other users,  
1. Cross-platform synchronization (e.g., iOS, Android), and  
1. Synchronized devices need only be [Occasionally Connected](https://msdn.microsoft.com/en-us/library/ff650163.aspx) to a network.

More detailed characteristics of the SMSyncServer:

1. The large majority of file information (i.e., all of the file content information) is stored in end-user cloud storage accounts. Only meta data for files, locks, and some user credentials information is stored in the mySQL database on the server.
1. Client apps can operate offline. The client API queues operations (e.g., uploads) until network access is available.
1. Interrupted operations are retried. For example, if network access is lost during a series of file uploads, then those uploads are retried when network access is available.

Contact: <<EMAIL>> (primary developer)

# Development Status

* Previously, the server side of this project was implemented in Javascript and MongoDb. I'm now in the process of rewriting the server in Swift, and using mySQL.
* Google Drive is supported in terms of cloud storage systems.

# Standing up a Server

1. Each separate mobile app (i.e., for iOS, each app with a separate bundle id) needs its own server.

1. The server needs to run using the `GoogleServerClientId` (see below) and associated (server) client secret specific to the mobile app.

# Installation in a new iOS app

1. Setup your `Podfile`. 

    The SyncServer iOS client API is used as a Cocoapod, and because it hasn't been released yet, you will need to access the project files directly. E.g., the example apps supplied with the project use the following `Podfile`. Google SignIn is the only option currently for cloud storage, and thus the Google SignIn Cocoapod is required.

    ```
    source 'https://github.com/CocoaPods/Specs.git'
    source 'https://github.com/crspybits/Specs.git'

    use_frameworks!

    target 'SharedImages' do
        pod 'SyncServer', :path => '../Client/'
        pod 'SMCoreLib'
        pod 'Google/SignIn'
    end
    ```

1. Call the following when your app first starts (e.g., in `didFinishLaunchingWithOptions`):

    ```
    SyncServer.session.appLaunchSetup(withServerURL: serverURL, cloudFolderName:cloudFolderName)
    ```

    `serverURL` is the URL of your SyncServer server.
    `cloudFolderName` is the folder (i.e., directory) that you want your app's files to be stored in your cloud storage service (i.e., Google Drive at this point)

1. Enable your app to work with Google Drive

  1. Create Google App/Developer Credentials
  
    To enable access to user Google Drive accounts, you must create Google Developer credentials for your iOS app using the SyncServer Framework and server. These credentials need to be installed in your app making use of the Framework. See https://developers.google.com/identity/sign-in/ios/start and click on `GET A CONFIGURATION FILE`. You need to generate a configuration file-- this will typically be named: `GoogleService-Info.plist`, and add that file to your Xcode project.
   
    Amongst other information, this .plist file contains your Google `CLIENT_ID` for your iOS app.
   
    You also need to make sure you enable the Google Drive API for your Google project. You can do this by going to https://console.developers.google.com, and look for `ENABLE API`, and within that `Drive API`.
   
    Within https://console.developers.google.com, you also need to obtain your `OAuth 2.0 client IDs` for your `Web client` (see under "Credentials). I call this the `GoogleServerClientId`. You will need both the `CLIENT_ID` (for your iOS app) and the `GoogleServerClientId` in order to sign in to Google Drive from your iOS app.

  1. Add URL scheme for Google Sign in to your app.

    You do this in XCode under the "Info" tab. Look for "URL Types" and paste the CLIENT_ID into the "URL Schemes" field of a new URL Type (press the "+" button).
  
  1. Use SMGoogleUserSignIn.swift to initialze Google sign in.
  
    Drag `iOS/Client/SignIn/SMGoogleUserSignIn.swift` into your Xcode project.
    
    Add the following code into your AppDelegate or someother app launch time code:
    
    ```
    let googleSignIn =  SMGoogleUserSignIn(serverClientId: GoogleServerClientId, appClientId: CLIENT_ID)
    googleSignIn.appLaunchSetup(silentSignIn: true)
    ```
    
    You will need to keep a reference to the googleSignIn object for the duration of your app running. E.g., it could be a member variable of the AppDelegate.
    
    Additionally, add the following into your AppDelegate:
    
{'fraction_non_alphanumeric': 0.06699576868829338, 'fraction_numerical': 0.005037275841225065, 'mean_word_length': 3.7840963855421688, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '33715', 'n_tokens_mistral': 2711, 'n_tokens_neox': 2609, 'n_words': 1332}