yglukhov / nimx

GUI library
MIT License
1.09k stars 75 forks source link

nake ios-sim - Hello world example app doesn't work #345

Closed iffy closed 4 years ago

iffy commented 5 years ago

I'm going to leave this issue open until I can launch an app :)

Doing the following (with the current HEAD):

#!/bin/bash
set -e
[ -e "nimxios" ] && rm -r nimxios
mkdir nimxios
cd nimxios
wget https://www.libsdl.org/release/SDL2-2.0.9.tar.gz
tar xf SDL2-2.0.9.tar.gz
cat <<E'O'F > main.nim
import nimx / [ window, layout, button, text_field ]

runApplication:
  let w = newWindow(newRect(50, 50, 500, 150))
  w.makeLayout:
    - Label as greetingLabel: # Add a view of type Label to the window. Create a local reference to it named greetingLabel.
        center == super # center point of the label should be equal to center point of superview
        width == 300 # width should be 300 points
        height == 15 # well, this should be obvious now
        text: "Press the Greet button to see the greeting" # property "text" should be set to whatever the label should display
    - Button: # Add a view of type Button. We're not referring to it so it's anonymous.
        centerX == super # center horizontally
        top == prev.bottom + 5 # the button should be lower than the label by 5 points
        width == 100
        height == 25
        title: "Greet"
        onAction:
          greetingLabel.text = "Hello, world!"
EOF

echo 'import nimx/naketools' > nakefile.nim
SDL_HOME="SDL2-2.0.9" nake ios-sim

makes an app that launches and immediately exits:

nolaunch

Here's what I think is the relevant portion from to log (xcrun simctl spawn booted log stream):

2018-11-07 15:39:53.145461-0700 0x2817d84  Default     0x0                  83427  NimxApp: (ManagedConfiguration) [com.apple.ManagedConfiguration:MC] Loaded MobileCoreServices.framework
2018-11-07 15:39:53.153259-0700 0x2817d84  Default     0x0                  83427  NimxApp: Could not find system font:
2018-11-07 15:39:53.153420-0700 0x2817d84  Default     0x0                  83427  NimxApp: Tried path '/Library/Fonts/OpenSans-Regular.ttf'
2018-11-07 15:39:53.153751-0700 0x2817d84  Default     0x0                  83427  NimxApp: Tried path '/Users/matt/Library/Developer/CoreSimulator/Devices/A9776308-4F5F-47C1-A271-E0976E62E24E/data/Containers/Bundle/Application/5F7E2DBC-1F53-442B-9FE5-792F298D2409/NimxApp.app/res/OpenSans-Regular.ttf'
2018-11-07 15:39:53.154086-0700 0x2817d84  Default     0x0                  83427  NimxApp: Tried path '/Users/matt/Library/Developer/CoreSimulator/Devices/A9776308-4F5F-47C1-A271-E0976E62E24E/data/Containers/Bundle/Application/5F7E2DBC-1F53-442B-9FE5-792F298D2409/Resources/OpenSans-Regular.ttf'
2018-11-07 15:39:53.154365-0700 0x2817d84  Default     0x0                  83427  NimxApp: Tried path '/Users/matt/Library/Developer/CoreSimulator/Devices/A9776308-4F5F-47C1-A271-E0976E62E24E/data/Containers/Bundle/Application/5F7E2DBC-1F53-442B-9FE5-792F298D2409/NimxApp.app/OpenSans-Regular.ttf'
2018-11-07 15:39:53.154502-0700 0x2817d84  Default     0x0                  83427  NimxApp: Could not create system font
2018-11-07 15:39:53.159178-0700 0x2817d84  Default     0x0                  83427  NimxApp: Traceback (most recent call last)
main.nim(3)              main
sdl_window.nim(436)      runUntilQuit
sdl_window.nim(355)      animateAndDraw
app.nim(105)             drawWindows
abstract_window.nim(79)  drawWindow
sdl_window.nim(178)      drawWindow
abstract_window.nim(85)  drawWindow
view.nim(442)            recursiveDrawSubviews
view.nim(437)            drawSubviews
view.nim(425)            drawWithinSuperview
view.nim(441)            recursiveDrawSubviews
view.nim(427)            draw
text_field.nim(268)      draw
formatted_text.nim(226)  drawText
formatted_text.nim(106)  updateCache
font.nim(130)            height
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
iffy commented 5 years ago

I can fix that by doing this before nake ios-sim:

mkdir -p res
cp $(nimble path nimx)/test/res/OpenSans-Regular.ttf res/

And it launches!

screen shot 2018-11-07 at 3 47 47 pm

But the "Greet" button doesn't work. Is that a known defect?

yglukhov commented 4 years ago

Everything mentioned above should be fixed now.