Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Issues building for ios #20

Closed
drbh opened this issue Oct 26, 2020 · 28 comments
Closed

Issues building for ios #20

drbh opened this issue Oct 26, 2020 · 28 comments

Comments

@drbh
Copy link
Contributor

drbh commented Oct 26, 2020

Screen Shot 2020-10-26 at 4 45 29 PM

I've added the framework and am a bit confused about the bridging header file...

A recent PR seems to have added this header file - maybe I'm missing a dependency?

@drbh
Copy link
Contributor Author

drbh commented Oct 26, 2020

@jakubkoci any insight?

Thank you!! 🙂

@jakubkoci
Copy link
Contributor

Unfortunately, I have the same problem. You need to manually link the Indy.framework library via Xcode. Although I linked Indy.framework as an embedded library, Xcode is still not able to find it.

@gnarula Have you solved this? Could you please help us and describe how to do it correctly?

@gnarula
Copy link
Contributor

gnarula commented Nov 2, 2020

uhm, it works here after I add Indy.framework to the workspace AND the frameworks directory in the Pods project. Make sure you select rn-indy-sdk as the target in the window that pops up.

@lhaber9
Copy link

lhaber9 commented Nov 2, 2020

Thank you @gnarula I was having the same issue and that was very helpful! I missed adding rn-indy-sdk as the target.

I now get an error saying that my Indy.framework is compiled with an older version of swift. Im wondering if you or @jakubkoci
could share the Indy.framework you're using? or how you compiled it with the correct swift version?

I see the Readme says to "Beware that the library needs to be compiled with the same version of Swift as your project" but i'm having trouble figuring out how to do that.

@jakubkoci
Copy link
Contributor

@lhaber9 You could install Xcode Toolchain version with the required version of Swfit. Here you can find toolchains for various versions of Swift: https://swift.org/download/#releases

Then you can change the toolchain in Xcode
image

@emberist
Copy link

emberist commented Nov 8, 2020

@gnarula @jakubkoci @lhaber9 Can someone help me with the same problem?

I build the Indy.framework for swift 5, but adding it to my code project I got this error:

Senza nome

@emberist
Copy link

emberist commented Nov 9, 2020

Finally resolved uninstalling and reinstalling the npm module and link the Indy.framework again

@lhaber9
Copy link

lhaber9 commented Nov 11, 2020

@riccardocaranfil Awesome! it sounds like you were able to successfully build the Indy.framework for swift 5. I haven't been able to do that yet. If you could list some steps for how you did that build it would be very helpful. Thank you!

@emberist
Copy link

emberist commented Nov 11, 2020

@lhaber9 Yes after hours of attempts I finally got it 🤣

I just did this:

  1. Changed the project Podfile using this pods:
    pod 'libsodium'
    pod 'libzmq',"4.2.3"
    pod 'OpenSSL-XM'
    pod 'libindy', "1.15.0"

  2. Run pod install, it takes like 10 minute

  3. In Build settings change the Swift Language Version to Swift 5

  4. Run Archive on the Indy target and you should get it working

If you need help, I will upload my Indy project in a new repo.

Hope it is helpful

@TimoGlastra
Copy link
Contributor

@riccardocaranfil I still get stuck on the archive step.

Would you be willing share the Indy.framework file for Swift 5?

@emberist
Copy link

@TimoGlastra I uploaded my project with the already build file

Available here -> https://github.com/riccardocaranfil/libindy-pod

@eli7ah
Copy link

eli7ah commented Jan 25, 2021

@riccardocaranfil could you please share an updated version of framework included Apple processor updates?
There is an error occurred while pods installing for your framework, but I still hope your solution will help me to save much more time for using Indy in my Swift project. Or give me please a suggestion how to fix the error.
Thanks in advance!

I'm using: Xcode 12.3, Swift 5.

Terminal output on pod install below:

Installing CoreBitcoin (0.6.8.1)
Installing ISO8601DateFormatter (0.8)
Installing OpenSSL-Universal (1.0.1.16)
Installing OpenSSL-XM (1.0.210.1)
[!] /bin/bash -c 
set -e
VERSION="1.0.2j"
SDKVERSION=`xcrun --sdk iphoneos --show-sdk-version 2> /dev/null`
MIN_SDK_VERSION_FLAG="-miphoneos-version-min=7.0"

BASEPATH="${PWD}"
CURRENTPATH="/tmp/openssl"
#CURRENTPATH="${PWD}/tmp"

ARCHS="i386 x86_64 armv7 armv7s arm64"
DEVELOPER=`xcode-select -print-path`


mkdir -p "${CURRENTPATH}"
mkdir -p "${CURRENTPATH}/bin"    

cp -rf "${BASEPATH}/" "${CURRENTPATH}/openssl-${VERSION}"
#cp "file.tgz" "${CURRENTPATH}/file.tgz"
cd "${CURRENTPATH}"
#tar -xzf file.tgz
cd "openssl-${VERSION}"

for ARCH in ${ARCHS}
do
  CONFIGURE_FOR="iphoneos-cross"

  if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ] ;
  then
    PLATFORM="iPhoneSimulator"
    if [ "${ARCH}" == "x86_64" ] ;
    then
      CONFIGURE_FOR="darwin64-x86_64-cc"
    fi
  else
    sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c"
    PLATFORM="iPhoneOS"
  fi

  export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
  export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"

  echo "Building openssl-${VERSION} for ${PLATFORM} ${SDKVERSION} ${ARCH}"
  echo "Please stand by..."

  export CC="${DEVELOPER}/usr/bin/gcc -arch ${ARCH} ${MIN_SDK_VERSION_FLAG}"
  mkdir -p "${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
  LOG="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/build-openssl-${VERSION}.log"

  LIPO_LIBSSL="${LIPO_LIBSSL} ${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/lib/libssl.a"
  LIPO_LIBCRYPTO="${LIPO_LIBCRYPTO} ${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/lib/libcrypto.a"

  ./Configure ${CONFIGURE_FOR} --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" > "${LOG}" 2>&1
  sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} !" "Makefile"

  make >> "${LOG}" 2>&1
  make all install_sw >> "${LOG}" 2>&1
  make clean >> "${LOG}" 2>&1
done


echo "Build library..."
rm -rf "${BASEPATH}/lib/"
mkdir -p "${BASEPATH}/lib/"
lipo -create ${LIPO_LIBSSL}    -output "${BASEPATH}/lib/libssl.a"
lipo -create ${LIPO_LIBCRYPTO} -output "${BASEPATH}/lib/libcrypto.a"

echo "Copying headers..."
rm -rf "${BASEPATH}/opensslIncludes/"
mkdir -p "${BASEPATH}/opensslIncludes/"
cp -RL "${CURRENTPATH}/openssl-${VERSION}/include/openssl" "${BASEPATH}/opensslIncludes/"

cd "${BASEPATH}"
echo "Building done."

echo "Cleaning up..."
rm -rf "${CURRENTPATH}"
echo "Done."

@TimoGlastra
Copy link
Contributor

TimoGlastra commented Jan 25, 2021

@eli7ah I recently made a new build with xcode 12.3 and swift 5, maybe that would work for you?

See https://github.com/animo/aries-mobile-agent-react-native/tree/develop/ios/Pods/Frameworks

If not, I can rebuild with the required modifications

@eli7ah
Copy link

eli7ah commented Jan 26, 2021

@TimoGlastra After several manipulations (etc. disabling bitcode in main target, but not sure yet if this meets the requirements of my project) I finally builded the project with Indy and can use it with Swift! I'll check everything and contact you if smth goes wrong. Great thanx!

@lhaber9
Copy link

lhaber9 commented Mar 22, 2021

@TimoGlastra im still having some trouble getting this working. I see you made a build above for xcode 12.3 and swift 5, any chance you could make one for 12.4 and swift 5.3.2? I have been trying unsuccessfully to do that.

Thank you!

@TimoGlastra
Copy link
Contributor

@lhaber9 the build you linked to should work with newer versions of Swift / XCode. Please see my comment here:

#37 (comment)

I think you need to enable the setting from the article (If you're not using the app you linked to) for your project.

@TimoGlastra
Copy link
Contributor

But I haven't tried with the specific Swift / Xcode versions you mentioned, so could be that it doesn't work for this combination

@lhaber9
Copy link

lhaber9 commented Mar 22, 2021

@TimoGlastra When i try to build using the Indy.Framwork file you shared above i get an error message that "module compiled with Swift 5.3 cannot be imported by the Swift 5.3.2 compiler".

I did see the text about turning on the "Build libraries for distribution" option but im a little unclear. My understanding is that setting would need to be turned on in the Indy project when archiving. But I have not been able to successfully build the indy project and get my own Indy.Framework, so i havent been able to use that option.

Any other thoughts you have about getting a version to work with swift 5.3.2 are much appreciated. Thank you for your help!

@jeremyKim
Copy link

jeremyKim commented Mar 26, 2021

Hi.
I am new to iOS, so I don't have much knowledge about iOS development.

I have a wierd problem.
I followed this guide above like this.

Changed the project Podfile using this pods:
pod 'libsodium'
pod 'libzmq',"4.2.3"
pod 'OpenSSL-XM'
pod 'libindy', "1.15.0"
Run pod install, it takes like 10 minute

In Build settings change the Swift Language Version to Swift 5

When I try to archive Indy, a wired error occurred like this.
"None of the ZMQ_USE* macros defined"_

So, I tried to add ZMQ_USE_KQUEUE in pod file like below, then build succeeded.
if target.name == 'libzmq' target.build_configurations.each do |config| config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'ZMQ_BUILD_DRAFT_API=1', 'ZMQ_USE_KQUEUE'] end

But, my framework has a problem, when I called "IndyPool.openLedger()" api, an error occurred like below.

thread '' panicked at 'FIXME: Operation not supported', src/libcore/result.rs:1165:5
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace.

Any other apis that do not need network connection like "IndyWallet.createWallet", "IndyDid.createAndStoreMyDid()", "IndyPool.createPoolLedgerConfig" all work well.
I guess it has something to do with 'libzmq'.

So, I tried to changed ZMQ_USE_* option to others, but build failed.

I really hope to know what I did wrong.
Would you please help me?

@jeremyKim
Copy link

I resolved my issue. It was my poor mistake.
I used a wrong platform.hpp, so wrong preprocessors are defined.

@riccardocaranfil
I really appreciate your kind guide, you saved me.

@i4apple
Copy link

i4apple commented Apr 8, 2021

I resolved my issue. It was my poor mistake.
I used a wrong platform.hpp, so wrong preprocessors are defined.

@riccardocaranfil
I really appreciate your kind guide, you saved me.

Which one is correct platform.hpp file

@jeremyKim
Copy link

@i4apple

Hi. I had a same problem too.
According to this page, (zeromq/zeromq4-x#162)

The platform.hpp is generated at build time by autoconf/cmake/etc.

So, I think if you try to compile zmq by cmake, you probably are gonna get right 'platform.hpp' file.

But, I did not follow above guide, I just manually generated 'platform.hpp' file refering to this file (https://github.com/zeromq/libzmq/blob/master/builds/cmake/platform.hpp.in)

I am not sure that my approach is right or not, but I ended up succeeding to archive indy.framework.

Here I attach my own platform.hpp file below.
I hope it is helpful.

platform.zip

@i4apple
Copy link

i4apple commented Apr 8, 2021

Hi @jeremyKim
Thanks for help. I dragged given file after that I am getting following issue.
I am using Xcode 12.4 and swift version 5.3.2
Screenshot 2021-04-09 at 00 27 39
also,
Do you build Indy framework on Swift version 5.3.2 ?
Thanks in advance.

@i4apple
Copy link

i4apple commented Apr 8, 2021

@lhaber9, Can you please look into the issue or please help me for getting Indy to build for Swift version 5.3.2.

@jeremyKim
Copy link

@i4apple
I am using Xcode 12.4 and swift version 5.3.3

I checked my build setting and found something related to ZMQ_USE_* preprocessor.

799B316E-DC80-4DEF-90D2-F9942F3CE4F4_1_105_c

I am not sure that I manually added 'ZMQ_USE_KQUEUE' preprocessor into libzmq before.

But, I think it is worthful to give it a try.
I hope it will be helpful.

@i4apple
Copy link

i4apple commented Apr 9, 2021

@jeremyKim
Thanks a lot for helping me but a suggested solution does not work for me. It would be very helpful if you upload the Indy framework and libzmq folder & share a link. I spend a lot of time to get it done but not yet successes.

@i4apple
Copy link

i4apple commented Apr 9, 2021

@jeremyKim
The issue is resolve on my end, as you mentioned check macros "ZMQ_USE_KQUEUE" firstly that won't work for me coz I manually added in build setting, after I check your "post #20 (comment)" then I add below line in my podfile
if target.name == 'libzmq' target.build_configurations.each do |config| config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'ZMQ_BUILD_DRAFT_API=1', 'ZMQ_USE_KQUEUE'] end

then It works for me after again I installed pod.
Thanks a lot @jeremyKim

@jakubkoci
Copy link
Contributor

I'm closing the issue in favor of hyperledger-archives/indy-sdk-react-native#11. This repository is being archived. If you have any other issues, please report them in the new repository hyperledger/indy-sdk-react-native.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants