Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBL-6269: Update Getting Started page for CBL iOS #917

Open
wants to merge 2 commits into
base: release/3.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pipeline {
stage("Validate C#") {
agent { label 's61113u16 (litecore)' }
steps {
sh 'jenkins/dotnet_build.sh 3.2.0 1.0.0'
sh 'jenkins/dotnet_build.sh 3.2.1 1.0.0'
}
}
stage("Validate C") {
Expand All @@ -21,7 +21,7 @@ pipeline {
stage("Validate iOS") {
agent { label 'mobile-builder-ios-pull-request' }
steps {
sh 'jenkins/ios.sh 3.2.0 1.0.0'
sh 'jenkins/ios.sh 3.2.1 1.0.0'
}
}
}
Expand Down
38 changes: 13 additions & 25 deletions jenkins/ios.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,30 @@
#!/bin/bash -e

if [[ "$#" -ne 2 ]]; then
echo "Usage: $0 <CBL_VERSION> <VS_VERSION>"
exit 1
fi
cbl_version=$1
vs_version=$2

THIS_DIR=$( dirname -- $(realpath "$0"); )
CBL_VERSION="$1"
VS_VERSION="$2"
dir=$( dirname -- $(realpath "$0"); )

# Get latest good CBL iOS EE build for given version
CBL_URL="http://proget.build.couchbase.com:8080/api/open_latestbuilds?product=couchbase-lite-ios&version=${CBL_VERSION}"
CBL_URL="http://proget.build.couchbase.com:8080/api/open_latestbuilds?product=couchbase-lite-ios&version=${cbl_version}"

# Grab the redirect url
CBL_SOURCE_URL=$(curl -s -L -o /dev/null -w '%{url_effective}' "${CBL_URL}")

# Extract version and build number
CBL_BUILD_NUMBER=$(basename "${CBL_SOURCE_URL}")

# Construct version with build number
CBL_BUILD="${CBL_VERSION}-${CBL_BUILD_NUMBER}"

# Get latest good VS extension build for given version
VS_URL="http://proget.build.couchbase.com:8080/api/open_latestbuilds?product=couchbase-lite-ios-vector-search&version=${VS_VERSION}"
VS_URL="http://proget.build.couchbase.com:8080/api/open_latestbuilds?product=couchbase-lite-ios-vector-search&version=${vs_version}"


# Grab the redirect url - workaround until url is fixed
VS_SOURCE_URL=$(curl -s -L -o /dev/null -w '%{url_effective}' "${VS_URL}")

# Extract version and build number
VS_BUILD_NUMBER=$(basename "${VS_SOURCE_URL}")

# Construct version with build number
VS_BUILD="${VS_VERSION}-${VS_BUILD_NUMBER}"
cbl_build=$(curl -s "http://proget.build.couchbase.com:8080/api/get_version?product=couchbase-lite-ios&version=$cbl_version&ee=true" | jq .BuildNumber)
vs_build=$(curl -s "http://proget.build.couchbase.com:8080/api/get_version?product=couchbase-lite-ios-vector-search&version=$vs_version&ee=true" | jq .BuildNumber)

for PLATFORM in "swift" "objc"
for PLATFORM in "objc" "swift"
do
echo $PLATFORM
pushd "${THIS_DIR}/../modules/${PLATFORM}/examples"
pushd "${dir}/../modules/${PLATFORM}/examples"

# In case script fails mid-way, cleanup on start
if [ -d "downloaded" ]; then
Expand All @@ -46,12 +34,12 @@ do

pushd downloaded
# Get CBL
CBL_PACKAGE_NAME="couchbase-lite-${PLATFORM}_xc_enterprise_${CBL_BUILD}.zip"
CBL_PACKAGE_NAME="couchbase-lite-${PLATFORM}_xc_enterprise_${cbl_version}-${cbl_build}.zip"
wget "$CBL_SOURCE_URL$CBL_PACKAGE_NAME"
unzip -o $CBL_PACKAGE_NAME -d "../Frameworks/"
# Get VS extension
VS_PACKAGE_NAME="couchbase-lite-vector-search-${VS_BUILD}-apple.zip"
wget "$VS_SOURCE_URL/$VS_PACKAGE_NAME"
VS_PACKAGE_NAME="couchbase-lite-vector-search-${vs_version}-apple.zip"
wget "$VS_SOURCE_URL$VS_PACKAGE_NAME"
unzip -o $VS_PACKAGE_NAME -d "../Frameworks/"
# Check if download was successful
if [ $? -eq 0 ]; then
Expand Down
6 changes: 0 additions & 6 deletions modules/objc/examples/code_snippets.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/* Begin PBXBuildFile section */
1A508E74273A3887007EABB2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1A508E66273A3887007EABB2 /* Assets.xcassets */; };
1A508E76273A3887007EABB2 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A508E68273A3887007EABB2 /* ViewController.m */; };
1A508E77273A3887007EABB2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1A508E69273A3887007EABB2 /* LaunchScreen.storyboard */; };
1A508E78273A3887007EABB2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1A508E6B273A3887007EABB2 /* Main.storyboard */; };
1A508E79273A3887007EABB2 /* GettingStarted.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A508E6D273A3887007EABB2 /* GettingStarted.m */; };
Expand Down Expand Up @@ -42,14 +41,12 @@
1A354CEC273B5A54001A20BE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
1A508E64273A3887007EABB2 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
1A508E66273A3887007EABB2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
1A508E68273A3887007EABB2 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
1A508E6A273A3887007EABB2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
1A508E6C273A3887007EABB2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
1A508E6D273A3887007EABB2 /* GettingStarted.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GettingStarted.m; sourceTree = "<group>"; };
1A508E6E273A3887007EABB2 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
1A508E6F273A3887007EABB2 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
1A508E70273A3887007EABB2 /* SampleCodeTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SampleCodeTest.m; sourceTree = "<group>"; };
1A508E72273A3887007EABB2 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
4001A1B82BB343120067B507 /* code-snippets.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "code-snippets.app"; sourceTree = BUILT_PRODUCTS_DIR; };
4001A1BA2BB344790067B507 /* CouchbaseLiteVectorSearch.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = CouchbaseLiteVectorSearch.xcframework; path = Frameworks/CouchbaseLiteVectorSearch.xcframework; sourceTree = "<group>"; };
4001A1BB2BB344790067B507 /* CouchbaseLite.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = CouchbaseLite.xcframework; path = Frameworks/CouchbaseLite.xcframework; sourceTree = "<group>"; };
Expand All @@ -75,15 +72,13 @@
1A354CEC273B5A54001A20BE /* Info.plist */,
1A508E64273A3887007EABB2 /* AppDelegate.h */,
1A508E66273A3887007EABB2 /* Assets.xcassets */,
1A508E68273A3887007EABB2 /* ViewController.m */,
1A508E69273A3887007EABB2 /* LaunchScreen.storyboard */,
1A508E6B273A3887007EABB2 /* Main.storyboard */,
1A508E6D273A3887007EABB2 /* GettingStarted.m */,
1A508E6E273A3887007EABB2 /* main.m */,
1A508E6F273A3887007EABB2 /* AppDelegate.m */,
1A508E70273A3887007EABB2 /* SampleCodeTest.m */,
AE96AF0B2BF24E36000253DF /* VectorSearch.m */,
1A508E72273A3887007EABB2 /* ViewController.h */,
1A354CEB273B5996001A20BE /* GettingStarted.h */,
);
path = code_snippets;
Expand Down Expand Up @@ -186,7 +181,6 @@
1A508E79273A3887007EABB2 /* GettingStarted.m in Sources */,
1A508E7B273A3887007EABB2 /* AppDelegate.m in Sources */,
1A508E7C273A3887007EABB2 /* SampleCodeTest.m in Sources */,
1A508E76273A3887007EABB2 /* ViewController.m in Sources */,
AE96AF0C2BF24E36000253DF /* VectorSearch.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
56 changes: 36 additions & 20 deletions modules/objc/examples/code_snippets/GettingStarted.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
//
// GettingStarted.m
// threeBeta01prod
//
// Created by Ian Bridge on 04/10/2021.
// Copyright (c) 2024 Couchbase, Inc. All rights reserved.
//
// Licensed under the Couchbase License Agreement (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// https://info.couchbase.com/rs/302-GJY-034/images/2017-10-30_License_Agreement.pdf
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#import "GettingStarted.h"
#import <CouchbaseLite/CouchbaseLite.h>
Expand All @@ -13,28 +22,31 @@ @implementation GettingStarted
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
// Get the database (and create it if it doesn’t exist).

bool *testReplication;
testReplication = false;


[self getStartedWithReplication: false];

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to have an empty line between methods.

- (void) getStartedWithReplication: (Boolean) replication {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this method for? Do we need any doc tags?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for iOS no, the whole file is a snippet. All GettingStarted platforms specify that replication is OPTIONAL, although there is no optional in place for that piece of code in any other platform. Plan is to have another PR with those changes as it will be easier to review by the team - no specific iOS code in that one.

NSError *error;
CBLDatabase *database = [[CBLDatabase alloc] initWithName:@"mydb" error:&error];

// Get the database (and create it if it doesn’t exist).
CBLDatabase *database = [[CBLDatabase alloc] initWithName: @"mydb" error: &error];
CBLCollection *collection = [database defaultCollection: &error];

// Create a new document (i.e. a record) in the database.
CBLMutableDocument *mutableDoc = [[CBLMutableDocument alloc] init];
[mutableDoc setFloat:2.0 forKey:@"version"];
[mutableDoc setString:@"SDK" forKey:@"type"];

// Save it to the database.
[database saveDocument:mutableDoc error:&error];
[collection saveDocument: mutableDoc error: &error];

// Update a document.
CBLMutableDocument *mutableDoc2 = [[database documentWithID:mutableDoc.id] toMutable];
[mutableDoc2 setString:@"Objective-C" forKey:@"language"];
[database saveDocument:mutableDoc2 error:&error];
CBLMutableDocument *mutableDoc2 = [[collection documentWithID: mutableDoc.id error: &error] toMutable];
[mutableDoc2 setString: @"Objective-C" forKey: @"language"];
[collection saveDocument: mutableDoc2 error: &error];

CBLDocument *document = [database documentWithID:mutableDoc2.id];
CBLDocument *document = [collection documentWithID: mutableDoc2.id error: &error];
// Log the document ID (generated by the database)
// and properties
NSLog(@"Document ID :: %@", document.id);
Expand All @@ -43,27 +55,29 @@ - (void)viewDidLoad {
// Create a query to fetch documents of type SDK.
CBLQueryExpression *type = [[CBLQueryExpression property:@"type"] equalTo:[CBLQueryExpression string:@"SDK"]];
CBLQuery *query = [CBLQueryBuilder select:@[[CBLQuerySelectResult all]]
from:[CBLQueryDataSource database:database]
from:[CBLQueryDataSource collection: collection]
where:type];

// Run the query
CBLQueryResultSet *result = [query execute:&error];
NSLog(@"Number of rows :: %lu", (unsigned long)[[result allResults] count]);

if (testReplication) {
if (replication) {

// Create replicators to push and pull changes to and from the cloud.
NSURL *url = [[NSURL alloc] initWithString:@"ws://localhost:4984/getting-started-db"];
CBLURLEndpoint *targetEndpoint = [[CBLURLEndpoint alloc] initWithURL:url];
CBLReplicatorConfiguration *replConfig = [[CBLReplicatorConfiguration alloc] initWithDatabase:database target:targetEndpoint];
CBLReplicatorConfiguration *replConfig = [[CBLReplicatorConfiguration alloc] initWithTarget:targetEndpoint];
replConfig.replicatorType = kCBLReplicatorTypePushAndPull;

// Add authentication.
replConfig.authenticator = [[CBLBasicAuthenticator alloc] initWithUsername:@"john" password:@"pass"];

// Create replicator (make sure to add an instance or static variable named _replicator)
CBLReplicator *_replicator = [CBLReplicator alloc];
_replicator = [[CBLReplicator alloc] initWithConfig:replConfig];

// Add collection
[replConfig addCollection: collection config: nil];

// Create replicator
CBLReplicator *_replicator = [[CBLReplicator alloc] initWithConfig: replConfig];

// Listen to replicator change events.
[_replicator addChangeListener:^(CBLReplicatorChange *change) {
Expand All @@ -75,6 +89,8 @@ - (void)viewDidLoad {
// Start replication
[_replicator start];

} else {
NSLog(@"Not testing replication");
}
}

Expand Down
15 changes: 0 additions & 15 deletions modules/objc/examples/code_snippets/ViewController.h

This file was deleted.

23 changes: 0 additions & 23 deletions modules/objc/examples/code_snippets/ViewController.m

This file was deleted.

12 changes: 6 additions & 6 deletions modules/swift/examples/code_snippets.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
1A354D0E273B643F001A20BE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A354D01273B643F001A20BE /* ViewController.swift */; };
1A354D0F273B643F001A20BE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1A354D02273B643F001A20BE /* Assets.xcassets */; };
1A354D10273B643F001A20BE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1A354D03273B643F001A20BE /* LaunchScreen.storyboard */; };
1A354D11273B643F001A20BE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1A354D05273B643F001A20BE /* Main.storyboard */; };
Expand All @@ -17,6 +16,7 @@
4001A1B52BB33AB60067B507 /* CouchbaseLiteVectorSearch.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4001A1B22BB33AB60067B507 /* CouchbaseLiteVectorSearch.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
4001A1B62BB33AB60067B507 /* CouchbaseLiteSwift.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4001A1B32BB33AB60067B507 /* CouchbaseLiteSwift.xcframework */; };
4001A1B72BB33AB60067B507 /* CouchbaseLiteSwift.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4001A1B32BB33AB60067B507 /* CouchbaseLiteSwift.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
AE5F25412CA7039A00AAB7F4 /* Getting-Started.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE5F25402CA7039A00AAB7F4 /* Getting-Started.swift */; };
AEE304BF2BADBAB500C12A19 /* VectorSearch.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEE304BE2BADBAB500C12A19 /* VectorSearch.swift */; };
/* End PBXBuildFile section */

Expand All @@ -36,7 +36,6 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
1A354D01273B643F001A20BE /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
1A354D02273B643F001A20BE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
1A354D04273B643F001A20BE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
1A354D06273B643F001A20BE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
Expand All @@ -45,6 +44,7 @@
1A354D0D273B643F001A20BE /* SampleCodeTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleCodeTest.swift; sourceTree = "<group>"; };
4001A1B22BB33AB60067B507 /* CouchbaseLiteVectorSearch.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = CouchbaseLiteVectorSearch.xcframework; path = Frameworks/CouchbaseLiteVectorSearch.xcframework; sourceTree = "<group>"; };
4001A1B32BB33AB60067B507 /* CouchbaseLiteSwift.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = CouchbaseLiteSwift.xcframework; path = Frameworks/CouchbaseLiteSwift.xcframework; sourceTree = "<group>"; };
AE5F25402CA7039A00AAB7F4 /* Getting-Started.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Getting-Started.swift"; sourceTree = "<group>"; };
AEE304BE2BADBAB500C12A19 /* VectorSearch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VectorSearch.swift; sourceTree = "<group>"; };
BE826F0B22130841002C4924 /* code-snippets.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "code-snippets.app"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
Expand All @@ -65,7 +65,7 @@
1A354D00273B643F001A20BE /* code_snippets */ = {
isa = PBXGroup;
children = (
1A354D01273B643F001A20BE /* ViewController.swift */,
AE5F25402CA7039A00AAB7F4 /* Getting-Started.swift */,
1A354D02273B643F001A20BE /* Assets.xcassets */,
1A354D03273B643F001A20BE /* LaunchScreen.storyboard */,
1A354D05273B643F001A20BE /* Main.storyboard */,
Expand Down Expand Up @@ -178,8 +178,8 @@
buildActionMask = 2147483647;
files = (
1A354D18273B643F001A20BE /* SampleCodeTest.swift in Sources */,
1A354D0E273B643F001A20BE /* ViewController.swift in Sources */,
AEE304BF2BADBAB500C12A19 /* VectorSearch.swift in Sources */,
AE5F25412CA7039A00AAB7F4 /* Getting-Started.swift in Sources */,
1A354D14273B643F001A20BE /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -332,7 +332,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 863R969N56;
DEVELOPMENT_TEAM = N2Q372V7W2;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Frameworks",
Expand All @@ -356,7 +356,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 863R969N56;
DEVELOPMENT_TEAM = N2Q372V7W2;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Frameworks",
Expand Down
Loading