Bad CRC while building TensorFlowLiteSelectTfOps_framework
@vishnukvmd I have tried to build in MacOS with the command provided and I have received different error. Please refer the below screenshot. Thanks!

<img width="1037" alt="Screenshot 2023-02-20 at 1 23 32 PM" src="https://user-images.githubusercontent.com/118897289/220045388-e4f9f5cf-2dda-437d-86fe-5d0e4434af27.png">

 Hey @pjpratik, sorry I'm not sure what this error is about. It sounds like your toolchain has not been configured correctly. Please make sure that you're following the steps @ https://www.tensorflow.org/lite/guide/build_ios. You might also want to check out https://developer.apple.com/metal/tensorflow-plugin/ and ensure that the right version of bazel is installed via https://docs.bazel.build/versions/5.3.0/install-bazelisk.html.

Also, the "awaiting response" label does not correctly reflect the status of the ticket. But thank you for looking into this! :) @vishnukvm Thanks for the information. I did follow the steps provided. However, still getting the same error. Need to dig deep.

Hi @sachinprasadhs , could you please look into this issue. Thanks. Can you try the following command?
`bazel build -c opt --config=ios --ios_multi_cpus=sim_arm64 //tensorflow/lite/ios:TensorFlowLiteSelectTfOps_framework` or
`bazel build -c opt --config=ios --ios_multi_cpus=arm64 //tensorflow/lite/ios:TensorFlowLiteSelectTfOps_framework` Hey @yishuangP!

Did that, the build succeeded on tag `2.12`, but linking the output binary is failing with the following error:

Build output:
<details>
<summary>Click to expand!</summary> 

```
Launching lib/main.dart on Vishnu’s iPhone in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: 6Z68YJY9Q2
Xcode build done.                                           114.5s
Failed to build iOS app
Could not build the precompiled application for the device.
Error (Xcode): Undefined symbol: _TfLiteFloatArrayCreate
Error (Xcode): Undefined symbol: _TfLiteIntArrayCopy
Error (Xcode): Undefined symbol: _TfLiteIntArrayCreate

Error (Xcode): Undefined symbol: _TfLiteIntArrayEqual

Error (Xcode): Undefined symbol: _TfLiteIntArrayEqualsArray

Error (Xcode): Undefined symbol: _TfLiteIntArrayFree

Error (Xcode): Undefined symbol: _TfLiteIntArrayGetSizeInBytes
Error (Xcode): Undefined symbol: _TfLiteQuantizationFree

Error (Xcode): Undefined symbol: _TfLiteSparsityFree

Error (Xcode): Undefined symbol: _TfLiteTensorCopy

Error (Xcode): Undefined symbol: _TfLiteTensorDataFree

Error (Xcode): Undefined symbol: _TfLiteTensorFree

Error (Xcode): Undefined symbol: _TfLiteTensorRealloc
Error (Xcode): Undefined symbol: _TfLiteTensorReset
Error (Xcode): Undefined symbol: _TfLiteTensorResizeMaybeCopy

Error (Xcode): Undefined symbol: _TfLiteTypeGetName

Error (Xcode): Undefined symbol: tensorflow::MemoryDump::MemoryDump(google::protobuf::Arena*, bool)

Error (Xcode): Undefined symbol: tensorflow::MemoryDump::~MemoryDump()

Error (Xcode): Undefined symbol: tensorflow::RPCOptions::MergeImpl(google::protobuf::Message&, google::protobuf::Message const&)

Error (Xcode): Undefined symbol: tensorflow::RPCOptions::RPCOptions(tensorflow::RPCOptions const&)

Error (Xcode): Undefined symbol: tensorflow::RPCOptions::~RPCOptions()
Error (Xcode): Undefined symbol: tensorflow::HistogramProto::Clear()

Error (Xcode): Undefined symbol: tensorflow::HistogramProto::MergeImpl(google::protobuf::Message&, google::protobuf::Message const&)

Error (Xcode): Undefined symbol: tensorflow::HistogramProto::~HistogramProto()

Error (Xcode): Undefined symbol: tensorflow::_RPCOptions_default_instance_
Error (Xcode): Undefined symbol: tensorflow::_HistogramProto_default_instance_

Error (Xcode): Undefined symbol: tensorflow::error::Code_descriptor()
Error (Xcode): Undefined symbol: tensorflow::BinSummary* google::protobuf::Arena::CreateMaybeMessage<tensorflow::BinSummary>(google::protobuf::Arena*)

Error (Xcode): Undefined symbol: tensorflow::RPCOptions* google::protobuf::Arena::CreateMaybeMessage<tensorflow::RPCOptions>(google::protobuf::Arena*)

Error (Xcode): Undefined symbol: tensorflow::HistogramProto* google::protobuf::Arena::CreateMaybeMessage<tensorflow::HistogramProto>(google::protobuf::Arena*)

Error (Xcode): Undefined symbol: tensorflow::MemAllocatorStats* google::protobuf::Arena::CreateMaybeMessage<tensorflow::MemAllocatorStats>(google::protobuf::Arena*)

Error (Xcode): Undefined symbol: tensorflow::MemChunk* google::protobuf::Arena::CreateMaybeMessage<tensorflow::MemChunk>(google::protobuf::Arena*)

Error (Xcode): Undefined symbol: tensorflow::RPCOptions::ByteSizeLong() const
Error (Xcode): Undefined symbol: tensorflow::HistogramProto::ByteSizeLong() const

Error (Xcode): Undefined symbol: _descriptor_table_tensorflow_2ftsl_2fprotobuf_2fbfc_5fmemory_5fmap_2eproto

Error (Xcode): Undefined symbol: _descriptor_table_tensorflow_2ftsl_2fprotobuf_2ferror_5fcodes_2eproto

Error (Xcode): Undefined symbol: _descriptor_table_tensorflow_2ftsl_2fprotobuf_2fhistogram_2eproto
Error (Xcode): Undefined symbol: _descriptor_table_tensorflow_2ftsl_2fprotobuf_2frpc_5foptions_2eproto

Error (Xcode): Undefined symbol: _descriptor_table_tensorflow_2ftsl_2fprotobuf_2ftest_5flog_2eproto

Error launching application on Vishnu’s iPhone.
Exited
```

</details>

Edit: Just fyi, the output binary is 1,147,338,064 bytes in size > Did that, the build succeeded on tag 2.12, but linking the output binary is failing with the following error:

Did you also include the c framework? TensorFlowLiteSelectTfOps only has the custom ops. You need to build the TensorFlowLiteC as well. It has the tflite runtime and builtin ops. You can find instructions [here](https://www.tensorflow.org/lite/guide/build_ios#build_tensorflowlitec_dynamic_framework_recommended).


> Edit: Just fyi, the output binary is 1,147,338,064 bytes in size

Yes this is normal, TensorFlowLiteSelectTfOps is very large so if your model only use tflite builtin ops, you don't need to build TensorFlowLiteSelectTfOps. Besides, we also release TensorFlowLiteSelectTfOps via cocoapods, so you can install it from cocoapods. 
 Thank you for the tip @yishuangP!

The `Podfile` now contains the following:
```
pod 'TensorFlowLiteSwift', '~> 2.11'
pod 'TensorFlowLiteSelectTfOps', '~> 2.11'
```

But the build is still failing, but with a different error:

```
Failed to build iOS app
Could not build the precompiled application for the device.
Error (Xcode): Undefined symbol: tensorflow::HistogramProto::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*)

Error (Xcode): Undefined symbol: tensorflow::HistogramProto::Clear()

Error (Xcode): Undefined symbol: tensorflow::HistogramProto::MergeFrom(tensorflow::HistogramProto const&)

Error (Xcode): Undefined symbol: tensorflow::_HistogramProto_default_instance_

Error (Xcode): Undefined symbol: tensorflow::HistogramProto* google::protobuf::Arena::CreateMaybeMessage<tensorflow::HistogramProto>(google::protobuf::Arena*)

Error (Xcode): Undefined symbol: tensorflow::HistogramProto::ByteSizeLong() const

Error (Xcode): Undefined symbol: tensorflow::HistogramProto::InternalSerializeWithCachedSizesToArray(unsigned char*) const

Error (Xcode): Undefined symbol: _descriptor_table_tensorflow_2ftsl_2fprotobuf_2ferror_5fcodes_2eproto

Error (Xcode): Undefined symbol: _descriptor_table_tensorflow_2ftsl_2fprotobuf_2fhistogram_2eproto

Error (Xcode): Undefined symbol: _scc_info_HistogramProto_tensorflow_2ftsl_2fprotobuf_2fhistogram_2eproto

Error launching application on Vishnu’s iPhone.
Exited
```

Thanks again! Sorry for the late reply. I can reproduce the issue. Can you try 2.10.0 or a nightly version between 2.10.0 and 2.11.0? Hi I just verified that 0.0.1-nightly.20220915 is working fine. Can you switch to this version? Hey @yishuangP thanks, it is working on this version. I'll close the issue. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/59721">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/59721">No</a>
 FYI, I just submitted the fixes for the TensorFlowLiteSelectTfOps_framework. They should be in tonight's release. FYI, Just verified TensorFlowLiteSelectTfOps 0.0.1-nightly.20230414 is working. TensorFlowLiteSelectTfOps 0.0.1-nightly.20230414 and TensorFlowLiteSwift 2.11.0 combination is building successfully however crashes when creating an interpreter.  Hi you need to use the same nightly version for all frameworks. So if you are using  TensorFlowLiteSelectTfOps 0.0.1-nightly.20230414, you need to use TensorFlowLiteSwift 0.0.1-nightly.20230414 Hi thanks a lot for the response. I'll do that.

On Fri, Jun 23, 2023 at 9:17 AM yishuangP ***@***.***> wrote:

> Hi you need to use the same nightly version for all frameworks. So if you
> are using TensorFlowLiteSelectTfOps 0.0.1-nightly.20230414, you need to use
> TensorFlowLiteSwift 0.0.1-nightly.20230414
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/tensorflow/tensorflow/issues/59721#issuecomment-1604507942>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/A6W57LDUUN23BEDEOIOCSO3XMW6S7ANCNFSM6AAAAAAU7DXRWI>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>

<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Build/Install

### Have you reproduced the bug with TF nightly?

Yes

### Source

source

### Tensorflow Version

2.11.0

### Custom Code

No

### OS Platform and Distribution

Macbook Air M1, Ventura 13.1

### Mobile device

_No response_

### Python version

3.10.10

### Bazel version

5.3.0

### GCC/Compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current Behaviour?

Executing the following command:
```shell
bazel build -c opt --config=ios --ios_multi_cpus=arm64,x86_64 \
  //tensorflow/lite/ios:TensorFlowLiteSelectTfOps_framework
```
results in the following error:
```
ERROR: /Users/vishnu/work/ente/tensorflow/tensorflow/lite/ios/BUILD:146:21: Processing and signing TensorFlowLiteSelectTfOps_framework failed: (Exit 2): process-and-sign--932494739.sh failed: error executing command bazel-out/applebin_ios-ios_arm64-opt-ST-82c2c37ad712/bin/tensorflow/lite/ios/TensorFlowLiteSelectTfOps_framework-intermediates/process-and-sign--932494739.sh should_compress
bazel-out/applebin_ios-ios_arm64-opt-ST-82c2c37ad712/bin/tensorflow/lite/ios/TensorFlowLiteSelectTfOps_framework_archive-root/TensorFlowLiteSelectTfOps.framework/TensorFlowLiteSelectTfOps  bad CRC a72ee873  (should be a131c8e2)
```


### Standalone code to reproduce the issue
Executing the following command on the current `main` (0c955358f75cc3d2f0e21e60cb9b3a2bd3faa24b) as well as `v2.11.0` reproduces the error:

```shell
bazel build -c opt --config=ios --ios_multi_cpus=arm64,x86_64 \
  //tensorflow/lite/ios:TensorFlowLiteSelectTfOps_framework
```


### Relevant log output

```shell
bazel build -c opt --config=ios --ios_multi_cpus=arm64,x86_64 \
  //tensorflow/lite/ios:TensorFlowLiteSelectTfOps_framework

INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=101
INFO: Reading rc options for 'build' from /Users/vishnu/work/ente/tensorflow/.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
INFO: Reading rc options for 'build' from /Users/vishnu/work/ente/tensorflow/.bazelrc:
  'build' options: --define framework_shared_object=true --define tsl_protobuf_header_only=true --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --spawn_strategy=standalone -c opt --announce_rc --define=grpc_no_ares=true --noincompatible_remove_legacy_whole_archive --enable_platform_specific_config --define=with_xla_support=true --config=short_logs --config=v2 --define=no_aws_support=true --define=no_hdfs_support=true --experimental_cc_shared_library --experimental_link_static_libraries_once=false
INFO: Reading rc options for 'build' from /Users/vishnu/work/ente/tensorflow/.tf_configure.bazelrc:
  'build' options: --action_env PYTHON_BIN_PATH=/opt/homebrew/opt/python@3.10/bin/python3.10 --action_env PYTHON_LIB_PATH=/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages --python_path=/opt/homebrew/opt/python@3.10/bin/python3.10
INFO: Reading rc options for 'build' from /Users/vishnu/work/ente/tensorflow/.bazelrc:
  'build' options: --deleted_packages=tensorflow/compiler/mlir/tfrt,tensorflow/compiler/mlir/tfrt/benchmarks,tensorflow/compiler/mlir/tfrt/jit/python_binding,tensorflow/compiler/mlir/tfrt/jit/transforms,tensorflow/compiler/mlir/tfrt/python_tests,tensorflow/compiler/mlir/tfrt/tests,tensorflow/compiler/mlir/tfrt/tests/ir,tensorflow/compiler/mlir/tfrt/tests/analysis,tensorflow/compiler/mlir/tfrt/tests/jit,tensorflow/compiler/mlir/tfrt/tests/lhlo_to_tfrt,tensorflow/compiler/mlir/tfrt/tests/lhlo_to_jitrt,tensorflow/compiler/mlir/tfrt/tests/tf_to_corert,tensorflow/compiler/mlir/tfrt/tests/tf_to_tfrt_data,tensorflow/compiler/mlir/tfrt/tests/saved_model,tensorflow/compiler/mlir/tfrt/transforms/lhlo_gpu_to_tfrt_gpu,tensorflow/core/runtime_fallback,tensorflow/core/runtime_fallback/conversion,tensorflow/core/runtime_fallback/kernel,tensorflow/core/runtime_fallback/opdefs,tensorflow/core/runtime_fallback/runtime,tensorflow/core/runtime_fallback/util,tensorflow/core/tfrt/common,tensorflow/core/tfrt/eager,tensorflow/core/tfrt/eager/backends/cpu,tensorflow/core/tfrt/eager/backends/gpu,tensorflow/core/tfrt/eager/core_runtime,tensorflow/core/tfrt/eager/cpp_tests/core_runtime,tensorflow/core/tfrt/gpu,tensorflow/core/tfrt/run_handler_thread_pool,tensorflow/core/tfrt/runtime,tensorflow/core/tfrt/saved_model,tensorflow/core/tfrt/graph_executor,tensorflow/core/tfrt/saved_model/tests,tensorflow/core/tfrt/tpu,tensorflow/core/tfrt/utils
INFO: Found applicable config definition build:short_logs in file /Users/vishnu/work/ente/tensorflow/.bazelrc: --output_filter=DONT_MATCH_ANYTHING
INFO: Found applicable config definition build:v2 in file /Users/vishnu/work/ente/tensorflow/.bazelrc: --define=tf_api_version=2 --action_env=TF2_BEHAVIOR=1
INFO: Found applicable config definition build:ios in file /Users/vishnu/work/ente/tensorflow/.bazelrc: --apple_platform_type=ios --apple_bitcode=embedded --copt=-fembed-bitcode --copt=-Wno-c++11-narrowing --noenable_platform_specific_config --copt=-w --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 --define=with_xla_support=false
INFO: Analyzed target //tensorflow/lite/ios:TensorFlowLiteSelectTfOps_framework (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /Users/vishnu/work/ente/tensorflow/tensorflow/lite/ios/BUILD:146:21: Processing and signing TensorFlowLiteSelectTfOps_framework failed: (Exit 2): process-and-sign--932494739.sh failed: error executing command bazel-out/applebin_ios-ios_arm64-opt-ST-82c2c37ad712/bin/tensorflow/lite/ios/TensorFlowLiteSelectTfOps_framework-intermediates/process-and-sign--932494739.sh should_compress
bazel-out/applebin_ios-ios_arm64-opt-ST-82c2c37ad712/bin/tensorflow/lite/ios/TensorFlowLiteSelectTfOps_framework_archive-root/TensorFlowLiteSelectTfOps.framework/TensorFlowLiteSelectTfOps  bad CRC a72ee873  (should be a131c8e2)
Target //tensorflow/lite/ios:TensorFlowLiteSelectTfOps_framework failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 38.891s, Critical Path: 38.60s
INFO: 4 processes: 3 internal, 1 local.
FAILED: Build did NOT complete successfully
```
</details>