OC 与 swift 混编杂记

今天使用在swift项目上使用了oc项目的一部分源代码发现了以下问题:

1. oc 无法继承swift类

2. oc 无法使用 纯swift类

3. 带有闭包的函数无法被oc类调用

以上问题使得 oc 使用swift源码变得困难重重

昨天打包的时候发现这个问题:

“Undefined symbols for architecture arm64:

  "__TFFC11duiDuiAlive21DataCenterMerchantsVCgP33_2F08BF04E285995BDA3E31B94BCF039714collectionViewCSo16UICollectionViewauL_4selfS0_", referenced from:

      __TTSf4g___TFFFFC11duiDuiAlive21DataCenterMerchantsVCgP33_2F08BF04E285995BDA3E31B94BCF039714collectionViewCSo16UICollectionViewU_FT_S1_L_23configureCollectionViewFS1_T_L_11setDelegatefT_T_ in DataCenterMerchantsVC.o

ld: symbol(s) not found for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

这个看起来像是编译器bug,因为我在 build phases中删掉该文件再添加后 又可以了。 但是最后还是有一个文件仍然出现错误,刚开始是四个文件,经过上述步骤只有一个。后来我仔细检查错误提示 ,把相关的函数改掉就好了。本来使用的是内嵌函数,把他展开就好了。也不知道为什么。

原文地址:https://www.cnblogs.com/TengSys/p/7126749.html