ooni / probe

OONI Probe network measurement tool for detecting internet censorship
https://ooni.org/install
BSD 3-Clause "New" or "Revised" License
750 stars 142 forks source link

engine, ios: link failure when building app #2569

Closed bassosimone closed 8 months ago

bassosimone commented 8 months ago

When using v3.19.0-alpha.3 and building the ooni/probe-ios app using the following command:

xcodebuild -workspace ooniprobe.xcworkspace -scheme ooniprobe \
            -destination='name=Any iOS Device' -sdk iphoneos archive CODE_SIGNING_ALLOWED="NO"

the build fails with this error:

ld: Undefined symbols:
  _tor_main_configuration_free, referenced from:
      __cgo_fb150ed03222_Cfunc_tor_main_configuration_free in Oonimkall[arm64][28](000025.o)
  _tor_main_configuration_new, referenced from:
      __cgo_fb150ed03222_Cfunc_tor_main_configuration_new in Oonimkall[arm64][28](000025.o)
  _tor_main_configuration_set_command_line, referenced from:
      __cgo_fb150ed03222_Cfunc_tor_main_configuration_set_command_line in Oonimkall[arm64][28](000025.o)
  _tor_main_configuration_setup_control_socket, referenced from:
      __cgo_fb150ed03222_Cfunc_tor_main_configuration_setup_control_socket in Oonimkall[arm64][28](000025.o)
  _tor_run_main, referenced from:
      __cgo_fb150ed03222_Cfunc_tor_run_main in Oonimkall[arm64][28](000025.o)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The reason why this happens is that gomobile bind produces an .xcframework that contains .a archives. Therefore, the linker flags in enabled.go have no effect, because we do not engage into proper linking, since we're just building static libraries. (I wrote a small PoC to show what happens in greater detail.)

The solution to this issue seems to build an additional .xcframework for libcrypto, libevent, libtor, libssl, and libz to link along with oonimkall.xcframework into the OONI Probe iOS app.