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:
Do not create a zip file, simply ask Xcode to copy all necessary files (while preserving directory structures) so that Xcode can automatically sign the dynamic library.
This approach would also require a Copy Files Phase, and the dynamic library will be placed under the main resources directory (UIBundle.main).
Therefore, the load_nif function will need to adjust the filepath. For this library, we need to changenif_file = '#{:code.priv_dir(:evision)}/evision' to nif_file = '#{:code.priv_dir(:evision)}/../../../../evision'.
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.
Sign the dynamic library manually (by manually I mean to sign it in the run_mix script instead of using Xcode) and then create the zip file.
Of course, the developer needs to somehow give the codesign information (could use an env var). Signing identity can be found using security find-identity -v -p codesigning.
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!
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:
Do not create a zip file, simply ask Xcode to copy all necessary files (while preserving directory structures) so that Xcode can automatically sign the dynamic library.
This approach would also require a
Copy Files Phase
, and the dynamic library will be placed under the main resources directory (UIBundle.main
).Therefore, the
load_nif
function will need to adjust the filepath. For this library, we need to changenif_file = '#{:code.priv_dir(:evision)}/evision'
tonif_file = '#{:code.priv_dir(:evision)}/../../../../evision'
.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 oneCopy Files Phase
with specific subpath for each NIF library used in the app.Sign the dynamic library manually (by manually I mean to sign it in the
run_mix
script instead of using Xcode) and then create the zip file.Of course, the developer needs to somehow give the codesign information (could use an env var). Signing identity can be found using
security find-identity -v -p codesigning
.Then
export CODESIGN_ID="Apple Development: First Last (1234ABCDEF)"
And add the codesign command in the
run_mix
script before thezip
command.cc @zacky1972, I remembered that you were also dealing with the code signature issue, hope this will help!