2

I have trouble compiling My app (Xcode app project) when my framework (Xcode framework project) is linked and files are added to the framework (not used in the app).

What I did:

  1. Create folder MyProject
  2. Create Xcode single view project (MyApp project) -> output of this is a folder MyApp inside MyProject folder containing all the data
  3. Create Xcode framework project (MyFramework project) -> output of this is a folder MyFramework inside MyProject folder containing all the data
  4. Create workspace and import both projects into the workspace -> output of this is file .xcworkspace in the folder MyProject

So, after this I have hierarchy:

->MyProject

--->MyApp

--->MyFramework

--->MyWorkspace.xcworkspace

Then in General tab of MyApp project I've added in Embedded Binaries my framework. This linked my framework with my app and when I compiled it my app started fine on the phone.

After that I've added one Objective-C .h/.m pair of classes to the framework, added them to the framework target (compiled sources has .m file, header file is selected as public).

When I try to compile and run the app one more time on the device, I get the error:

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_UNIRest", referenced from:
      objc-class-ref in TMSCommunicationManager.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Aleksandar
  • 1,457
  • 13
  • 30
  • Did you build your framework after adding the new classes? – shallowThought Jan 19 '17 at 09:37
  • Tried to build the framework on its own (selecting virtual device/simulator/phone) and it stil fails with the same error. Also tried removing the class, then error becomes error pointing to another class. Then I try to remove all but header generated by the framework and it compiles fine, and runs fine on the device. – Aleksandar Jan 19 '17 at 09:49
  • I suspect: You have to build for device if you want to run the app on device, as you have set `Build Active Architecture Only = YES` (in Build Settings) for your current configuration. Probably `Debug`. – shallowThought Jan 19 '17 at 09:53
  • That is correct but as I said, when trying to build framework it displays the same linking error as the one above. My class is not recognized for some reason. Tried to clean the project. Tried also to remove DerivedData folder. None of those helped. – Aleksandar Jan 19 '17 at 09:55
  • What is see is that when I right click framework linked in the App and go "show in Finder" folder "Headers" is empty. – Aleksandar Jan 19 '17 at 09:56
  • If you build your framework (only) for simulator it does not have a slice for `architecture arm64`. Thus it can not be found. If you build your framework for device and the error persists, the build path (path to the build framework) differs from the one used in embedded binaries. I.e. you are not using the newly build framework but an old build. – shallowThought Jan 19 '17 at 09:58
  • Are the new classes actually Categories? – shallowThought Jan 19 '17 at 09:59
  • I managed to fix the problem. It was related to the library I imported in the framework for http communication. Library had a dependency on Foundation framework which was not imported by default. As soon as I commented out code for that http lib, I was able to build for the device. – Aleksandar Jan 19 '17 at 10:25
  • Cool! Happy coding. – shallowThought Jan 19 '17 at 10:26
  • https://stackoverflow.com/a/57538354/4770877 – yoAlex5 Sep 02 '19 at 21:03

1 Answers1

0

Go to your Project's Target -> Build Settings, then:

Try Setting your Architectures Setting to: $(ARCHS_STANDARD)

And set "Build Active Architecture" to No

Hope this Helps :-)

Hernan Arber
  • 1,626
  • 3
  • 22
  • 35