简体   繁体   English

iOS Ionic构建失败

[英]iOS Ionic build failed

I try to build my app in ionic to IOS however I get an error, when i try ionic build iOS. 我尝试在IOS上使用Ionic来构建我的应用程序,但是当我尝试Ionic来构建iOS时出现错误。 Here is the error code 这是错误代码

BUILD FAILED 建立失败

The following build commands failed: 以下构建命令失败:

CompileC build/varfinz.build/Debug-iphonesimulator/varfinz.build/Objects-normal/i386/CDVFile.o varfinz/Plugins/org.apache.cordova.file/CDVFile.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler (1 failure) CompileC build / varfinz.build / Debug-iphonesimulator / varfinz.build / Objects-normal / i386 / CDVFile.o varfinz / Plugins / org.apache.cordova.file / CDVFile.m正常的i386 Objective-c com.apple.compilers。 llvm.clang.1_0.compiler(1个失败)

Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/lorenzo/Desktop/varfinz5/platforms/ios/cordova/build-debug.xcconfig,-project,varfinz.xcodeproj,ARCHS=i386,-target,varfinz,-configuration,Debug,-sdk,iphonesimulator,build,VALID_ARCHS=i386,CONFIGURATION_BUILD_DIR=/Users/lorenzo/Desktop/varfinz5/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/lorenzo/Desktop/varfinz5/platforms/ios/build/sharedpch 错误:命令的错误代码65:带有args的xcodebuild:-xcconfig,/ Users / lorenzo / Desktop / varfinz5 / platforms / ios / cordova / build-debug.xcconfig,-project,varfinz.xcodeproj,ARCHS = i386,-target, varfinz,-配置,调试,-sdk,iphonesimulator,构建,VALID_ARCHS = i386,CONFIGURATION_BUILD_DIR = / Users / lorenzo / Desktop / varfinz5 / platforms / ios / build / emulator,SHARED_PRECOMPS_DIRz = / Users / lorenzo / Desktop / varfinz ios /构建/ sharedpch

Here is the code part with the error. 这是带有错误的代码部分。 The error is on the 3rd line with the snippet self = (CDVFile*)[super initWithWebView:theWebView]; 错误出现在第三行,代码段self =(CDVFile *)[super initWithWebView:theWebView]; Xcode says following: "No visible @interface for CDVPlugin declares the selector initWithWebView Xcode表示以下内容:“对于CDVPlugin,没有可见的@interface声明选择器initWithWebView

- (id)initWithWebView:(UIWebView*)theWebView
{
    self = (CDVFile*)[super initWithWebView:theWebView];
    if (self) {
        filePlugin = self;
        [NSURLProtocol registerClass:[CDVFilesystemURLProtocol class]];

        fileSystems_ = [[NSMutableArray alloc] initWithCapacity:3];

        // Get the Library directory path
        NSArray* paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
        self.appLibraryPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"files"];

        // Get the Temporary directory path
        self.appTempPath = [NSTemporaryDirectory()stringByStandardizingPath];   // remove trailing slash from NSTemporaryDirectory()

        // Get the Documents directory path
        paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        self.rootDocsPath = [paths objectAtIndex:0];
        self.appDocsPath = [self.rootDocsPath stringByAppendingPathComponent:@"files"];

    }

    return self;
}

You can Solve this in 2 ways: 您可以通过两种方式解决此问题:

1- replace [super initWithWebView:theWebView] by [super init] . 1-用[super initWithWebView:theWebView] [super init]替换[super initWithWebView:theWebView] [super init]

2- add a compiler flag to CDVFile to disable ARC, the compiler flag is -fno-objc-arc 2-将编译器标志添加到CDVFile以禁用ARC,编译器标志为-fno-objc-arc

From my point of view, I recommend the second solution because it's not affecting the code. 从我的角度来看,我建议第二种解决方案,因为它不会影响代码。

if you are looking for a step by step solution do the following in Xcode. 如果您正在寻找逐步解决方案,请在Xcode中执行以下操作。

  1. Select your main project. 选择您的主要项目。
  2. Select your target 选择你的目标
  3. Go to build phases 进入构建阶段
  4. Expand the compiled resources tap 展开已编译资源
  5. select "CDVFile.m" 选择“ CDVFile.m”
  6. at the right side of the "CDVFile.m", you can add the following compiler flag 在“ CDVFile.m”的右侧,可以添加以下编译器标志

    -fno-objc-arc -fno-objc-arc

Now if you want to understand the problem in details: 现在,如果您想详细了解问题,请执行以下操作:

The CDVFile was built under non-ARC environment and he controls his memory consumption. CDVFile是在非ARC环境下构建的,他可以控制内存消耗。 but Xcode doesn't allow that as it's using ARC to control the memory consumption of the whole app. 但是Xcode不允许这样做,因为它使用ARC来控制整个应用程序的内存消耗。 so the solution for this conflict is to revamp the CDVFile Code to use ARC or simply tell the Xcode that you are responsible for the memory management of this class by adding the compiler flag. 因此,解决此冲突的方法是修改CDVFile代码以使用ARC或通过添加编译器标志来简单告知Xcode您负责此类的内存​​管理。

update Note: both of the above solutions should be done everytime you add a platform. 更新注:每次添加平台时,都应完成上述两个解决方案。

To solve the issue permenantly do the following: 要永久解决此问题,请执行以下操作:

  1. Go to plugins folder 转到插件文件夹
  2. Find the plugin causing the issue (in this case: cordova-plugin-file) 查找引起问题的插件(在这种情况下:cordova-plugin-file)
  3. Open plugin.xml file 打开plugin.xml文件
  4. Locate <platform name="ios"> 找到<platform name="ios">
  5. Locat the following tag: <source-file src="src/ios/CDVFile.m"/> and replace it with: <source-file src="src/ios/CDVFile.m" compiler-flags="-fno-objc-arc"/> 找到以下标记: <source-file src="src/ios/CDVFile.m"/>并替换为: <source-file src="src/ios/CDVFile.m" compiler-flags="-fno-objc-arc"/>
  6. remove and add ios platform and you are done. 删除并添加ios平台,您就完成了。

I get this problem intermittently. 我间歇性地遇到这个问题。 While I can't speak to the root cause of the issue, the following works for me - from CLI: 虽然我无法说出问题的根本原因,但以下这些对我有用-从CLI:

cordova platform remove ios
ionic serve
cordova platform add ios

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

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