cocoa-xu / evision

Evision: An OpenCV-Erlang/Elixir binding
https://evision.app
Apache License 2.0
337 stars 22 forks source link

Compile for iOS if MIX_TARGET=ios #79

Closed cocoa-xu closed 2 years ago

cocoa-xu commented 2 years ago

This is still an experimental feature, and this feature is mainly to make it compatible with ElixirDesktop. Currently the NIF library compiles, however, there are some hacks needed to use it on iOS.

As iOS requires any dynamic library to be codesigned, we cannot simply pack everything as a zip file expecting iOS to load unsigned code.

There are two potential ways to deal with this:

Screenshot 2022-09-26 at 12 42 08

It's also possible to change the subpath in the Copy Files Phase so we don't need the above changes. Of course, in this way, there will be one Copy Files Phase with specific subpath for each NIF library used in the app.

  1) 1234567890ABCDEF1234567890ABCDEF12345678 "Apple Development: First Last (1234ABCDEF)"
     1 valid identities found

Then export CODESIGN_ID="Apple Development: First Last (1234ABCDEF)"

And add the codesign command in the run_mix script before the zip command.

mix assets.deploy && \
  mix release --overwrite && \
  cd _build/ios_prod/rel/todo_app && \
  echo "CODESIGN_ID: ${CODESIGN_ID}" && \
  # change ".so" if you have dynamic libraries using other file extensions
  find . -name "*.so" -exec codesign --force --sign "${CODESIGN_ID}" {} \; && \
  zip -9r "$BASE/todoapp/app.zip" lib/ releases/

cc @zacky1972, I remembered that you were also dealing with the code signature issue, hope this will help!

cocoa-xu commented 1 year ago

cc @zacky1972 (sorry the ping in the comment above didn't work)

Hope this would help to get the issue #18 (in sample_nx_add_by_gpu) sorted. :)

zacky1972 commented 1 year ago

Great! Thanks!