Giter Site home page Giter Site logo

ios-example-app's Introduction

TodoApp iOS: An iOS Sample App

This xcode project wraps the Desktop Sample App to run on an iPhone.

How to build & run

  1. Install xcode from the app store.

  2. Install brew, git, carthage, npm

    brew install carthage git [email protected] npm

  3. Install Erlang-OTP (with openssl) in the same version 25.0.4 as the bundled runtime edition:

    asdf install erlang 25.0.4
    asdf install elixir 1.13.4-otp-25
    

    If above fails for you on an older mac or can't seem to find openssl you can try this custom build command as well:

    export DED_LDFLAGS_CONFTEST="-bundle"
    export KERL_CONFIGURE_OPTIONS="--without-javac --with-ssl=$(brew --prefix [email protected])"
    asdf install erlang 25.0.4
    asdf install elixir 1.13.4-otp-25
    
  4. fork / git clone this project to your local disk:

    git clone https://github.com/elixir-desktop/ios-example-app.git

  5. Build the dependencies:

    cd ios-example-app && carthage update --use-xcframeworks

  6. Open the ios-example-app project with xcode

  7. Start the App

Known todos

Menus and other integration not yet available

This sample only launch the elixir app and shows it in a WKWebView. There is no integration yet with the iOS Clipboard, sharing or other OS capabilities. They can though easily be added to the Bridge.swift file when needed.

Other notes

  • The Erlang runtime is for ease of use embedded in this example git repository. The native runtimes for M1 and iPhoneOS and the exqlite nif are are generated using the Desktop Runtime repository.

  • iOS specific settings, icons and metadata are all contained in this xcode wrapper project.

  • Bridge.swift and the native library are doing most of the wrapping of the Elixir runtime.

Screenshots

App

Architecture

App

The iOS App is initializing the Erlang VM and starting it up with a new environment variable BRIDGE_PORT. This environment variable is used by the Bridge Elixir project to connect to a local TCP server inside the iOS app. Through this new TCP communication channel all calls that usually would go to wxWidgets are now redirected. The iOS side of things implements handling in Bridge.swift.

ios-example-app's People

Contributors

dominicletz avatar opsb avatar ryowakabayashi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ios-example-app's Issues

macOS update from version 25.0.4 bundled runtime edition

Install Erlang-OTP (with openssl) in the same version 25.0.4 as the bundled runtime edition:

Is there a way to update the erlang version 25.0.4 as the bundled runtime edition?
Where is the bundled runtime version coming from to be able to update it?

Ive attempted for a day+ now attempting to get the iOS example running and cannot get erlang 25.0.4 to build on my machine with wxwidgets.

Intel macOS Ventura 13.6.6 (22G630)
Xcode Version 15.2 (15C500b)

I have attempted brew with multiple versions of wxwidgets and building wxwidgets from source - but I always get the same error when attempting with erlang version 25.0.4.

* wx : Can not link wx program are all developer packages installed?

While Im an a asdf novice and no build/release engineer - I think the issue is the same as this Elixir Forum Thread - “Can not link wx program” error when installing erlang where its an OTP / Xcode issue that was fixed / backported in later versions of OTP - but possibly not 25.0.4?

I thought I could try some later versions of OTP 25 and I can get everything to compile (also after relaxing the elixir 1.13 requirement for 1.14) - the iOS example app immediately crashes after launcing with:

elixir 1.14.3-otp-25
erlang 25.3.2.11

Bridge Server ready. Starting Elixir
setenv ELIXIR_DESKTOP_OS ios
setenv BRIDGE_PORT 23115
setenv HOME /Library/Developer/CoreSimulator/Devices/05A7AC5B-52E3-4336-8007-D882172C6FEC/data/Containers/Data/Application/F59D8C3F-E249-4A37-92CD-BE84876BE7D2/Library/net.cohawk.elixirdesktop.example
setenv BINDIR /Library/Developer/CoreSimulator/Devices/05A7AC5B-52E3-4336-8007-D882172C6FEC/data/Containers/Data/Application/F59D8C3F-E249-4A37-92CD-BE84876BE7D2/Library/net.cohawk.elixirdesktop.example/bin
Ret: ok

=SUPERVISOR REPORT==== 28-Apr-2024::13:19:33.108600 ===
    supervisor: {local,kernel_sup}
    errorContext: start_error
    reason: {{badmatch,{error,internal_error}},
             [{global,init,1,[{file,"global.erl"},{line,525}]},
              {gen_server,init_it,2,[{file,"gen_server.erl"},{line,851}]},
              {gen_server,init_it,6,[{file,"gen_server.erl"},{line,814}]},
              {proc_lib,init_p_do_apply,3,
                        [{file,"proc_lib.erl"},{line,240}]}]}
    offender: [{pid,undefined},
               {id,global_name_server},
               {mfargs,{global,start_link,[]}},
               {restart_type,permanent},
               {significant,false},
               {shutdown,2000},
               {child_type,worker}]

{"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{{shutdown,{failed_to_start_child,global_name_server,{{badmatch,{error,internal_error}},[{global,init,1,[{file,\"global.erl\"},{line,525}]},{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,851}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,814}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,240}]}]}}},{kernel,start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,kernel,{{shutdown,{failed_to_start_child,global_name_server,{{badmatch,{error,internal_error}},[{global,init,1,[{file,"global.erl"},{line,525}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,851}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,814}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}}},{kernel,start,[normal,[]]}}})

Crash dump is being written to: erl_crash.dump...done

Desktop Example app works fine when standalone - crazy project you've got here.

/Users/zuzannakowal/projects/24.beta/activate: No such file or directory

Hi! I've heard about the project in Thinking Elixir podcast.

I wanted to try it and when building I am getting the following error:

/Users/zuzannakowal/Library/Developer/Xcode/DerivedData/todoapp-brtxmrwciyidivgfgljugmuxqxyc/Build/Intermediates.noindex/todoapp.build/Debug-iphonesimulator/todoapp.build/Script-EC8A1FD6270B4EF900054F1C.sh: line 7: /Users/zuzannakowal/projects/24.beta/activate: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code

It might be an error with my setup. I am an elixir developer and just freshly installed xcode.

can't reconnect at real device

I put the iOS sample in the background and wait 30 seconds and come back, it will not reconnect and become inoperable.

The Android sample was not a problem.

iOS 16
devide iPhone SE 2nd gen
Elixir 1.14.1
elrang 25.0.1

2023-03-30 00:13:59.481001+0900 todoapp[21387:5657675] [connection] nw_socket_handle_socket_event [C1:1] Socket SO_ERROR [9: Bad file descriptor]
2023-03-30 00:13:59.482905+0900 todoapp[21387:5657675] [connection] nw_socket_get_input_frames [C1:1] recvmsg(fd 41, 4 bytes) [57: Socket is not connected]
2023-03-30 00:13:59.483627+0900 todoapp[21387:5657675] [connection] nw_read_request_report [C1] Receive failed with error "Socket is not connected"
connection 0 did end
server did close connection 0
�[31m[error] GenServer Bridge terminating
** (FunctionClauseError) no function clause matching in Bridge.handle_info/2
    (wx 1.0.10) lib/bridge.ex:227: Bridge.handle_info({:tcp_error, #Port<0.4>, :enotconn}, %Bridge{events: [], funs: %{164 => #Function<1.14728739/2 in Desktop.Window.close_window>}, port: 52165, requests: %{}, send: &:gen_tcp.send/2, socket: #Port<0.4>, subscribers: [#PID<0.202.0>]})
    (stdlib 4.0.1) gen_server.erl:1120: :gen_server.try_dispatch/4
    (stdlib 4.0.1) gen_server.erl:1197: :gen_server.handle_msg/6
    (stdlib 4.0.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {:tcp_error, #Port<0.4>, :enotconn}
State: %Bridge{events: [], funs: %{164 => #Function<1.14728739/2 in Desktop.Window.close_window>}, port: 52165, requests: %{}, send: &:gen_tcp.send/2, socket: #Port<0.4>, subscribers: [#PID<0.202.0>]}
�[0m�[31m[error] Process Bridge (#PID<0.203.0>) terminating
** (FunctionClauseError) no function clause matching in Bridge.handle_info/2
    (wx 1.0.10) lib/bridge.ex:227: Bridge.handle_info({:tcp_error, #Port<0.4>, :enotconn}, %Bridge{events: [], funs: %{164 => #Function<1.14728739/2 in Desktop.Window.close_window>}, port: 52165, requests: %{}, send: &:gen_tcp.send/2, socket: #Port<0.4>, subscribers: [#PID<0.202.0>]})
    (stdlib 4.0.1) gen_server.erl:1120: :gen_server.try_dispatch/4
    (stdlib 4.0.1) gen_server.erl:1197: :gen_server.handle_msg/6
    (stdlib 4.0.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Initial Call: Bridge.init/1
Ancestors: [Desktop.Env, Desktop.Sup, #PID<0.200.0>]
Message Queue Length: 1
Messages: [tcp_closed: #Port<0.4>]
Links: []
Dictionary: []
Trapping Exits: false
Status: :running
Heap Size: 987
Stack Size: 28
Reductions: 26431
�[0mconnection 0 did fail, error: POSIXErrorCode(rawValue: 57): Socket is not connected
2023-03-30 00:13:59.524915+0900 todoapp[21387:5656348] [connection] nw_connection_set_state_changed_handler_block_invoke [C1] Cannot set state changed handler after cancel
2023-03-30 00:13:59.525024+0900 todoapp[21387:5658395] [connection] [C1 127.0.0.1:62922 tcp, local: 127.0.0.1:52165, definite, attribution: developer, server, prohibit joining] is already cancelled, ignoring cancel

support elixir through asdf

building couldn't find any elixir installed.. adding this to shell script (below the nvm line) makes it pick up asdf installed elixir/erlang
[ -s "$HOME/.asdf/asdf.sh" ] && \. $HOME/.asdf/asdf.sh # This loads asdf

Fail to build on macOS 12.6, Xcode 14.0 and iOS 16.0

My environment is:

  • M2 Macbook Air
  • macOS 12.6
  • Xcode 14.0
  • iOS 16.0

I did the following steps:

  1. I built Erlang/OTP 25.0.4 with export DED_LDFLAGS_CONFTEST="-bundle" with asdf
  2. git clone https://github.com/elixir-desktop/ios-example-app.git
  3. cd ios-example-app
  4. carthage update --platform ios --use-xcframeworks --no-use-binaries --new-resolver (According to this issue: Carthage/Carthage#2615)
  5. open todoapp.xcodeproj
  6. Fix an issue of Bundle Identifier
  7. Connect my iPhone (iOS 16.0) and set the target to it
  8. Build

But, I got the error: error build: Command PhaseScriptExecution failed with a nonzero exit code.

I found the issue #3, but I feel my issue may be different to it.

Cannot open more than one ElixirDesktop app on the same device

Application crashed when opening a second application with one ElixirDesktop application already open.

When the running application was dropped using Task Manager, it worked fine.

bridge init()
Preparing app files 2023-05-11 05:46:38 +0000 installed: Optional("2023-05-11 05:39:32 +0000")
setenv ERL_INETRC /var/mobile/Containers/Data/Application/5F9AD2BF-025D-44B5-973D-5FF5E26129C4/Library/io.elixirdesktop.example2/app/inetrc
'%% enable EDNS, 0 means enable YES!
{edns,0}.
{alt_nameserver, {8,8,8,8}}.
%% specify lookup method
{lookup, [dns]}.'
Server starting...
.active
Server re-init called
2023-05-11 14:46:51.043901+0900 todoapp[2266:787410] [] nw_path_evaluator_evaluate NECP_CLIENT_ACTION_ADD error [48: Address already in use]
2023-05-11 14:46:51.043945+0900 todoapp[2266:787410] [] nw_path_create_evaluator_for_listener nw_path_evaluator_evaluate failed
2023-05-11 14:46:51.043981+0900 todoapp[2266:787410] [listener] nw_listener_start_on_queue [L1] nw_path_create_evaluator_for_listener failed
Server failure, error: The operation couldn’t be completed. Address already in use
2023-05-11 14:46:51.047702+0900 todoapp[2266:787412] [client] No error handler for XPC error: Connection invalid

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.