Xcode 8 beta 4:构建失败,“以下二进制文件使用不兼容的Swift版本:”错误

时间:2016-08-05 15:47:05

标签: ios iphone xcode swift3 xcode8

使用新的Xcode 8 beta 4,我们在CopySwiftLibs构建阶段开始遇到以下错误:

Effective srcDirs: {(

    <DVTFilePath:0x7f865961e970:'/Volumes/Data/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator'>,

    <DVTFilePath:0x7f8657d02b20:'/Volumes/Data/Xcode-beta.app/Contents/Developer/Toolchains/Swift_2.3.xctoolchain/usr/lib/swift/iphonesimulator'>

)}

错误:以下二进制文件使用不兼容的Swift版本:

  

/Users/user/Projects/git/iphone-swift-1/DerivedData/myApp/Build/Products/Debug-iphonesimulator/myApp.app/myApp

     

/Users/user/Projects/git/iphone-swift-1/myApp/myAppApi.framework/myAppApi

myAppApi是工作空间中包含一些共享代码的子项目(它使用Alamofire)。

有一点需要注意:最初我们将项目从Swift 2.2转换为Swift 2.3,然后手动升级到3.0。

有没有人知道可能导致此错误的原因是什么?

谢谢!

11 个答案:

答案 0 :(得分:67)

我遇到了同样的问题,但设法修复

  1. 清理项目。
  2. 关闭项目并退出Xcode。
  3. 清理衍生数据。
  4. 再次打开项目,它就在那里,一切都很好,也很有效。
  5. 我是使用Swift 3在Xcode 8上完成的。

答案 1 :(得分:17)

您也可以解决此问题,如果您的容器应用程序的代码是Swift 2.3,并且您在Xcode 8中创建了新的扩展程序。

解决上述问题......

注意:所有代码必须处于相同的swift(兼容)版本才能编译而不会失败。

话虽这么说,解决这个问题的一种方法是坚持使用Swift 2.3 ,然后设置你的扩展目标使用Legacy Swift语言版来&#34;是&#34;

您可以在Xcode 8打开时找到该选项,如下所示:

  1. 在Project Navigator(左侧)
  2. 中选择您的应用项目根目录
  3. 在右侧,在目标下选择您的分机 节
  4. 选择扩展程序后,点击构建设置标签
  5. 向下滚动并找到使用旧版Swift语言版并进行设置 从其下拉菜单中
  6. 您现在可以构建项目
  7. 注意:您可能需要修改扩展模板中的已覆盖代码,因为它们最初位于Swift 3中。

答案 2 :(得分:7)

在做任何事之前......

(如果您可以使用与您的项目兼容的Xcode 8.0)

默认情况下,您的项目设置为Xcode 3.2兼容

  • 导航器中选择您的应用项目(位于左侧)
  • 实用工具面板中选择项目文档(在 右侧)
  • 项目格式更改为 Xcode 8.0兼容

尝试构建您的项目。

如果不起作用,请尝试提出的其他解决方案。

注意:您甚至可以在修复错误后切换回兼容Xcode 3.2并且它应该可以正常工作,但您可能“稍后”可能会遇到其他构建问题。

建议: 在调试现有项目之前。如果在创建项目时没有创建Git存储库,请关闭项目并压缩项目文件的副本。

答案 3 :(得分:5)

将Xcode更新为9.3后,我遇到了同样的问题。我只是通过清理构建文件夹来解决问题。您可以使用Command-Option-Shift-K或选项菜单&#34; Product&#34; - &GT; &#34;清洁&#34; (见截图)

You can clean the build folder with Command-Option-Shift-K or in the option menu "Product" -> "Clean"

答案 4 :(得分:4)

我通过删除项目中的嵌入式二进制文件来修复此问题。要做到这一点:

  1. 在Xcode中打开您的工作区/项目。
  2. 导航到实际的项目文件(使用常规,功能等功能区)。
  3. 转到常规&gt;嵌入式二进制文件,通过选择您不想要的内容然后单击减号来删除。
  4. 注1:你不应该从&#34;链接的框架和图书馆&#34;删除它们。部分(当您从&#34;嵌入式二进制文件&#34;中删除它们时,它们应自动删除。)

    注意2:我有很多依赖项,并且正在使用CocoaPods。我在嵌入式二进制文件中没有任何内容。并且只有&#34; Pods_ [YourApplicationName] .framework&#34;在&#34;链接的框架和图书馆&#34;部分。

答案 5 :(得分:2)

我通过carthage集成了各种库。但是在此过程中,我将其中一些切换为cocoapods,忘记从项目目标中删除旧的.frameworks文件。

删除它们解决了构建错误。

答案 6 :(得分:1)

我遇到了同样的问题。 我的解决方案是将'myApp'目录重命名为'myAppmyApp'然后再次运行应用程序。一个新的'myApp'目录被制作成了一个应用程序在我的iPhone上再次运行得很好。

与您的情况不同的可能是:我的应用程序的名称,假设'DerivedData'目录中的'myApp'是myApp与以下内容连接:' - '

也许这会对你有帮助。

答案 7 :(得分:0)

您需要将所有依赖项切换为swift 3。 在您的情况下,Alamofire需要切换到Swift 3分支

答案 8 :(得分:0)

添加Swift 3版本的框架后,我收到了同样的错误消息。

我的目标C:\Users\Artoon>pip install mysql Collecting mysql Collecting MySQL-python (from mysql) Using cached MySQL-python-1.2.5.zip Building wheels for collected packages: MySQL-python Running setup.py bdist_wheel for MySQL-python ... error Complete output from command c:\paython36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Artoon\\AppData\\Local\\Temp\\pip-build-la79b8wq\\MySQL-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\Artoon\AppData\Local\Temp\tmpg_5j7u4fpip-wheel- --python-tag cp36: running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-3.6 copying _mysql_exceptions.py -> build\lib.win-amd64-3.6 creating build\lib.win-amd64-3.6\MySQLdb copying MySQLdb\__init__.py -> build\lib.win-amd64-3.6\MySQLdb copying MySQLdb\converters.py -> build\lib.win-amd64-3.6\MySQLdb copying MySQLdb\connections.py -> build\lib.win-amd64-3.6\MySQLdb copying MySQLdb\cursors.py -> build\lib.win-amd64-3.6\MySQLdb copying MySQLdb\release.py -> build\lib.win-amd64-3.6\MySQLdb copying MySQLdb\times.py -> build\lib.win-amd64-3.6\MySQLdb creating build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.6\MySQLdb\constants running build_ext building '_mysql' extension creating build\temp.win-amd64-3.6 creating build\temp.win-amd64-3.6\Release C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -Ic:\paython36\include -Ic:\paython36\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tc_mysql.c /Fobuild\temp.win-amd64-3.6\Release\_mysql.obj /Zl _mysql.c C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include\config-win.h(192): warning C4005: 'isnan': macro redefinition C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(264): note: see previous definition of 'isnan' C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include\config-win.h(203): warning C4005: 'SIZEOF_OFF_T': macro redefinition c:\paython36\include\pyconfig.h(332): note: see previous definition of 'SIZEOF_OFF_T' C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include\config-win.h(301): warning C4005: 'HAVE_STDDEF_H': macro redefinition c:\paython36\include\pyconfig.h(675): note: see previous definition of 'HAVE_STDDEF_H' _mysql.c(287): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data _mysql.c(297): warning C4090: '=': different 'const' qualifiers _mysql.c(317): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data _mysql.c(327): warning C4090: '=': different 'const' qualifiers _mysql.c(470): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data _mysql.c(623): warning C4090: '=': different 'const' qualifiers _mysql.c(624): warning C4090: '=': different 'const' qualifiers _mysql.c(625): warning C4090: '=': different 'const' qualifiers _mysql.c(626): warning C4090: '=': different 'const' qualifiers _mysql.c(627): warning C4090: '=': different 'const' qualifiers _mysql.c(1118): warning C4090: '=': different 'const' qualifiers _mysql.c(1161): warning C4090: '=': different 'const' qualifiers _mysql.c(1162): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data _mysql.c(1165): warning C4090: '=': different 'const' qualifiers _mysql.c(1274): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data _mysql.c(1466): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data _mysql.c(1468): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data _mysql.c(1504): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data _mysql.c(1506): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data _mysql.c(1532): warning C4018: '<': signed/unsigned mismatch _mysql.c(2238): warning C4311: 'type cast': pointer truncation from '_mysql_ConnectionObject *' to 'long' _mysql.c(2241): warning C4311: 'type cast': pointer truncation from '_mysql_ConnectionObject *' to 'long' _mysql.c(2302): warning C4244: 'function': conversion from '__int64' to 'long', possible loss of data _mysql.c(2321): warning C4311: 'type cast': pointer truncation from '_mysql_ResultObject *' to 'long' C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\lib\opt" /LIBPATH:c:\paython36\libs /LIBPATH:c:\paython36\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" kernel32.lib advapi32.lib wsock32.lib mysqlclient.lib /EXPORT:PyInit__mysql build\temp.win-amd64-3.6\Release\_mysql.obj /OUT:build\lib.win-amd64-3.6\_mysql.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\_mysql.cp36-win_amd64.lib _mysql.obj : warning LNK4197: export 'PyInit__mysql' specified multiple times; using first specification Creating library build\temp.win-amd64-3.6\Release\_mysql.cp36-win_amd64.lib and object build\temp.win-amd64-3.6\Release\_mysql.cp36-win_amd64.exp mysqlclient.lib(typelib.obj) : error LNK2001: unresolved external symbol __iob_func mysqlclient.lib(viosslfactories.obj) : error LNK2001: unresolved external symbol __iob_func mysqlclient.lib(my_winfile.obj) : error LNK2001: unresolved external symbol __iob_func mysqlclient.lib(my_messnc.obj) : error LNK2001: unresolved external symbol __iob_func mysqlclient.lib(client.obj) : error LNK2001: unresolved external symbol __iob_func mysqlclient.lib(my_thr_init.obj) : error LNK2001: unresolved external symbol __iob_func mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external symbol __iob_func mysqlclient.lib(default.obj) : error LNK2001: unresolved external symbol __iob_func build\lib.win-amd64-3.6\_mysql.cp36-win_amd64.pyd : fatal error LNK1120: 1 unresolved externals error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1120 ---------------------------------------- Failed building wheel for MySQL-python Running setup.py clean for MySQL-python Failed to build MySQL-python Installing collected packages: MySQL-python, mysql Running setup.py install for MySQL-python ... error Complete output from command c:\paython36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Artoon\\AppData\\Local\\Temp\\pip-build-la79b8wq\\MySQL-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Artoon\AppData\Local\Temp\pip-a7xacs6e-record\install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating build\lib.win-amd64-3.6 copying _mysql_exceptions.py -> build\lib.win-amd64-3.6 creating build\lib.win-amd64-3.6\MySQLdb copying MySQLdb\__init__.py -> build\lib.win-amd64-3.6\MySQLdb copying MySQLdb\converters.py -> build\lib.win-amd64-3.6\MySQLdb copying MySQLdb\connections.py -> build\lib.win-amd64-3.6\MySQLdb copying MySQLdb\cursors.py -> build\lib.win-amd64-3.6\MySQLdb copying MySQLdb\release.py -> build\lib.win-amd64-3.6\MySQLdb copying MySQLdb\times.py -> build\lib.win-amd64-3.6\MySQLdb creating build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.6\MySQLdb\constants running build_ext building '_mysql' extension creating build\temp.win-amd64-3.6 creating build\temp.win-amd64-3.6\Release C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -Ic:\paython36\include -Ic:\paython36\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tc_mysql.c /Fobuild\temp.win-amd64-3.6\Release\_mysql.obj /Zl _mysql.c C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include\config-win.h(192): warning C4005: 'isnan': macro redefinition C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(264): note: see previous definition of 'isnan' C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include\config-win.h(203): warning C4005: 'SIZEOF_OFF_T': macro redefinition c:\paython36\include\pyconfig.h(332): note: see previous definition of 'SIZEOF_OFF_T' C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include\config-win.h(301): warning C4005: 'HAVE_STDDEF_H': macro redefinition c:\paython36\include\pyconfig.h(675): note: see previous definition of 'HAVE_STDDEF_H' _mysql.c(287): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data _mysql.c(297): warning C4090: '=': different 'const' qualifiers _mysql.c(317): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data _mysql.c(327): warning C4090: '=': different 'const' qualifiers _mysql.c(470): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data _mysql.c(623): warning C4090: '=': different 'const' qualifiers _mysql.c(624): warning C4090: '=': different 'const' qualifiers _mysql.c(625): warning C4090: '=': different 'const' qualifiers _mysql.c(626): warning C4090: '=': different 'const' qualifiers _mysql.c(627): warning C4090: '=': different 'const' qualifiers _mysql.c(1118): warning C4090: '=': different 'const' qualifiers _mysql.c(1161): warning C4090: '=': different 'const' qualifiers _mysql.c(1162): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data _mysql.c(1165): warning C4090: '=': different 'const' qualifiers _mysql.c(1274): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data _mysql.c(1466): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data _mysql.c(1468): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data _mysql.c(1504): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data _mysql.c(1506): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data _mysql.c(1532): warning C4018: '<': signed/unsigned mismatch _mysql.c(2238): warning C4311: 'type cast': pointer truncation from '_mysql_ConnectionObject *' to 'long' _mysql.c(2241): warning C4311: 'type cast': pointer truncation from '_mysql_ConnectionObject *' to 'long' _mysql.c(2302): warning C4244: 'function': conversion from '__int64' to 'long', possible loss of data _mysql.c(2321): warning C4311: 'type cast': pointer truncation from '_mysql_ResultObject *' to 'long' C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\lib\opt" /LIBPATH:c:\paython36\libs /LIBPATH:c:\paython36\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" kernel32.lib advapi32.lib wsock32.lib mysqlclient.lib /EXPORT:PyInit__mysql build\temp.win-amd64-3.6\Release\_mysql.obj /OUT:build\lib.win-amd64-3.6\_mysql.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\_mysql.cp36-win_amd64.lib _mysql.obj : warning LNK4197: export 'PyInit__mysql' specified multiple times; using first specification Creating library build\temp.win-amd64-3.6\Release\_mysql.cp36-win_amd64.lib and object build\temp.win-amd64-3.6\Release\_mysql.cp36-win_amd64.exp mysqlclient.lib(typelib.obj) : error LNK2001: unresolved external symbol __iob_func mysqlclient.lib(viosslfactories.obj) : error LNK2001: unresolved external symbol __iob_func mysqlclient.lib(my_winfile.obj) : error LNK2001: unresolved external symbol __iob_func mysqlclient.lib(my_messnc.obj) : error LNK2001: unresolved external symbol __iob_func mysqlclient.lib(client.obj) : error LNK2001: unresolved external symbol __iob_func mysqlclient.lib(my_thr_init.obj) : error LNK2001: unresolved external symbol __iob_func mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external symbol __iob_func mysqlclient.lib(default.obj) : error LNK2001: unresolved external symbol __iob_func build\lib.win-amd64-3.6\_mysql.cp36-win_amd64.pyd : fatal error LNK1120: 1 unresolved externals error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1120 ---------------------------------------- Command "c:\paython36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Artoon\\AppData\\Local\\Temp\\pip-build-la79b8wq\\MySQL-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Artoon\AppData\Local\Temp\pip-a7xacs6e-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Artoon\AppData\Local\Temp\pip-build-la79b8wq\MySQL-python\ 仍配置为同时找到同一框架的swift 2和swift 3版本,因此我的项目卡在swift 2.3版本上。

对我来说,解决方案是从项目目录中删除旧框架,并从framework search path中删除其文件夹引用。

答案 9 :(得分:0)

所以我只是发布一小时调试后发现的解决方案。

自Xcode 9 以来,编译器日志可以跟踪它。

如果向下滚动到编译器日志的底部,您会发现此问题是由类型检查崩溃引起的。

enter image description here

答案 10 :(得分:-1)

升级到Xcode 10.2之后,就弹出了这个窗口……我的一个pod使用Swift。 解决方法是:

Cell