AbsaOSS / rn-indy-sdk

This code was starting point of https://github.com/hyperledger/indy-sdk-react-native where the work continues.
Apache License 2.0
11 stars 6 forks source link

Issues building for ios #20

Closed drbh closed 3 years ago

drbh commented 3 years ago

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 commented 3 years ago

@jakubkoci any insight?

Thank you!! 🙂

jakubkoci commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

@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 commented 3 years ago

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

lhaber9 commented 3 years ago

@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 commented 3 years ago

@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 commented 3 years ago

@riccardocaranfil I still get stuck on the archive step.

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

emberist commented 3 years ago

@TimoGlastra I uploaded my project with the already build file

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

eli7ah commented 3 years ago

@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 commented 3 years ago

@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 commented 3 years ago

@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 commented 3 years ago

@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 commented 3 years ago

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

https://github.com/AbsaOSS/rn-indy-sdk/pull/37#discussion_r555850647

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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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 ZMQUSE* 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 ZMQUSE* option to others, but build failed.

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

jeremyKim commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

@i4apple

Hi. I had a same problem too. According to this page, (https://github.com/zeromq/zeromq4-x/issues/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 commented 3 years ago

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 commented 3 years ago

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

jeremyKim commented 3 years ago

@i4apple I am using Xcode 12.4 and swift version 5.3.3

I checked my build setting and found something related to ZMQUSE* 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 commented 3 years ago

@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 commented 3 years ago

@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 https://github.com/AbsaOSS/rn-indy-sdk/issues/20#issuecomment-808038128" 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 commented 3 years ago

I'm closing the issue in favor of hyperledger/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.