I am having trouble accessing classes from the main app in my widget extension.
I have tried selecting widget in target membership of the class I want to access, but for some reason I get a lot of Undefined errors from widget. I want to share API classes and Models. The error occurs exactly when I share API classes, and not when I share models only. I have no idea what's wrong:(
The errors is telling you that some part of the class you are using are including libraries that are written in C++. To fix it:
Select the widget target in the project area.
Select the "Build Settings" tab.
Type "linker" in the search box.
Find the "Other Linker Flags".
Double click on the right side of the "Other Linker Flags" row.
Press "+" and type "-lc++"
See screen shot below:
Related
I am working on an Xcode project that uses a Calendar framework, here: https://github.com/mmick66/CalendarView.
In the readme is says in order to use the Event system, you need to set custom swift compiler flags in the build settings. For some reason it isn't shown as an option for me.
Here is a screenshot of what I see in my projects build settings.
On the repository is a sample project. When I open that in Xcode, "Swift Compiler - Custom Flags" is one of the sections unlike my project.
Why would this be happening?
Here is a screenshot from the open source example project:
As per Richard Robinson's comment. I was able to find the required settings by restarting Xcode, and in the Build Settings tab, click all (combined is default) then searching for "custom flags". From there I was able to add the required flags for the calendar framework.
Edit 1: I jus thought I should add this clause to this answer. This doesn't technically answer the "why" is this happening, rather just how to fix it.
I am trying to use a custom framework in a playground as described in this Apple documentation:
http://help.apple.com/xcode/mac/9.0/#/devc9b33111c
However, I am unable to get the playground to recognize the framework (https://github.com/gk-brown/MarkupKit). It is a 64-bit Objective-C framework that defines a module.
Here is what I have tried:
Create a new "single view" playground
As directed in the document, open the playground and choose File > Save As Workspace
Close the playground
Open the workspace containing the playground
Attempt to choose File > Add Files to [Workspace Name]
The menu item is actually named "Add Files..." and is disabled. I'm able to work around this by opening the Navigator panel and selecting Project Navigator. The menu item changes to "Add Files to TestPlayground" and becomes enabled.
Moving on, as directed in the document:
Navigate to the directory containing the framework, select the framework, and click "Add"
In the editor, open the desired playground source file
Add an import statement for the framework (e.g. "import MarkupKit")
The console displays the following error:
error: TestPlayground.playground:5:8: error: no such module 'MarkupKit'
The document additionally notes that the workspace must contain at least one active scheme that builds a target. However, adding a project to the workspace and building it does not resolve the problem. The playground is still unable to see the framework.
Based on what I've read elsewhere on SO, it seems like this should be possible. However, most of the information I have found is 2-3 years old and may be out of date. The framework is a universal binary, and I have tried trimming it using lipo as suggested in some other posts. Specifically, I did this:
https://github.com/gk-brown/MarkupKit/wiki/Deployment
Unfortunately, it didn't help.
Any suggestions would be very much appreciated.
You steps looks okay but
Only missing part I see here is adding a .swift Empty file in the project.
This actually compiles below project so after this framework will be ready to import into the playground.
I am trying to create my own iOS framework for my project. I am following the below link to create it:-
Creating custom framework in iOS
I am not getting any error as well as warning but not able to see the content of Product folder generated during project creation.
I am facing problem in this step:-
To build, select the target as iOS Device and press cmd+B to perform the build. Once completed, the libRWUIControls.a product in the Products group of the Project Navigator will turn from red to black, signaling that it now exists. Right click on libRWUIControls.a and select Show in Finder.
Looking for all yours help and support on this.
Suppose you are using Xcode 6, and Apple has provided an easier way to create a custom framework.
You can refer to some instruction on How to create an iOS Cocoa Touch Framework using Xcode
And you may still encounter some problems while using your custom framework in your app.
Here are 3 tips to solve the problems you may face.
Add your public headers:
In your custom framework project, please select TARGETS->Build Phases->Headers->Public, and drag and drop your headers here.
Build a static library framework:
In your custom framework project, please select TARGETS->Build Settings->Linking->Mach-O Type, and select it as Static Library.
To fix Xcode “Missing Submodule” warning while import your custom framework in your app:
Please refer the solution here.
Enjoy your own framework.
There are several parts to this "step"
Assuming since frameworks are fairly advanced that building is not your issue.
This tutorial uses multiple targets. To choose which target you want to build you must select it from the drop down menu at the top left of your Xcode window. This is immediately to the left (and loosely tied to) the drop down for choosing the device/emulator type. The target selected in the drop down becomes the active target and will respond to the build menu and shortcut keys.
Once a target is built the object created by the build will be displayed in the XCode Project Navigator inside the folder named "Products" In the default view the left most panel in XCode is the Navigator panel. Selecting the folder icon at the top of this panel will display the Project Navigator and the projects file structure. This is where you will find the Products folder containing your newly created file.
If the file is still red then the build did not complete correctly.
If it is black then you can right click on the file and choose "Show in Finder" to see the file.
If the file remains red or as an alternative to finding the file location you can use the build log.
To show the build log - in the Navigation Panel select the "Report Navigator". This is the right most icon at the top of the panel and looks like a cartoon text bubble. In the Report Navigator highlight the "Build" Entry associated with your static library. You can now review the build log to determine why the target didn't build correctly or if it did build correctly you will see an entry near the end of the log showing the path of build files.
I followed the instructions in this article to create a static library:
http://developer.apple.com/library/ios/#technotes/iOSStaticLibraries/Articles/creating.html
I built it for iPhone simulator target. It built successfully, then I imported into a new project where I wanted to use it. It imported fine and there are no problems, but the library doesn't work. There are no library methods that I'm calling; rather the purpose of the library is to swizzle the UIViewController viewDidAppear method so that a piece of code gets executed every time a UIViewController appears. This piece of code is not getting called, despite my library being included in the "Link Binary With Libraries" build phase.
I know the problem isn't with the code itself because if I import the raw .m and .h source files not as a library, everything works fine.
Did your library contain any categories?
If so, I think you should follow these steps to get it work:
In Xcode, double-click the target's name under "Targets" in the Project window.
Choose the Build Settings panel.
Scroll down to the "Other Linker Flags" build setting under the Linking collection and set its value to "-all_load -ObjC".
Please refer to corresponding Apple Documentation
Here is a related question: Objective-C categories in static library
Here's a screen capture of my app. I'm using UIKit to create a PDF from some of the app data. I get no errors on the app itself but in the test section I get a bunch of them that look like the app can't find some CoreGraphics references. But CG is being imported in Tests.h... I can run the app, on simulator and device with no problems. Any idea what is causing this?
To add a little more to this: I imported the class where I am making the PDF into another application and I am not getting the errors there, so that's good. So any ideas what could be happening? (And yes, the libraries are in my app)
It is being imported but not linked. You need to link the CoreGraphics framework:
Importing a class header A into class B allows class B to know what public API (variables, properties and methods) in class A can be used by other classes and that is why you do not get any errors until you compile.
When you compile, you need the actual code (.m file if you will) to be able to execute the calls that class B is doing to class A variables, properties and methods. That code resides in the libraries/ frameworks you link to your project. Your code with the linked libraries together become the final compiled code.
Here is what you need to do:
Single click on your project (top left of the navigator)
Select your Target project
Click on the "Build Phases" tab
Click on "Link Binary with Libraries"
Add CoreGraphics.framework
That should solve it.
I solved it. I removed the libraries, reinstalled them and did a clean and that seemed to fix the issue.