Skip to content

Commit

Permalink
Update iOS example app for latest SDK code
Browse files Browse the repository at this point in the history
  • Loading branch information
shyam-builder committed Sep 6, 2023
1 parent dd13b85 commit 1f183f9
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 87 deletions.
10 changes: 0 additions & 10 deletions examples/swift/Podfile

This file was deleted.

3 changes: 0 additions & 3 deletions examples/swift/Podfile.lock

This file was deleted.

32 changes: 18 additions & 14 deletions examples/swift/Shared/ContentView.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
import SwiftUI
import BuilderIO

class BuilderContentWrapper: ObservableObject {
var content: BuilderContent? = nil;
init(content: BuilderContent? = nil) {
self.content = content
}

func changeContent(_ newValue: BuilderContent?) {
self.content = newValue;
self.objectWillChange.send();
}
}

struct ContentView: View {
@ObservedObject var content: BuilderContentWrapper = BuilderContentWrapper();

Expand All @@ -24,6 +12,16 @@ struct ContentView: View {
}

func fetchContent() {
print("TRIGGER FETCH CONTENT")

let isAppetize = UserDefaults.standard.bool(forKey: "isAppetize");
print("IS APPETIZE??", isAppetize);
let contentId = UserDefaults.standard.string(forKey: "builderContentId") ?? "NO CONTENT ID";
let modelName = UserDefaults.standard.string(forKey: "builderModelName") ?? "NO MODEL NAME";

let modelId = UserDefaults.standard.string(forKey: "builderModelId") ?? "NO MODEL ID";
print("FETCH CONtent iN APP", isAppetize, contentId, modelName, modelId);

Content.getContent(model: "page", apiKey: "e084484c0e0241579f01abba29d9be10", url: "/custom-components", locale: "", preview: "") { content in
DispatchQueue.main.async {
self.content.changeContent(content);
Expand All @@ -38,9 +36,15 @@ struct ContentView: View {
}
}

Button("Reload") {
fetchContent()
if (Content.isPreviewing()) {
Button("Reload") {
fetchContent();
}.onReceive(NotificationCenter.default.publisher(for: deviceDidShakeNotification)) { _ in
fetchContent()

}
}

}
}

Expand Down
26 changes: 26 additions & 0 deletions examples/swift/Shared/NavigationViews.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// NavigationViews.swift
// SwiftExample (iOS)
//
// Created by Shyam Seshadri on 9/4/23.
//

import SwiftUI

struct NavigationViews: View {
var body: some View {
NavigationView {
NavigationLink(destination: ContentView()) {
Text("Navigate to Home Screen")
}
.navigationBarTitle("Login!")
}

}
}

struct NavigationViews_Previews: PreviewProvider {
static var previews: some View {
NavigationViews()
}
}
2 changes: 1 addition & 1 deletion examples/swift/Shared/testingApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SwiftUI
struct testingApp: App {
var body: some Scene {
WindowGroup {
ContentView()
NavigationViews()
}
}
}
67 changes: 10 additions & 57 deletions examples/swift/SwiftExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,28 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 53;
objects = {

/* Begin PBXBuildFile section */
AF15816126B83DE000531EAD /* testingApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF15813826B83DDF00531EAD /* testingApp.swift */; };
AF15816326B83DE000531EAD /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF15813926B83DDF00531EAD /* ContentView.swift */; };
AF15816526B83DE000531EAD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AF15813A26B83DE000531EAD /* Assets.xcassets */; };
AF7E5E5126BA0EA600AB0FF5 /* BuildFile in Resources */ = {isa = PBXBuildFile; };
DB24C7D37B2327134650DA43 /* Pods_SwiftExample__iOS_.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 58AFCF3ABC5E867D90F2A19A /* Pods_SwiftExample__iOS_.framework */; };
AF7E5E5126BA0EA600AB0FF5 /* (null) in Resources */ = {isa = PBXBuildFile; };
E414A22E290FF2920018A728 /* BuilderIO in Frameworks */ = {isa = PBXBuildFile; productRef = E414A22D290FF2920018A728 /* BuilderIO */; };
E4209C3B2AA5B6FC00675D5F /* NavigationViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4209C3A2AA5B6FC00675D5F /* NavigationViews.swift */; };
E4CC63852A2F0CA8008A399E /* HeroComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4CC63842A2F0CA8008A399E /* HeroComponent.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
2C49A3DB675E8F68DB9EC1DC /* Pods-SwiftExample (iOS).release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftExample (iOS).release.xcconfig"; path = "Target Support Files/Pods-SwiftExample (iOS)/Pods-SwiftExample (iOS).release.xcconfig"; sourceTree = "<group>"; };
58AFCF3ABC5E867D90F2A19A /* Pods_SwiftExample__iOS_.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftExample__iOS_.framework; sourceTree = BUILT_PRODUCTS_DIR; };
88A76566BC4B71D5E2FB16C8 /* Pods-SwiftExample (iOS).debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftExample (iOS).debug.xcconfig"; path = "Target Support Files/Pods-SwiftExample (iOS)/Pods-SwiftExample (iOS).debug.xcconfig"; sourceTree = "<group>"; };
AF15813826B83DDF00531EAD /* testingApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = testingApp.swift; sourceTree = "<group>"; };
AF15813926B83DDF00531EAD /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
AF15813A26B83DE000531EAD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
AF15813F26B83DE000531EAD /* SwiftExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
AF15814226B83DE000531EAD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AF15815326B83DE000531EAD /* Tests_iOS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests_iOS.swift; sourceTree = "<group>"; };
AF15815526B83DE000531EAD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E4209C3A2AA5B6FC00675D5F /* NavigationViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationViews.swift; sourceTree = "<group>"; };
E4CC63842A2F0CA8008A399E /* HeroComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeroComponent.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -36,38 +34,27 @@
buildActionMask = 2147483647;
files = (
E414A22E290FF2920018A728 /* BuilderIO in Frameworks */,
DB24C7D37B2327134650DA43 /* Pods_SwiftExample__iOS_.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
71FBD8CA1E6297C177018390 /* Pods */ = {
isa = PBXGroup;
children = (
88A76566BC4B71D5E2FB16C8 /* Pods-SwiftExample (iOS).debug.xcconfig */,
2C49A3DB675E8F68DB9EC1DC /* Pods-SwiftExample (iOS).release.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
AF15813226B83DDF00531EAD = {
isa = PBXGroup;
children = (
AF15813726B83DDF00531EAD /* Shared */,
AF15814126B83DE000531EAD /* iOS */,
AF15815226B83DE000531EAD /* Tests iOS */,
AF15814026B83DE000531EAD /* Products */,
FA9AC8BA04E0370036E61A5E /* Frameworks */,
71FBD8CA1E6297C177018390 /* Pods */,
);
sourceTree = "<group>";
};
AF15813726B83DDF00531EAD /* Shared */ = {
isa = PBXGroup;
children = (
AF15813826B83DDF00531EAD /* testingApp.swift */,
E4209C3A2AA5B6FC00675D5F /* NavigationViews.swift */,
AF15813926B83DDF00531EAD /* ContentView.swift */,
AF15813A26B83DE000531EAD /* Assets.xcassets */,
E4CC63842A2F0CA8008A399E /* HeroComponent.swift */,
Expand Down Expand Up @@ -100,22 +87,13 @@
path = "Tests iOS";
sourceTree = "<group>";
};
FA9AC8BA04E0370036E61A5E /* Frameworks */ = {
isa = PBXGroup;
children = (
58AFCF3ABC5E867D90F2A19A /* Pods_SwiftExample__iOS_.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
AF15813E26B83DE000531EAD /* SwiftExample (iOS) */ = {
isa = PBXNativeTarget;
buildConfigurationList = AF15816926B83DE000531EAD /* Build configuration list for PBXNativeTarget "SwiftExample (iOS)" */;
buildPhases = (
F39362739CC7EF83CA84E933 /* [CP] Check Pods Manifest.lock */,
AF15813B26B83DE000531EAD /* Sources */,
AF15813C26B83DE000531EAD /* Frameworks */,
AF15813D26B83DE000531EAD /* Resources */,
Expand All @@ -138,8 +116,9 @@
AF15813326B83DDF00531EAD /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1250;
LastUpgradeCheck = 1400;
LastUpgradeCheck = 1430;
TargetAttributes = {
AF15813E26B83DE000531EAD = {
CreatedOnToolsVersion = 12.5.1;
Expand Down Expand Up @@ -173,44 +152,20 @@
buildActionMask = 2147483647;
files = (
AF15816526B83DE000531EAD /* Assets.xcassets in Resources */,
AF7E5E5126BA0EA600AB0FF5 /* BuildFile in Resources */,
AF7E5E5126BA0EA600AB0FF5 /* (null) in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
F39362739CC7EF83CA84E933 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-SwiftExample (iOS)-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
AF15813B26B83DE000531EAD /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AF15816326B83DE000531EAD /* ContentView.swift in Sources */,
E4CC63852A2F0CA8008A399E /* HeroComponent.swift in Sources */,
E4209C3B2AA5B6FC00675D5F /* NavigationViews.swift in Sources */,
AF15816126B83DE000531EAD /* testingApp.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -335,7 +290,6 @@
};
AF15816A26B83DE000531EAD /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 88A76566BC4B71D5E2FB16C8 /* Pods-SwiftExample (iOS).debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
Expand All @@ -359,7 +313,6 @@
};
AF15816B26B83DE000531EAD /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 2C49A3DB675E8F68DB9EC1DC /* Pods-SwiftExample (iOS).release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
Expand Down Expand Up @@ -410,7 +363,7 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/BuilderIO/builder-swift";
requirement = {
branch = main;
branch = "shyam-ios-fixes";
kind = branch;
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/BuilderIO/builder-swift",
"state" : {
"branch" : "main",
"revision" : "2973d0c86e54b7514ec3e25b8fd7d1d85edd1a27"
"branch" : "shyam-ios-fixes",
"revision" : "20b619ba5c35023560b9728c45837f6a2c27f3d5"
}
},
{
Expand Down

0 comments on commit 1f183f9

Please sign in to comment.