Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcode 6, ios 8, object-C++

Tags:

xcode

ios

I create a new app project(not library or framework), and then I set "compile source as" as object-C++.But when I compile the source, it shows “build failed”.

The error is :

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_UIResponder", referenced from:
      _OBJC_CLASS_$_AppDelegate in AppDelegate.o
  "_OBJC_METACLASS_$_UIResponder", referenced from:
      _OBJC_METACLASS_$_AppDelegate in AppDelegate.o
  "_UIApplicationMain", referenced from:
      _main in main.o
  "_OBJC_METACLASS_$_UIViewController", referenced from:
      _OBJC_METACLASS_$_ViewController in ViewController.o
  "_OBJC_CLASS_$_UIViewController", referenced from:
      _OBJC_CLASS_$_ViewController in ViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

but what makes me confused is that : if it is a framework project,it compiles well. Could you lend me a hand !

like image 289
DreamRunner Avatar asked Dec 12 '14 07:12

DreamRunner


People also ask

Is Objective-C still used for iOS?

Most of the core iOS and MacOs software is still written in Objective-C, though Apple is pushing for new updates to be written in Swift.

Does XCode use Objective-C?

Objective-C is an object-oriented programming language used by Apple since the 90. It combines the advantages of two earlier languages - C and Smalltalk. In 1996 Apple overtook NeXT, which developer tools would use Objective-C. These tools were later included in Xcode.

What is XCode Objective-C?

Overview of Objective-C Objective-C is the programming language that is used to write applications for Apple's iOS and OS X operating systems. The Objective-C programming language is based on C, but it adds support for object-oriented programming. All Objective-C programming is done with the Foundation framework.

Does XCode use Swift or Objective-C?

You can use XCode IDE to develop iOS and OS X apps in both Objective-C and Swift. XCode provides everything you need to build a performant app from SDKs, APIs, frameworks, and compilers, to pre-build development libraries, etc.


1 Answers

Your app's missing symbols from UIKit. You need to link your app to UIKit:

  • Select the project in the project navigator (cmd+1, top left in left panel)
  • Select the target (i.e. your app) under TARGETS
  • Click "Build Phases" tab
  • Click the "Link Binary with Libraries" disclosure triangle, unless the table is already visible
  • Click the '+' at the bottom of the table
  • Double click UIKit.framework to add it to your link stage

Once that is completed, there may be new link issues which are discovered.

like image 102
justin Avatar answered Sep 23 '22 10:09

justin