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

iOS #60

Merged
merged 45 commits into from
Oct 18, 2023
Merged

iOS #60

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
27de036
refactoring shared swift logic
zackbrown Oct 3, 2023
b787064
refactoring shared swift logic
zackbrown Oct 3, 2023
d1d6c32
git config
zackbrown Oct 3, 2023
5577068
cargo config
zackbrown Oct 3, 2023
3db82ce
cargo config
zackbrown Oct 3, 2023
cdb0314
cargo config
zackbrown Oct 3, 2023
9f1f771
appease swift
zackbrown Oct 3, 2023
b1bc32a
substantial refactoring for macos and ios, wip safety
zackbrown Oct 3, 2023
df4129a
wip: safety
zackbrown Oct 3, 2023
3b07a2b
wip: safety, progress; getting meaningful errors from xcode now
zackbrown Oct 3, 2023
d5a7220
wip: safety
zackbrown Oct 4, 2023
4201738
wip: safety
zackbrown Oct 4, 2023
27e5288
wip: safety
zackbrown Oct 5, 2023
226d0ee
achieve modularized macos build
zackbrown Oct 5, 2023
c9af562
cleaning, wip toward getting assets back into mac builds
zackbrown Oct 5, 2023
1b549f8
achieve swift image bundling & loading via SPM package
zackbrown Oct 5, 2023
1fc708e
toward iOS; build refactoring & cleaning
zackbrown Oct 6, 2023
5ba2dc0
re-achieve e2e mac builds
zackbrown Oct 6, 2023
08e41af
multithread multi-arch builds
zackbrown Oct 7, 2023
f617e26
wip: multi-arch release builds
zackbrown Oct 7, 2023
93eb898
wip: toward multi-arch release builds
zackbrown Oct 7, 2023
1dd86fa
achieve multi-arch builds for macos using lipo
zackbrown Oct 9, 2023
50c3bf5
print correct output path for macos builds
zackbrown Oct 9, 2023
2fcac47
cleaning
zackbrown Oct 9, 2023
645d4e6
wip: add placeholder frameworks + dylibs for ios and ios simulator
zackbrown Oct 9, 2023
f223fca
wip: safety
zackbrown Oct 9, 2023
d5fb49d
refactor xcframework to satisfy xcode + ios simulator
zackbrown Oct 9, 2023
0b9b2a1
hello iOS
zackbrown Oct 9, 2023
c505efe
polish for iOS
zackbrown Oct 10, 2023
be73fda
wip: toward robust iOS and macOS builds
zackbrown Oct 10, 2023
34ca913
reduce xcode build errors; cleaning
zackbrown Oct 12, 2023
1b8b095
add color grid example
zackbrown Oct 12, 2023
b304a50
wip: toward robust iOS and macOS builds
zackbrown Oct 13, 2023
36b8115
wip: toward robust iOS and macOS builds
zackbrown Oct 13, 2023
bacba8d
wip: toward robust iOS and macOS builds
zackbrown Oct 14, 2023
40f48b5
cleaning
zackbrown Oct 14, 2023
778a525
cleaning and conditional rendering of update banner for libdev mode
zackbrown Oct 16, 2023
68755e2
cleaning
zackbrown Oct 16, 2023
22538bf
adjust error handling when starting ios simulator
zackbrown Oct 16, 2023
ca7a3e5
achieve e2e run on ios simulator
zackbrown Oct 17, 2023
0f4f7b6
cleaning and vetting {ios, macos, web} x {debug, release} x {run, build}
zackbrown Oct 17, 2023
b136612
rebase fixes and cleaning
zackbrown Oct 17, 2023
0218942
update readme support matrix
zackbrown Oct 17, 2023
b8457b0
updated readme
warfaj Oct 18, 2023
4d8a878
updated readme & fixed booting issues (uuid differences, decouple boo…
warfaj Oct 18, 2023
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
12 changes: 9 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ node_modules
target/
vendor/

pax-chassis-macos/pax-dev-harness-macos/build
.swiftpm
.build


xcuserdata

pax-chassis-macos/interface/build
pax-example/build
pax-example/.pax/
pax-create-sandbox/
Expand All @@ -16,5 +22,5 @@ Cargo.lock
## VScode project configuration files
.vscode/

pax-chassis-macos/pax-dev-harness-macos/pax-dev-harness-macos.xcodeproj/project.xcworkspace/xcuserdata/**/*
pax-chassis-macos/pax-dev-harness-macos/pax-dev-harness-macos.xcodeproj/xcuserdata/**/*
pax-chassis-macos/interface/interface.xcodeproj/project.xcworkspace/xcuserdata/**/*
pax-chassis-macos/interface/interface.xcodeproj/xcuserdata/**/*
2 changes: 2 additions & 0 deletions .idea/vcs.xml

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exclude = [
"pax-compiler/new-project-template",
"pax-example",
"pax-properties-coproduct",
"pax-chassis-macos/pax-dev-harness-macos",
"pax-chassis-macos/interface",
"pax-create-sandbox",
"pax-language-server",
]
Expand Down
107 changes: 79 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,70 @@ Writing Pax is intended to feel familiar and the language borrows many ideas fro
Following is a simple Pax component called `IncrementMe`:

```rust
//File: increment-me.rs

//File: lib.rs
use pax_lang::*;
use pax_std::{Text};
use pax_std::forms::{Button, ArgsButtonSubmit};
use pax_std::layout::{Stacker};
use pax_lang::api::*;
use pax_std::primitives::*;
use pax_std::types::*;
use pax_std::types::text::*;
use pax_std::components::Stacker;

/// Defines the Pax component `IncrementMe`, with template & settings specified in `increment-me.pax`.
#[derive(Pax)]
#[file("increment-me.pax")]
#[main]
#[file("increment-me.pax")]
pub struct IncrementMe {
pub num_clicks: Property<i64>
pub num_clicks: Property<u32>,
pub message: Property<String>,
}

impl IncrementMe {
pub async fn increment(&self, args: ArgsButtonSubmit) {
let old_num_clicks = self.num_clicks.get();
self.num_clicks.set(old_num_clicks + 1);
}
}
pub fn handle_did_mount(&mut self, ctx: RuntimeContext) {
self.num_clicks.set(0);
self.message.set("0 clicks".to_string());
}
pub fn increment(&mut self, ctx: RuntimeContext, args: ArgsClick){
let old_num_clicks = self.num_clicks.get();
self.num_clicks.set(old_num_clicks + 1);
self.message.set(format!("{} clicks", self.num_clicks.get()));
}

}
```
```rust
//File: increment-me.pax
//increment-me.pax
<Text text={self.message} class=centered id=text class=centered />
<Rectangle class=centered class=small @click=self.increment
fill={Fill::Solid(Color::rgba(0.0,0.0,0.0,1.0))}
corner_radii={RectangleCornerRadii::radii(10.0,10.0,10.0,10.0)}
/>

@handlers{
did_mount:handle_did_mount
}

<Stacker cells=2>
<Text text={"I have been clicked " + self.num_clicks + " times."}></Text>
<Button @submit=self.increment>"Increment me!"</Button>
</Stacker>
@settings {
.centered {
x: 50%
y: 50%
anchor_x: 50%
anchor_y: 50%
}
.small {
width: 120px
height: 120px
}
#text {
style: {
font: {Font::system("Times New Roman", FontStyle::Normal, FontWeight::Bold)},
font_size: 32px,
fill: {Color::rgba(1.0, 1.0, 1.0, 1.0)},
align_vertical: TextAlignVertical::Center,
align_horizontal: TextAlignHorizontal::Center,
align_multiline: TextAlignHorizontal::Center
}
}
}
```

Any Pax component like the example above may be included inside other Pax components, or may be mounted as the root of a stand-alone app.
Expand Down Expand Up @@ -107,24 +144,38 @@ Read more in [The Pax Docs](https://docs.pax.dev/)
### To build Pax projects as native macOS apps

- Building macOS apps requires running a Mac with macOS. This is a constraint enforced technically and legally by Apple.
- Install xcode `>=14.3` and Xcode command line utils: `xcode-select --install`
- SDK Version `macosx13.3`, Xcode version `>=14.3`
- Install xcode `>=15.0` and Xcode command line utils: `xcode-select --install`
- Make sure to accept Xcode's license agreement (prompted during Xcode startup for the first time)
- SDK Version `macosx13.3`, Xcode version `>=15.0`
- Current Minimum Deployment `13.0`
- Install all necessary build architectures for Rust, so that binaries can be built for both Intel and Apple Silicon macs
```
rustup target add aarch64-apple-darwin x86_64-apple-darwin
```

### To build Pax projects as native iOS apps

- Follow instructions for building native macOS apps, above
- Install all necessary build architectures for Rust, so that binaries can be built for iOS and simulator targets:
```
rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim
```
- Install [ios simulator through Xcode](https://developer.apple.com/documentation/safari-developer-tools/adding-additional-simulators)

#### Support matrix:

| | Web browsers | Native iOS | Native Android | Native macOS | Native Windows | Native Linux |
|-----------------------------------------|---------------|---------------------|-------------------|---------------------|-----------------------------|--------------|
| Development harness & chassis | ✅ | | ⏲ | ✅ | ⏲ | ⏲ |
| 2D rendering and UIs | ✅ <br/>Canvas | <br/>CoreGraphics | ⏲ <br/>Cairo | ✅ <br/>CoreGraphics | ⏲ <br/>Direct2D | ⏲ <br/>Cairo |
| Development harness & chassis | ✅ | | ⏲ | ✅ | ⏲ | ⏲ |
| 2D rendering and UIs | ✅ <br/>Canvas | <br/>CoreGraphics | ⏲ <br/>Cairo | ✅ <br/>CoreGraphics | ⏲ <br/>Direct2D | ⏲ <br/>Cairo |
| 3D rendering and UIs | ⏲ | ⏲ | ⏲ | ⏲ | ⏲ | ⏲ |
| Vector graphics APIs | ✅ | | ⏲ | ✅ | ⏲ | ⏲ |
| 2D layouts | ✅ | | ⏲ | ✅ | ⏲ | ⏲ |
| Animation APIs | ✅ | | ⏲ | ✅ | ⏲ | ⏲ |
| Native text rendering | ✅ <br/>DOM | <br/>UIKit | ⏲ <br/>android:\* | ✅ <br/>SwiftUI | ⏲ <br/>System.Windows.Forms | ⏲ <br/>GTK |
| Native form elements | ⏲ <br/>DOM | ⏲ <br/>UIKit | ⏲ <br/>android:\* | ⏲ <br/>SwiftUI | ⏲ <br/>System.Windows.Forms | ⏲ <br/>GTK |
| Native event handling (e.g. Click, Tap) | ✅ | | ⏲ | ✅ | ⏲ | ⏲ |
| Rust host language | ✅ <br/>WASM | <br/>LLVM | ⏲ <br/>LLVM | ✅ <br/>LLVM | ⏲ <br/>LLVM | ⏲ <br/>LLVM |
| Vector graphics APIs | ✅ | | ⏲ | ✅ | ⏲ | ⏲ |
| 2D layouts | ✅ | | ⏲ | ✅ | ⏲ | ⏲ |
| Animation APIs | ✅ | | ⏲ | ✅ | ⏲ | ⏲ |
| Native text rendering | ✅ <br/>DOM | <br/>SwiftUI | ⏲ <br/>android:\* | ✅ <br/>SwiftUI | ⏲ <br/>System.Windows.Forms | ⏲ <br/>GTK |
| Native form elements | ⏲ <br/>DOM | ⏲ <br/>SwiftUI | ⏲ <br/>android:\* | ⏲ <br/>SwiftUI | ⏲ <br/>System.Windows.Forms | ⏲ <br/>GTK |
| Native event handling (e.g. Click, Tap) | ✅ | | ⏲ | ✅ | ⏲ | ⏲ |
| Rust host language | ✅ <br/>WASM | <br/>LLVM | ⏲ <br/>LLVM | ✅ <br/>LLVM | ⏲ <br/>LLVM | ⏲ <br/>LLVM |
| JS/TypeScript host language | ⏲ | ⏲ | ⏲ | ⏲ | ⏲ | ⏲ |

| Legend: |
Expand Down
Loading