Skip to content
This repository was archived by the owner on Aug 12, 2022. It is now read-only.

add macOS support #477

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
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
2 changes: 0 additions & 2 deletions editions/free/Free-Info.plist
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSSupportsOpeningDocumentsInPlace</key>
<false/>
<key>NSMicrophoneUsageDescription</key>
<string>Used to record sounds for your projects</string>
<key>NSCameraUsageDescription</key>
17 changes: 17 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load 'remove_unsupported_libraries.rb'

# Uncomment this line to define a global platform for your project
platform :ios, '8.0'

@@ -11,3 +13,18 @@ end
target 'ScratchJrTests' do

end

# define unsupported pods
def unsupported_pods
['Firebase/Analytics']
end

def supported_pods
['SSZipArchive']
end

# Remove unsupported pods from your project
post_install do |installer|
$verbose = true # remove or set to false to avoid printing
installer.configure_support_catalyst(supported_pods, unsupported_pods)
end
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -99,6 +99,6 @@ SPEC CHECKSUMS:
nanopb: 2901f78ea1b7b4015c860c2fdd1ea2fee1a18d48
SSZipArchive: cefe1364104a0231268a5deb8495bdf2861f52f0

PODFILE CHECKSUM: 43eaf7714849e36c6216d378a51f3dc168eda736
PODFILE CHECKSUM: 046f57a5087fb12afecf0de2ddc52f29bed6fa98

COCOAPODS: 1.9.3
COCOAPODS: 1.10.1
14 changes: 14 additions & 0 deletions ios/ScratchJr Free.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
12 changes: 10 additions & 2 deletions ios/ScratchJr.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@
isEditable = 1;
outputFiles = (
);
script = "";
script = "# Type a script or drag a script file from your workspace to insert its path.\n";
};
/* End PBXBuildRule section */

@@ -68,6 +68,7 @@
20B2226818A4404B003BDE44 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = SOURCE_ROOT; };
20B2226E18A46327003BDE44 /* libsqlite3.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.0.dylib; path = usr/lib/libsqlite3.0.dylib; sourceTree = SDKROOT; };
20B2227818A53688003BDE44 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
40A3556426A8E31100FF2C2D /* ScratchJr Free.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "ScratchJr Free.entitlements"; sourceTree = "<group>"; };
40AF1E472619DB10000F853E /* NSDictionary+JSONString.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "NSDictionary+JSONString.h"; path = "src/NSDictionary+JSONString.h"; sourceTree = "<group>"; };
40AF1E482619DB10000F853E /* NSDictionary+JSONString.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "NSDictionary+JSONString.m"; path = "src/NSDictionary+JSONString.m"; sourceTree = "<group>"; };
512C88D0E9938AB5972ACF38 /* libPods-ScratchJrTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ScratchJrTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -131,6 +132,7 @@
204D809C18A4140600ECBB8B = {
isa = PBXGroup;
children = (
40A3556426A8E31100FF2C2D /* ScratchJr Free.entitlements */,
D92D0FE41C335BDE00C573AD /* src */,
20B2226818A4404B003BDE44 /* Settings.bundle */,
D9104A9F1C220516004D1708 /* Editions */,
@@ -430,7 +432,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "EDITION=free;\n\n../bin/bundle-compile.sh;\n\nrsync -pvtrlL --cvs-exclude \\\n ../editions/$EDITION/ios-resources/* \\\n \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/\";\n\nrsync -pvtrlL --cvs-exclude \\\n ../editions/$EDITION/src/* \\\n \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/HTML5\";\n \nmkdir -p \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/HTML5/pnglibrary\";\n\n../bin/convert-svg-to-png.py -i \"../editions/$EDITION/src/svglibrary/\" -o \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/HTML5/pnglibrary\";\n";
shellScript = "EDITION=free;\n\n#../bin/bundle-compile.sh;\n\nrsync -pvtrlL --cvs-exclude \\\n ../editions/$EDITION/ios-resources/* \\\n \"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/\";\n\nrsync -pvtrlL --cvs-exclude \\\n ../editions/$EDITION/src/* \\\n \"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/HTML5\";\n\nmkdir -p \"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/HTML5/pnglibrary\";\n\n../bin/convert-svg-to-png.py -i \"../editions/$EDITION/src/svglibrary/\" -o \"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/HTML5/pnglibrary\";\n";
};
/* End PBXShellScriptBuildPhase section */

@@ -648,6 +650,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = "Free-AppIcon";
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Free-LaunchImage";
CODE_SIGN_ENTITLEMENTS = "ScratchJr Free.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = W7AR3WMP87;
@@ -659,9 +662,11 @@
);
INFOPLIST_FILE = "$(SRCROOT)/../editions/free/Free-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
OTHER_CODE_SIGN_FLAGS = "--deep";
PRODUCT_BUNDLE_IDENTIFIER = edu.mitmedialab.scratchjrfree;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SUPPORTS_MACCATALYST = YES;
TARGETED_DEVICE_FAMILY = 2;
WRAPPER_EXTENSION = app;
};
@@ -673,6 +678,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = "Free-AppIcon";
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Free-LaunchImage";
CODE_SIGN_ENTITLEMENTS = "ScratchJr Free.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = W7AR3WMP87;
@@ -684,9 +690,11 @@
);
INFOPLIST_FILE = "$(SRCROOT)/../editions/free/Free-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
OTHER_CODE_SIGN_FLAGS = "--deep";
PRODUCT_BUNDLE_IDENTIFIER = edu.mitmedialab.scratchjrfree;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SUPPORTS_MACCATALYST = YES;
TARGETED_DEVICE_FAMILY = 2;
WRAPPER_EXTENSION = app;
};
4 changes: 4 additions & 0 deletions ios/ScratchJr/src/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#import "AppDelegate.h"
#import "ScratchJr.h"
#if !TARGET_OS_MACCATALYST
@import Firebase;
#endif

@implementation AppDelegate

@@ -20,8 +22,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
self.window.rootViewController = [[ViewController alloc] initWithNibName:@"View" bundle:nil];
[self.window makeKeyAndVisible];

#if !TARGET_OS_MACCATALYST
// Configure Firebase
[FIRApp configure];
#endif

return YES;
}
8 changes: 8 additions & 0 deletions ios/ScratchJr/src/JsBridge.m
Original file line number Diff line number Diff line change
@@ -7,7 +7,9 @@

#import "ScratchJr.h"
#import <WebKit/WebKit.h>
#if !TARGET_OS_MACCATALYST
@import Firebase;
#endif

@implementation JsBridge

@@ -182,24 +184,30 @@ -(void) analyticsEvent: (JsRequest *) request {
if (![request.params[2] isEqual:[NSNull null]]) {
label = request.params[2];
}
#if !TARGET_OS_MACCATALYST
[FIRAnalytics logEventWithName:request.params[1] // action
parameters:@{
kFIRParameterItemName:label, // label
kFIRParameterItemCategory:request.params[0] // category
}];
#endif
[request callback:@"ok"];
}

-(void) setAnalyticsPlacePref: (JsRequest *) request {
#if !TARGET_OS_MACCATALYST
[FIRAnalytics setUserPropertyString:request.params[0] forName:@"place_preference"];
#endif
[request callback:@"ok"];
}

// @param request like [name, propertyString]
-(void) setAnalyticsPref: (JsRequest *) request {
NSString *name = [NSString stringWithFormat:@"%@", request.params[0]];
NSString *propertyString = [NSString stringWithFormat:@"%@", request.params[1]];
#if !TARGET_OS_MACCATALYST
[FIRAnalytics setUserPropertyString:propertyString forName:name];
#endif
[request callback:@"ok"];
}

4 changes: 4 additions & 0 deletions ios/ScratchJr/src/ViewController.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#import "ScratchJr.h"
#import <WebKit/WebKit.h>
// @import MessageUI;
#if !TARGET_OS_MACCATALYST
@import Firebase;
#endif

WKWebView *webview;
NSDate* startDate;
@@ -183,8 +185,10 @@ - (void) webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)naviga
NSArray<NSString*>* parts = [screenString componentsSeparatedByString:@"/"];
NSString* page = [[[parts lastObject] componentsSeparatedByString:@"?"] firstObject];

#if !TARGET_OS_MACCATALYST
// Track pageview in Firebase?
[FIRAnalytics setScreenName:page screenClass:NULL];
#endif
}

- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error {
447 changes: 447 additions & 0 deletions ios/remove_unsupported_libraries.rb

Large diffs are not rendered by default.