简体   繁体   English

j2objc作为XCode中的子项目

[英]j2objc as subproject in XCode

I have a problem to link the j2objc library as a subproject. 我在将j2objc库链接为子项目时遇到问题。 It always ends up with "missing libjre_emul.a" error. 它总是以“缺少libjre_emul.a”错误结尾。

Steps I have done: 我已完成的步骤:

1) Create empty iOS project 1)创建一个空的iOS项目

2) Include j2objc library by following the simple steps in the part "Including JreEmulation project into your project. 2)按照“将JreEmulation项目包括到您的项目中”部分中的简单步骤来包括j2objc库。

I checked that I am building for the iPhone simulator and the build process is running. 我检查了我是否正在为iPhone模拟器进行构建,并且构建过程正在运行。 It seems that libjre_emul.a is generated at j2objc/jre_emul/build_result/ but it should be also available in the DerivedData, which is not. 看来libjre_emul.a是在j2objc / jre_emul / build_result /上生成的,但它也应该在DerivedData中可用,但不是。 I have also tried setting a shared folder for DerivedData (File -> Project settings -> Derived Data -> Advanced), but this didn't help. 我也尝试过为DerivedData设置共享文件夹(文件->项目设置->衍生数据->高级),但这没有帮助。

The reason why I would like to include it as a subproject is to be able to set breakpoints inside j2objc source. 我之所以想将其作为子项目包括在内,是为了能够在j2objc源代码中设置断点。

Here is the error: 这是错误:

Ld /Users/user/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/SubProject4.app/SubProject4 normal i386 cd /Users/user/Documents/Project1/SubProject4 setenv IPHONEOS_DEPLOYMENT_TARGET 6.1 setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk -L/Users/user/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator -F/Users/user/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator -filelist /Users/user/Library/Developer/Xcode/DerivedData/Build/Intermediates/SubProject4.build/Debug-iphonesimulator/SubProject4.build/Objects-normal/i386/SubProject4.LinkFileList -Xlinker -ob ld /用户/用户/库/开发人员/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/SubProject4.app/SubProject4普通i386 cd / Users / user / Documents / Project1 / SubProject4 setenv IPHONEOS_DEPLOYMENT_TARGET 6.1 setenv PATH“ / Applications / Xcode .app / Contents / Developer / Platforms / iPhoneSimulator.platform / Developer / usr / bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/ usr / bin:/ bin:/ usr / sbin:/ sbin“ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6。 1.sdk -L /用户/用户/库/开发人员/ Xcode / DerivedData / Build /产品/ Debug-iphonesimulator -F /用户/用户/用户/库/开发人员/ Xcode / DerivedData / Build /产品/ Debug-iphonesimulator-文件列表用户/用户/库/开发人员/Xcode/DerivedData/Build/Intermediates/SubProject4.build/Debug-iphonesimulator/SubProject4.build/Objects-normal/i386/SubProject4.LinkFileList -Xlinker -ob jc_abi_version -Xlinker 2 -ObjC -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=6.1 /Users/user/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/libjre_emul.a -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/user/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/SubProject4.app/SubProject4 jc_abi_version -Xlinker 2 -ObjC -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min = 6.1 / Users / user / Library / Developer / Xcode / DerivedData / Build / Products / Debug-iphonesimulator /libjre_emul.a-框架UIKit-框架基础-框架CoreGraphics -o /用户/用户/用户/库/开发人员/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/SubProject4.app/SubProject4

clang: error: no such file or directory: '/Users/user/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/libjre_emul.a' 铛声:错误:没有这样的文件或目录:'/Users/user/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/libjre_emul.a'

Tom Ball responded on the j2obj google group : 汤姆·鲍尔(Tom Ball)在j2obj谷歌论坛上做出了回应:

The problem looks to be that the JreEmulation project's makefile is not copying the built library to where Xcode expects it to be. 问题似乎是JreEmulation项目的makefile没有将生成的库复制到Xcode期望的位置。 Xcode used to pass build environment variables like BUILT_PRODUCTS_DIR to external build system targets, but doesn't any more. Xcode过去曾将诸如BUILT_PRODUCTS_DIR之类的构建环境变量传递给外部构建系统目标,但不再适用。 Here's a workaround until I figure out how to fix embedding JreEmulation properly (if anyone has a solution, please reply): 在我弄清楚如何正确解决嵌入JreEmulation之前,这是一个解决方法(如果有人有解决方案,请回复):

  • Remove the red libjre_emul.a from your project's Link Binary with Libraries list. 从项目的“带库链接二进制文件”列表中删除红色的libjre_emul.a。

  • In that list, click the + button, then Add Other... 在该列表中,单击+按钮,然后单击添加其他...。

  • Go to your j2objc directory, then dist/lib and add libjre_emul.a 转到j2objc目录,然后dist / lib并添加libjre_emul.a

Now when you look at the link list, libjre_emul.a should be red after cleaning your project (since it was deleted), and black after your project builds successfully. 现在,当您查看链接列表时,清理项目后libjre_emul.a应该为红色(因为已删除),而项目成功构建后应该为黑色。

So it was a bug, but I still can't debug/step into the j2objc source code. 因此,这是一个错误,但是我仍然无法调试/进入j2objc源代码。 But at least this is working. 但这至少是有效的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM