1
votes

I try to build my app in ionic to IOS however I get an error, when i try ionic build 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)

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

Here is the code part with the error. The error is on the 3rd line with the snippet self = (CDVFile*)[super initWithWebView:theWebView]; Xcode says following: "No visible @interface for CDVPlugin declares the selector 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;
}
2
Can you provide some code? Try adding some break points in your code and debug to see where it is breakinguser4410715
hi, yes sure I edited the post aboveLorenzo Varano
@Lorenzo are you using keychain or Facebook plugin?Gandhi
Hi Gandhi, yes keychainLorenzo Varano

2 Answers

4
votes

You can Solve this in 2 ways:

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

2- add a compiler flag to CDVFile to disable ARC, the compiler flag is -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.

  1. Select your main project.
  2. Select your target
  3. Go to build phases
  4. Expand the compiled resources tap
  5. select "CDVFile.m"
  6. at the right side of the "CDVFile.m", you can add the following compiler flag

    -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. but Xcode doesn't allow that as it's using ARC to control the memory consumption of the whole app. 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.

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)
  3. Open plugin.xml file
  4. Locate <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"/>
  6. remove and add ios platform and you are done.
0
votes

I get this problem intermittently. While I can't speak to the root cause of the issue, the following works for me - from CLI:

cordova platform remove ios
ionic serve
cordova platform add ios