mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Independent Playground app for simulator
This commit is contained in:
parent
fa49a77a1b
commit
f708762946
3
.gitignore
vendored
3
.gitignore
vendored
@ -66,4 +66,5 @@ build-input/*
|
|||||||
**/*.pyc
|
**/*.pyc
|
||||||
*.pyc
|
*.pyc
|
||||||
submodules/**/.build/*
|
submodules/**/.build/*
|
||||||
swiftgram-scripts
|
swiftgram-scripts
|
||||||
|
Swiftgram/Playground/custom_bazel_path.bzl
|
45
Swiftgram/Playground/BUILD
Normal file
45
Swiftgram/Playground/BUILD
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
|
||||||
|
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
|
||||||
|
load(
|
||||||
|
"@rules_xcodeproj//xcodeproj:defs.bzl",
|
||||||
|
"top_level_target",
|
||||||
|
"xcodeproj",
|
||||||
|
)
|
||||||
|
load(
|
||||||
|
"//Swiftgram/Playground:custom_bazel_path.bzl", "custom_bazel_path"
|
||||||
|
)
|
||||||
|
|
||||||
|
swift_library(
|
||||||
|
name = "playgroundLib",
|
||||||
|
srcs = glob(["Sources/*.swift"]),
|
||||||
|
deps = [
|
||||||
|
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||||
|
"//submodules/Display:Display",
|
||||||
|
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||||
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
||||||
|
ios_application(
|
||||||
|
name = "Playground",
|
||||||
|
bundle_id = "app.swiftgram.playground",
|
||||||
|
families = [
|
||||||
|
"iphone",
|
||||||
|
"ipad",
|
||||||
|
],
|
||||||
|
infoplists = ["Resources/Info.plist"],
|
||||||
|
minimum_os_version = "14.0",
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
deps = [":playgroundLib"],
|
||||||
|
)
|
||||||
|
|
||||||
|
xcodeproj(
|
||||||
|
bazel_path = custom_bazel_path(),
|
||||||
|
name = "Playground_xcodeproj",
|
||||||
|
build_mode = "bazel",
|
||||||
|
project_name = "Playground",
|
||||||
|
tags = ["manual"],
|
||||||
|
top_level_targets = [
|
||||||
|
":Playground",
|
||||||
|
],
|
||||||
|
)
|
17
Swiftgram/Playground/README.md
Normal file
17
Swiftgram/Playground/README.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Swiftgram Playground
|
||||||
|
|
||||||
|
Small app to quickly iterate on components testing without building an entire messenger.
|
||||||
|
|
||||||
|
## Generate Xcode project
|
||||||
|
|
||||||
|
### From root
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./Swiftgram/Playground/generate_project.py
|
||||||
|
```
|
||||||
|
|
||||||
|
### From current directory
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./generate_project.py
|
||||||
|
```
|
39
Swiftgram/Playground/Resources/Info.plist
Normal file
39
Swiftgram/Playground/Resources/Info.plist
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?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>UILaunchScreen</key>
|
||||||
|
<dict>
|
||||||
|
<key>UILaunchScreen</key>
|
||||||
|
<dict/>
|
||||||
|
</dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>en</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>$(PRODUCT_NAME)</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
<true/>
|
||||||
|
<key>UIRequiredDeviceCapabilities</key>
|
||||||
|
<array>
|
||||||
|
<string>armv7</string>
|
||||||
|
</array>
|
||||||
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
12
Swiftgram/Playground/Sources/App.swift
Normal file
12
Swiftgram/Playground/Sources/App.swift
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import SwiftUI
|
||||||
|
import AsyncDisplayKit
|
||||||
|
import Display
|
||||||
|
|
||||||
|
@main
|
||||||
|
struct BazelApp: App {
|
||||||
|
var body: some Scene {
|
||||||
|
WindowGroup {
|
||||||
|
Text("Hello from Bazel!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
78
Swiftgram/Playground/generate_project.py
Executable file
78
Swiftgram/Playground/generate_project.py
Executable file
@ -0,0 +1,78 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from contextlib import contextmanager
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import shutil
|
||||||
|
import textwrap
|
||||||
|
|
||||||
|
# Import the locate_bazel function
|
||||||
|
sys.path.append(
|
||||||
|
os.path.join(os.path.dirname(__file__), "..", "..", "build-system", "Make")
|
||||||
|
)
|
||||||
|
from BazelLocation import locate_bazel
|
||||||
|
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def cwd(path):
|
||||||
|
oldpwd = os.getcwd()
|
||||||
|
os.chdir(path)
|
||||||
|
try:
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
os.chdir(oldpwd)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# Get the current script directory
|
||||||
|
current_script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
with cwd(os.path.join(current_script_dir, "..", "..")):
|
||||||
|
bazel_path = locate_bazel(os.getcwd())
|
||||||
|
# 1. Kill all Xcode processes
|
||||||
|
subprocess.run(["killall", "Xcode"], check=False)
|
||||||
|
|
||||||
|
# 2. Delete xcodeproj.bazelrc if it exists and write a new one
|
||||||
|
bazelrc_path = os.path.join(current_script_dir, "..", "..", "xcodeproj.bazelrc")
|
||||||
|
if os.path.exists(bazelrc_path):
|
||||||
|
os.remove(bazelrc_path)
|
||||||
|
|
||||||
|
with open(bazelrc_path, "w") as f:
|
||||||
|
f.write(
|
||||||
|
textwrap.dedent(
|
||||||
|
"""
|
||||||
|
build --announce_rc
|
||||||
|
build --features=swift.use_global_module_cache
|
||||||
|
build --verbose_failures
|
||||||
|
build --features=swift.enable_batch_mode
|
||||||
|
build --features=-swift.debug_prefix_map
|
||||||
|
# build --disk_cache=
|
||||||
|
|
||||||
|
build --swiftcopt=-no-warnings-as-errors
|
||||||
|
build --copt=-Wno-error
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# 3. Delete the Xcode project if it exists
|
||||||
|
xcode_project_path = os.path.join(current_script_dir, "Playground.xcodeproj")
|
||||||
|
if os.path.exists(xcode_project_path):
|
||||||
|
shutil.rmtree(xcode_project_path)
|
||||||
|
|
||||||
|
# 4. Write content to generate_project.py
|
||||||
|
generate_project_path = os.path.join(current_script_dir, "custom_bazel_path.bzl")
|
||||||
|
with open(generate_project_path, "w") as f:
|
||||||
|
f.write("def custom_bazel_path():\n")
|
||||||
|
f.write(f' return "{bazel_path}"\n')
|
||||||
|
|
||||||
|
# 5. Run xcodeproj generator
|
||||||
|
working_dir = os.path.join(current_script_dir, "..", "..")
|
||||||
|
bazel_command = f'"{bazel_path}" run //Swiftgram/Playground:Playground_xcodeproj'
|
||||||
|
subprocess.run(bazel_command, shell=True, cwd=working_dir, check=True)
|
||||||
|
|
||||||
|
# 5. Open Xcode project
|
||||||
|
subprocess.run(["open", xcode_project_path], check=True)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
x
Reference in New Issue
Block a user