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

Added vision os build support for capacitor and cordova #7534

Open
wants to merge 9 commits into
base: main
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
1 change: 1 addition & 0 deletions ios/Capacitor.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Pod::Spec.new do |s|
s.license = 'MIT'
s.homepage = 'https://capacitorjs.com/'
s.ios.deployment_target = '13.0'
s.visionos.deployment_target = '1.0'
s.authors = { 'Ionic Team' => '[email protected]' }
s.source = { git: 'https://github.com/ionic-team/capacitor.git', tag: package['version'] }
s.source_files = "#{prefix}Capacitor/Capacitor/**/*.{swift,h,m}"
Expand Down
32 changes: 26 additions & 6 deletions ios/Capacitor/Capacitor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@
50503EF41FC08595003606DC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
DEFINES_MODULE = YES;
Expand All @@ -967,17 +968,21 @@
PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.Capacitor;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,7";
XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Debug;
};
50503EF51FC08595003606DC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
DEFINES_MODULE = YES;
Expand All @@ -996,10 +1001,13 @@
PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.Capacitor;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,7";
XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Release;
};
Expand All @@ -1015,10 +1023,13 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.CapacitorTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OBJC_BRIDGING_HEADER = "CapacitorTests/CapacitorTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,7";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestsHostApp.app/TestsHostApp";
};
name = Debug;
Expand All @@ -1035,9 +1046,12 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.CapacitorTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OBJC_BRIDGING_HEADER = "CapacitorTests/CapacitorTests-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,7";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestsHostApp.app/TestsHostApp";
};
name = Release;
Expand Down Expand Up @@ -1107,10 +1121,13 @@
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.CodableTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Debug;
};
Expand All @@ -1133,9 +1150,12 @@
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.CodableTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Release;
};
Expand Down
8 changes: 6 additions & 2 deletions ios/Capacitor/Capacitor/CAPBridgeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ import Cordova
self.becomeFirstResponder()
loadWebView()
}

#if os(iOS)
override open func canPerformUnwindSegueAction(_ action: Selector, from fromViewController: UIViewController, withSender sender: Any) -> Bool {
return false
}

#endif
// MARK: - Initialization

/**
Expand Down Expand Up @@ -223,16 +223,20 @@ import Cordova

open func setStatusBarVisible(_ isStatusBarVisible: Bool) {
self.isStatusBarVisible = isStatusBarVisible
#if os(iOS)
UIView.animate(withDuration: 0.2, animations: {
self.setNeedsStatusBarAppearanceUpdate()
})
#endif
}

open func setStatusBarStyle(_ statusBarStyle: UIStatusBarStyle) {
self.statusBarStyle = statusBarStyle
#if os(iOS)
UIView.animate(withDuration: 0.2, animations: {
self.setNeedsStatusBarAppearanceUpdate()
})
#endif
}

open func setStatusBarAnimation(_ statusBarAnimation: UIStatusBarAnimation) {
Expand Down
14 changes: 14 additions & 0 deletions ios/Capacitor/Capacitor/CapacitorBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,35 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {

public var statusBarVisible: Bool {
get {
#if os(iOS)
return !(viewController?.prefersStatusBarHidden ?? true)
#else
return false
#endif
}
set {
#if os(iOS)
DispatchQueue.main.async { [weak self] in
(self?.viewController as? CAPBridgeViewController)?.setStatusBarVisible(newValue)
}
#endif
}
}

public var statusBarStyle: UIStatusBarStyle {
get {
#if os(iOS)
return viewController?.preferredStatusBarStyle ?? .default
#else
return .default
#endif
}
set {
#if os(iOS)
DispatchQueue.main.async { [weak self] in
(self?.viewController as? CAPBridgeViewController)?.setStatusBarStyle(newValue)
}
#endif
}
}

Expand Down Expand Up @@ -711,6 +723,7 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {
}

@objc open func presentVC(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) {
#if os(iOS)
if viewControllerToPresent.modalPresentationStyle == .popover {
self.viewController?.present(viewControllerToPresent, animated: flag, completion: completion)
} else {
Expand All @@ -719,6 +732,7 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {
self.tmpWindow?.makeKeyAndVisible()
self.tmpWindow?.rootViewController?.present(viewControllerToPresent, animated: flag, completion: completion)
}
#endif
}

@objc open func dismissVC(animated flag: Bool, completion: (() -> Void)? = nil) {
Expand Down
5 changes: 4 additions & 1 deletion ios/CapacitorCordova.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ Pod::Spec.new do |s|
s.license = 'MIT'
s.authors = { 'Ionic Team' => '[email protected]' }
s.source = { git: 'https://github.com/ionic-team/capacitor', tag: s.version.to_s }
s.platform = :ios, 13.0
s.platforms = {
'ios' => '13.0',
'visionos' => '1.0'
}
s.source_files = "#{prefix}CapacitorCordova/CapacitorCordova/**/*.{h,m}"
s.public_header_files = "#{prefix}CapacitorCordova/CapacitorCordova/Classes/Public/*.h",
"#{prefix}CapacitorCordova/CapacitorCordova/CapacitorCordova.h"
Expand Down
12 changes: 10 additions & 2 deletions ios/CapacitorCordova/CapacitorCordova.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,11 @@
PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.ios.CapacitorCordova;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
TARGETED_DEVICE_FAMILY = "1,2,7";
XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Debug;
};
Expand All @@ -424,7 +428,11 @@
PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.ios.CapacitorCordova;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
TARGETED_DEVICE_FAMILY = "1,2,7";
XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Release;
};
Expand Down