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

Feature: 支持AppKit #171

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7d19758
Create or update Upstream Sync workflow file.
Mx-Iris Feb 17, 2024
cdb52bd
Merge branch 'develop' of https://github.com/QMUI/LookinServer into d…
actions-user Feb 18, 2024
e4dca79
Merge branch 'develop' of https://github.com/QMUI/LookinServer into d…
actions-user Mar 1, 2024
3198bd1
Merge branch 'develop' of https://github.com/QMUI/LookinServer into d…
actions-user Mar 3, 2024
73639a1
Merge branch 'develop' of https://github.com/QMUI/LookinServer into d…
actions-user Mar 4, 2024
03a1f73
Merge branch 'develop' of https://github.com/QMUI/LookinServer into d…
actions-user Mar 18, 2024
142d522
Merge branch 'develop' of https://github.com/QMUI/LookinServer into d…
actions-user Mar 26, 2024
43a2b87
Merge branch 'develop' of https://github.com/QMUI/LookinServer into d…
actions-user Apr 3, 2024
4ab4af8
Merge branch 'develop' of https://github.com/QMUI/LookinServer into d…
actions-user Apr 7, 2024
3eb1e39
Merge branch 'QMUI:develop' into develop
Mx-Iris Nov 1, 2024
d3356c2
Support MacCatalyst
Mx-Iris Nov 1, 2024
f87a53b
AppKit Support
Mx-Iris Nov 5, 2024
b47b1a4
Updates
Mx-Iris Nov 5, 2024
47867fc
[WIP] AppKit Support
Mx-Iris Nov 5, 2024
fb752f5
[WIP] AppKit Support
Mx-Iris Nov 5, 2024
da3c43c
[WIP] AppKit Support
Mx-Iris Nov 6, 2024
cde7043
Fix errors
Mx-Iris Nov 6, 2024
a3bbccc
[WIP] AppKit Support
Mx-Iris Nov 6, 2024
1dcecc7
[WIP] AppKit Support
Mx-Iris Nov 7, 2024
5cb640b
[WIP] AppKit Support
Mx-Iris Nov 7, 2024
8c5e815
[WIP] AppKit Support
Mx-Iris Nov 7, 2024
44f1947
[WIP] AppKit Support
Mx-Iris Nov 7, 2024
ea2ab5c
[WIP] AppKit Support
Mx-Iris Nov 7, 2024
bf1610f
[WIP] AppKit Support
Mx-Iris Nov 7, 2024
8d31d9f
[WIP] AppKit Support
Mx-Iris Nov 7, 2024
59a6f0d
[WIP] AppKit Support
Mx-Iris Nov 8, 2024
ef0cfdc
[WIP] AppKit Support
Mx-Iris Nov 8, 2024
3129a94
[WIP] AppKit Support
Mx-Iris Nov 8, 2024
5c8559d
[WIP] AppKit Support
Mx-Iris Nov 10, 2024
0c687d7
Updates
Mx-Iris Nov 22, 2024
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
421 changes: 421 additions & 0 deletions LookinDemo/AppKitDemo/AppKitDemo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions LookinDemo/AppKitDemo/AppKitDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// AppDelegate.swift
// AppKitDemo
//
// Created by JH on 2024/11/5.
//

import Cocoa

@main
class AppDelegate: NSObject, NSApplicationDelegate {




func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
}

func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}

func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}


}

14 changes: 14 additions & 0 deletions LookinDemo/AppKitDemo/AppKitDemo/AppKitDemo.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>
<false/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
718 changes: 718 additions & 0 deletions LookinDemo/AppKitDemo/AppKitDemo/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// ViewController.swift
// AppKitDemo
//
// Created by JH on 2024/11/5.
//

import Cocoa

class View: NSView {
override var isFlipped: Bool { true }
}

extension NSView {
var backgroundColor: NSColor? {
set {
setValue(newValue, forKeyPath: "backgroundColor")
}
get {
value(forKeyPath: "backgroundColor") as? NSColor
}
}
}

class ViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()

let subview = NSView()
subview.backgroundColor = .red
subview.frame = CGRect(x: 10, y: 10, width: 100, height: 100)
view.addSubview(subview)

let subview2 = NSView()
subview2.backgroundColor = .blue
subview2.frame = CGRect(x: 10, y: 10, width: 50, height: 50)
subview.addSubview(subview2)

guard let bitmapRep = view.bitmapImageRepForCachingDisplay(in: view.bounds) else {
return
}
view.cacheDisplay(in: view.bounds, to: bitmapRep)
let image = NSImage(size: view.bounds.size)
image.addRepresentation(bitmapRep)
try? image.tiffRepresentation?.write(to: .desktopDirectory.appending(path: "Test.tiff"))
}

override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}

override func viewDidAppear() {
super.viewDidAppear()
}
}
5 changes: 5 additions & 0 deletions LookinDemo/AppKitDemo/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use_frameworks!

target 'AppKitDemo' do
pod 'LookinServer', :path=>'../../'
end
18 changes: 18 additions & 0 deletions LookinDemo/AppKitDemo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
PODS:
- LookinServer (1.2.8):
- LookinServer/Core (= 1.2.8)
- LookinServer/Core (1.2.8)

DEPENDENCIES:
- LookinServer (from `../../`)

EXTERNAL SOURCES:
LookinServer:
:path: "../../"

SPEC CHECKSUMS:
LookinServer: 32e176f3ef9dfbda52026e2d9e18b7204c141272

PODFILE CHECKSUM: 0eea96142f9864079641953fac183889175edfb2

COCOAPODS: 1.15.2
14 changes: 12 additions & 2 deletions LookinDemo/OC_Pod/LookinDemoOC.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
A76A15A028F43C5B00086B38 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
A76A15A228F43C5B00086B38 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A76A15A328F43C5B00086B38 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
E94749E72CD4C2FB00CB2204 /* LookinDemoOC.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = LookinDemoOC.entitlements; sourceTree = "<group>"; };
FD8E7F541A46626F2CA92333 /* Pods-LookinDemoOC.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LookinDemoOC.release.xcconfig"; path = "Target Support Files/Pods-LookinDemoOC/Pods-LookinDemoOC.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -79,6 +80,7 @@
A76A159028F43C5A00086B38 /* LookinDemoOC */ = {
isa = PBXGroup;
children = (
E94749E72CD4C2FB00CB2204 /* LookinDemoOC.entitlements */,
A76A159128F43C5A00086B38 /* AppDelegate.h */,
A76A159228F43C5A00086B38 /* AppDelegate.m */,
A76A159428F43C5A00086B38 /* SceneDelegate.h */,
Expand Down Expand Up @@ -365,6 +367,8 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = LookinDemoOC/LookinDemoOC.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -381,8 +385,10 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = Lookin.LookinDemoOC;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,6";
};
name = Debug;
};
Expand All @@ -392,6 +398,8 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = LookinDemoOC/LookinDemoOC.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -408,8 +416,10 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = Lookin.LookinDemoOC;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,6";
};
name = Release;
};
Expand Down
12 changes: 12 additions & 0 deletions LookinDemo/OC_Pod/LookinDemoOC/LookinDemoOC.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?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.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
</plist>
10 changes: 5 additions & 5 deletions LookinDemo/OC_Pod/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- LookinServer (1.2.6):
- LookinServer/Core (= 1.2.6)
- LookinServer/Core (1.2.6)
- LookinServer (1.2.8):
- LookinServer/Core (= 1.2.8)
- LookinServer/Core (1.2.8)

DEPENDENCIES:
- LookinServer (from `../../`)
Expand All @@ -11,8 +11,8 @@ EXTERNAL SOURCES:
:path: "../../"

SPEC CHECKSUMS:
LookinServer: de929b55f8fa2e241c18c39af3f900eaa9166389
LookinServer: 32e176f3ef9dfbda52026e2d9e18b7204c141272

PODFILE CHECKSUM: c1b5f203c9e81bcbf3888ba95a03c31e2435a4f7

COCOAPODS: 1.13.0
COCOAPODS: 1.15.2
6 changes: 5 additions & 1 deletion LookinServer.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ Pod::Spec.new do |spec|
spec.homepage = "https://lookin.work"
spec.license = "GPL-3.0"
spec.author = { "Li Kai" => "[email protected]" }
spec.macos.deployment_target = "11.0"
spec.ios.deployment_target = "9.0"
spec.tvos.deployment_target = '9.0'
spec.visionos.deployment_target = "1.0"
spec.default_subspecs = 'Core'
spec.source = { :git => "https://github.com/QMUI/LookinServer.git", :tag => "1.2.8"}
spec.framework = "UIKit"
spec.macos.framework = "AppKit"
spec.ios.framework = "UIKit"
spec.tvos.framework = "UIKit"
spec.visionos.framework = "UIKit"
spec.requires_arc = true

spec.subspec 'Core' do |ss|
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "LookinServer",
platforms: [
.iOS(.v9),.tvOS(.v9)
.iOS(.v9),.tvOS(.v9), .macOS(.v11)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
Expand Down
2 changes: 0 additions & 2 deletions Src/Base/LookinIvarTrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ extern NSString *const LookinIvarTraceRelationValue_Self;

#pragma mark - No Coding

#if TARGET_OS_IPHONE
@property(nonatomic, weak) id hostObject;
#endif

@end

Expand Down
18 changes: 8 additions & 10 deletions Src/Main/Server/Category/CALayer+LookinServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,28 @@
//

#import "LookinDefines.h"
#import "TargetConditionals.h"
#import <UIKit/UIKit.h>

@interface CALayer (LookinServer)

/// 如果 myView.layer == myLayer,则 myLayer.lks_hostView 会返回 myView
@property(nonatomic, readonly, weak) UIView *lks_hostView;
@property(nonatomic, readonly, weak) LookinView *lks_hostView;

- (UIWindow *)lks_window;
- (LookinWindow *)lks_window;

- (CGRect)lks_frameInWindow:(UIWindow *)window;
- (CGRect)lks_frameInWindow:(LookinWindow *)window;

- (UIImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality;
- (LookinImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality;
/// 当没有 sublayers 时,该方法返回 nil
- (UIImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality;
- (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality;

/// 获取和该对象有关的对象的 Class 层级树
- (NSArray<NSArray<NSString *> *> *)lks_relatedClassChainList;

- (NSArray<NSString *> *)lks_selfRelation;

@property(nonatomic, strong) UIColor *lks_backgroundColor;
@property(nonatomic, strong) UIColor *lks_borderColor;
@property(nonatomic, strong) UIColor *lks_shadowColor;
@property(nonatomic, strong) LookinColor *lks_backgroundColor;
@property(nonatomic, strong) LookinColor *lks_borderColor;
@property(nonatomic, strong) LookinColor *lks_shadowColor;
@property(nonatomic, assign) CGFloat lks_shadowOffsetWidth;
@property(nonatomic, assign) CGFloat lks_shadowOffsetHeight;

Expand Down
Loading