o链接器错误(加密应用程序)

我在Xcode中有一个基本的加密项目并且不断收到错误。 这是我的viewcontroller.m文件

////////////////////////////////////////////////// //

这是错误

前两个:

Ld /Users/ellek/Library/Developer/Xcode/DerivedData/£ncryptor-hfcpwsbibblkliafeasjiugwqzuy/Build/Products/Debug-iphonesimulator/£ncryptor.app/£ncryptor normal x86_64
    cd "/Volumes/Ellek/Xcode/£ncryptor"
    export IPHONEOS_DEPLOYMENT_TARGET=7.1
    export 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 x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -L/Users/ellek/Library/Developer/Xcode/DerivedData/£ncryptor-hfcpwsbibblkliafeasjiugwqzuy/Build/Products/Debug-iphonesimulator -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/usr/lib/system -F/Users/ellek/Library/Developer/Xcode/DerivedData/£ncryptor-hfcpwsbibblkliafeasjiugwqzuy/Build/Products/Debug-iphonesimulator -filelist /Users/ellek/Library/Developer/Xcode/DerivedData/£ncryptor-hfcpwsbibblkliafeasjiugwqzuy/Build/Intermediates/£ncryptor.build/Debug-iphonesimulator/£ncryptor.build/Objects-normal/x86_64/£ncryptor.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.1 -framework QuartzCore -framework CoreGraphics -framework UIKit -Xlinker -dependency_info -Xlinker /Users/ellek/Library/Developer/Xcode/DerivedData/£ncryptor-hfcpwsbibblkliafeasjiugwqzuy/Build/Intermediates/£ncryptor.build/Debug-iphonesimulator/£ncryptor.build/Objects-normal/x86_64/£ncryptor_dependency_info.dat -o /Users/ellek/Library/Developer/Xcode/DerivedData/£ncryptor-hfcpwsbibblkliafeasjiugwqzuy/Build/Products/Debug-iphonesimulator/£ncryptor.app/£ncryptor

Undefined symbols for architecture x86_64:
  "_password", referenced from:
      -[ZAViewController decrypt:] in ZAViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

最后的错误:

GenerateDSYMFile /Users/ellek/Library/Developer/Xcode/DerivedData/£ncryptor-hfcpwsbibblkliafeasjiugwqzuy/Build/Products/Debug-iphonesimulator/£ncryptor.app.dSYM /Users/ellek/Library/Developer/Xcode/DerivedData/£ncryptor-hfcpwsbibblkliafeasjiugwqzuy/Build/Products/Debug-iphonesimulator/£ncryptor.app/£ncryptor
    cd "/Volumes/Ellek/Xcode/£ncryptor"
    export 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/dsymutil /Users/ellek/Library/Developer/Xcode/DerivedData/£ncryptor-hfcpwsbibblkliafeasjiugwqzuy/Build/Products/Debug-iphonesimulator/£ncryptor.app/£ncryptor -o /Users/ellek/Library/Developer/Xcode/DerivedData/£ncryptor-hfcpwsbibblkliafeasjiugwqzuy/Build/Products/Debug-iphonesimulator/£ncryptor.app.dSYM

error: unable to open executable '/Users/ellek/Library/Developer/Xcode/DerivedData/£ncryptor-hfcpwsbibblkliafeasjiugwqzuy/Build/Products/Debug-iphonesimulator/£ncryptor.app/£ncryptor'

////////////////////////////////////////////////// //

这是.h文件

#import <UIKit/UIKit.h>
#import "NSData-AES.h"
#import "Base64.h"
#import <QuartzCore/QuartzCore.h>
#import <CoreGraphics/CoreGraphics.h>

@interface ZAViewController : UIViewController{

 //   NSString *decryptedStr;
   // NSString *customKey;
   // NSString *password;
    UITextField *customKey;
   // NSString *customKeyString;
}

//encrypt
@property (strong, nonatomic) IBOutlet UITextView *textFieldEncrypt;
@property (strong, nonatomic) IBOutlet UILabel *encryptedLabel;
- (IBAction)encrypt:(UIButton *)sender;
//decrypt
@property (strong, nonatomic) IBOutlet UITextView *textFieldDecrypt;
@property (strong, nonatomic) IBOutlet UILabel *decryptLabel;

@property (strong, nonatomic) IBOutlet UITextField *customKey;
//@property (strong, nonatomic) IBOutlet NSString *customKeyString;

- (IBAction)decrypt:(UIButton *)sender;
- (IBAction)options:(UIButton *)sender;

@end

////////////////////////////////////////////////// //

.M文件

.m文件的顶部

#import "ZAViewController.h"

@interface ZAViewController ()

@end
@implementation ZAViewController

extern NSString *password;

@synthesize customKey;

第一次IBAction:

- (IBAction)解密:(UIButton *)sender {

//解密字符串

[self.textFieldDecrypt resignFirstResponder]; NSString * b64EncStr = self.textFieldDecrypt.text;

NSData * b64DecData = [Base64 decode:b64EncStr];

NSData * decryptedData = [b64DecData AESDecryptWithPassphrase:password];

NSString * decryptedStr = [[NSString alloc] initWithData:decryptedData

编码:NSASCIIStringEncoding];

self.decryptLabel.text = decryptedStr;

[self.textFieldDecrypt resignFirstResponder];

}

下一个IBAction:

-(IBAction)encrypt:(UIButton *)sender {

    NSString *password = nil;

    NSString *customKeyString = self.customKey.text;

    if ([customKeyString length] == 0) {
        password = @"M1Jzqn8sDNJDp2rjqj6ECqPozCUZXsE";
    }

    if ([customKeyString length] != 0) {
        password = customKeyString;
    }

    /*
     if ([customKeyString length] == 0) {
     NSString *password = @"M1Jzqn8sDNJDp2rjqj6ECqPozCUZXsE";


     }

     if ([customKeyString length] != 0) {
     NSString *password = customKeyString;
     }*/

    [self.textFieldEncrypt resignFirstResponder];

    NSString *str = self.textFieldEncrypt.text; // It does not work with UTF8 like @"こんにちは世界"

    NSLog(@"encrypting string = %@",str);

    NSData *data = [str dataUsingEncoding: NSASCIIStringEncoding];
    NSData *encryptedData = [data AESEncryptWithPassphrase:password];

    [Base64 initialize];
    NSString *b64EncStr = [Base64 encode:encryptedData];

    NSLog(@"Base 64 encoded = %@",b64EncStr);

    self.encryptedLabel.text = b64EncStr;

    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    pasteboard.string = b64EncStr;

    NSString* messageString = [NSString stringWithFormat: @"The encrypted text (%@) has been copied to the clipboard", b64EncStr];

    UIAlertView *copyTHAT = [[[UIAlertView alloc] initWithTitle:@"Copy Successful"
                                                      message:messageString
                                                    delegate:self
                                           cancelButtonTitle:@"Ok"
                                           otherButtonTitles:nil] autorelease];

    [copyTHAT show];


}

IBAction 3:

- (IBAction)options:(UIButton *)sender{

    if ((customKey.enabled = YES)) {
        customKey.enabled = NO;
    }

    if ((customKey.enabled = NO)) {
        customKey.enabled = YES;
    }

}
链接地址: http://www.djcxy.com/p/68335.html

上一篇: o linker error (encryption app)

下一篇: iOS AES encryption and PHP decryption