Skip to content

Commit

Permalink
refactor!: Convert template project to Swift
Browse files Browse the repository at this point in the history
Bump min iOS version for template app to 13.0 (due to UISceneDelegate)
  • Loading branch information
dpogue committed Aug 15, 2024
1 parent a3be849 commit 794863a
Show file tree
Hide file tree
Showing 15 changed files with 347 additions and 503 deletions.
12 changes: 4 additions & 8 deletions lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,10 @@ class ProjectCreator {
['__PROJECT_NAME__.xcworkspace', 'contents.xcworkspacedata'],
['__PROJECT_NAME__.xcworkspace', 'xcshareddata', 'xcschemes', '__PROJECT_NAME__.xcscheme'],
['__PROJECT_NAME__.xcodeproj', 'project.pbxproj'],
['__PROJECT_NAME__', 'AppDelegate.h'],
['__PROJECT_NAME__', 'AppDelegate.m'],
['__PROJECT_NAME__', 'MainViewController.h'],
['__PROJECT_NAME__', 'MainViewController.m'],
['__PROJECT_NAME__', 'main.m'],
['__PROJECT_NAME__', '__PROJECT_NAME__-Info.plist'],
['__PROJECT_NAME__', '__PROJECT_NAME__-Prefix.pch']
['__PROJECT_NAME__', 'AppDelegate.swift'],
['__PROJECT_NAME__', 'SceneDelegate.swift'],
['__PROJECT_NAME__', 'ViewController.swift'],
['__PROJECT_NAME__', '__PROJECT_NAME__-Info.plist']
]) {
this.expandProjectNameInFileContents(this.projectPath(...p));
}
Expand All @@ -192,7 +189,6 @@ class ProjectCreator {
['__PROJECT_NAME__.xcworkspace'],
['__PROJECT_NAME__.xcodeproj'],
['__PROJECT_NAME__', '__PROJECT_NAME__-Info.plist'],
['__PROJECT_NAME__', '__PROJECT_NAME__-Prefix.pch'],
['__PROJECT_NAME__']
]) {
this.expandProjectNameInBaseName(this.projectPath(...p));
Expand Down
3 changes: 0 additions & 3 deletions templates/cordova/build-debug.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
//

#include "build.xcconfig"

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) DEBUG=1

#include "build-extras.xcconfig"

// (CB-11792)
Expand Down
4 changes: 0 additions & 4 deletions templates/cordova/build-release.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
//

#include "build.xcconfig"

CODE_SIGN_IDENTITY = iPhone Distribution
CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Distribution

#include "build-extras.xcconfig"

// (CB-11792)
Expand Down
19 changes: 0 additions & 19 deletions templates/cordova/build.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,3 @@
// XCode build settings shared by all Build Configurations.
// Settings are overridden by configuration-level .xcconfig file (build-release/build-debug).
//

HEADER_SEARCH_PATHS = "$(TARGET_BUILD_DIR)/usr/local/lib/include" "$(OBJROOT)/UninstalledProducts/include" "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" "$(BUILT_PRODUCTS_DIR)"
OTHER_LDFLAGS = -ObjC

// Type of signing identity used for codesigning, resolves to first match of given type.
// "iPhone Developer": Development builds (default, local only; iOS Development certificate) or "iPhone Distribution": Distribution builds (Adhoc/In-House/AppStore; iOS Distribution certificate)
CODE_SIGN_IDENTITY = iPhone Developer
CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Developer

// (CB-9721) Set ENABLE_BITCODE to NO in build.xcconfig
ENABLE_BITCODE = NO

// (CB-9719) Set CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES to YES in build.xcconfig
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES

// (CB-10072)
SWIFT_OBJC_BRIDGING_HEADER = $(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) WK_WEB_VIEW_ONLY=$(WK_WEB_VIEW_ONLY)
472 changes: 243 additions & 229 deletions templates/project/__PROJECT_NAME__.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

31 changes: 0 additions & 31 deletions templates/project/__PROJECT_NAME__/AppDelegate.m

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ Licensed to the Apache Software Foundation (ASF) under one
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
*/

#import <UIKit/UIKit.h>
#import "AppDelegate.h"
import UIKit
import Cordova

int main(int argc, char *argv[]) {
NSString *appDelegateClassName;
@autoreleasepool {
// Setup code that might create autoreleased objects goes here.
appDelegateClassName = NSStringFromClass([AppDelegate class]);
@main
class AppDelegate: CDVAppDelegate {
override func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
return UIApplicationMain(argc, argv, nil, appDelegateClassName);
}

60 changes: 60 additions & 0 deletions templates/project/__PROJECT_NAME__/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
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.
-->
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="$(PRODUCT_MODULE_NAME)" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" name="BackgroundColor"/>
</view>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="backgroundColor">
<color key="value" name="BackgroundColor"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="splashBackgroundColor">
<color key="value" name="SplashScreenBackgroundColor"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="boolean" keyPath="showSplashScreen" value="YES"/>
</userDefinedRuntimeAttributes>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
<resources>
<namedColor name="BackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</namedColor>
<namedColor name="SplashScreenBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</namedColor>
</resources>
</document>

24 changes: 0 additions & 24 deletions templates/project/__PROJECT_NAME__/MainViewController.h

This file was deleted.

138 changes: 0 additions & 138 deletions templates/project/__PROJECT_NAME__/MainViewController.xib

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
*/

#import <Cordova/CDVAppDelegate.h>
import UIKit

@interface AppDelegate : CDVAppDelegate
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ Licensed to the Apache Software Foundation (ASF) under one
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
*/

#import "MainViewController.h"
import Cordova

@implementation MainViewController
class ViewController: CDVViewController {
}

@end
Loading

0 comments on commit 794863a

Please sign in to comment.