Debugging (owned) Framework when using Carthage - ios

I am in the process of developing my own Swift framework to be used privately between two of my applications. I am using Carthage to manage that and other dependencies.
I finally got through developing the framework and hooking it up to one of my apps and, not surprisingly, the app crashes in the new framework code.
I would like to debug the framework code. I've looked at some articles that talk about:
Copying the dsym files and
Compiling with debugging information.
Unfortunately, the articles leave out a lot of details (and I'm not a seasoned enough iOS developer or Carthage user to implicitly know them).
Can someone provide a recipe on how to configure the app such that the private framework code is not optimized and I can step into the framework code from the hosting application?
Thanks
Peter...

Here are two options.
1. Debug framework within main project
Follow step 4 of the Carthage guide and then you should be able to step through and debug your private framework.
With the debug information copied into the built products directory, Xcode will be able to symbolicate the stack trace whenever you stop at a breakpoint. This will also enable you to step through third-party code in the debugger.
2. Modify framework within main project
Clone the private framework source locally.
Drag the framework's .xcodeproj into your main project. (Do not have both projects open in Xcode).
remove crthage entry form carthageInput.xcfilelist & carthageOutput.xcfilelist
remove the framework from project -> target -> general -> frameworks libraries and embedded content then add it using the + sign from the dragged project. then you will see beside the framework name Embed & sign
Now you can develop on your private framework and test them all within your main project. Once done
Remove reference to framework .xcodeproj from main project.
Create a new release of your framework.
Update main project to use newer version using standard carthage update

Related

Xcode 7 is using my framework after I deleted it

I'm in the process of developing a framework. My problem is that the changes I make to my framework are not being reflected in my app. My app seems to be linked to the original framework I created and isn't updating when I update the framework. Even when I delete the framework from my project, xcode still seems to think it's there.
Setup
I created a separate xcode project intending to make an app that uses the framework. I copied the root folder of my framework project into my app project root folder and I drag and dropped the .xcodeproj into my App's xcode project. I added the framework from my nested xcode project in each of the following steps:
Build Phases>Link Binary With Libraries
Build phases>Target Dependencies
General>Embedded Binaries
I tried removing the framework from each of these locations.
I tried cleaning the framework project and App project.
I tried deleting the derived data in my app project and framework project in Window>Projects
I tried using a previous version of my app project that doesn't contain the framework in any way (not in the xcode project or root folder)
The ghost of my framework continues to haunt my project! Any help?
I suppose you must have tried deleting it from build phases as well... just in case though:
Go to Build phases -> Link Binary with libraries
Select the one you want to remove, press minus button down there.
Do it for all modules: as in Debug, Release.
You can also try deleting the older framework and emptying trash to be on the safer side.
I just made a mistake.
I was using the classes I built my framework out of rather than the framework itself. I thought deleting these classes and selecting 'Remove Reference' would stop Xcode from using them. I deleted these classes completely and Xcode told me they couldn't find the class I was looking for-- indicating it was using those files rather than the framework.
Also, in my AppDelegate I used
import "ExternalClass.h"
Which I believe is for classes that are in the project. I changed this to
import <ExternalClass/ExternalClass.h>
to import the header file from the framework instead.

Adding a custom Framework to an Xcode project

I decided to try to make a Cocoa Touch Framework. Making it worked fine, but I am having trouble adding it to a project. After searching through a lot of SO posts and looking at Apple Forum threads I decided to try this from the Docs:
Add a framework bundle to a project in order to incorporate the
framework’s features into your product.
In the project navigator, select the project or group within a project
to which you want to add the framework.
Choose File > Add Files to “”.
Select the framework bundle, and click Add.
The frameworks you add this way are third-party-built bundles
containing the framework’s object code and runtime resources. See
related articles for information about linking to a framework without
adding it to the project.
After you add the framework, Xcode configures the targets in your
project to link them to the framework just added.
It still doesn't work. I am getting a No such module 'Scaffold' error for everything I try, I have checked spelling, but that is not it. Can someone explain how this works? I might just need clarification on how this is done.
Links I have looked at:
Create and import swift framework
Xcode error when I add a framework
Adding a framework to XCode 4
Xcode 5.1 compiler errors after adding a framework
Add a framework to an existing project without using cocoapods
What is the process for creating a Framework?
Hey I do not know if it is too late to answer this question, but due to the fact that I am facing same issues right know I would recommend you to check the Build Settings of the project where you import your framework
You should check the "Framework Search Path" and if the framework is at Swift and you import to an obj c project check YES to "Always embed swift standard libraries"
More or less the problem I think is in the Build Settings

Building a Swift Framework with Xcode 7 (Beta 3) to use as an Embedded Binary

Ever since Embedded Binaries were introduced in iOS 8, I have been wanting to port a lot of my common code into frameworks. I decided to wait one year before doing it and this year, with Xcode 7 Beta and iOS 9, I'm starting to do that just that.
I have started a Cocoa Touch framework project in Xcode 7 and I want to compile it into a usable framework. I can get it to compile my project into a .framework, but there's a few issues; namely, the framework doesn't appear to be importable into new projects (I will describe the steps I did for that shortly). Because of that, I'm not sure if my framework has any visible symbols.
This is what I have done to create the Framework:
Created my Framework as a Cocoa Touch Framework.
Went to my target's Build Phases, went to Headers, and added all my Swift files to the "Public" section, in hopes that will export all my simbols without having to mark them as public.
I tried to archive my project as a framework. Currently, it looks like Xcode 7 Beta 3 has a bug (going to report it later today) in which it generates corrupted archive files. For this reason I couldn't get my framework from the Organizer Window. To work around this, I changed the schema of the Run action in Xcode from Debug to Release, built it and grabbed it's generated .framework from my project's build/iphoneos-release directory. This was a quick test so I didn't need the frameworks generated for emulators.
And this is what I did to try to add the framework to a new project:
Created a "Frameworks" group (for organizational purposes) and dragged the framework there, selecting "yes" when it asked me if I want to copy the file to my project's directory.
Went to my target's settings, removed my framework from "Linked Libraries" (it was added there automatically), added it to Embedded Binaries instead. This added the framework to Linked Libraries again, so I had to remove it from there twice. Leaving the framework in Linked Libraries causes a linker error (can't find the framework - no idea why but I think it's irrelevant to my problem and something I should report to Apple as well), but once you remove it from there it seems to compile fine when you add it to Embedded Binaries.
Tried to import my framework in a file. Xcode complains there is "no such module".
Unfortunately, despite the fact that embedded frameworks have been around for around a year, I can't find much writing on the topic.
So my question is: Am I creating the framework correctly, making it possible that my framework/anything else is failing due to an Xcode 7 Beta bug? Or is there a different procedure to create a framework that I want to use as an Embedded Binary? I should probably mention that I want to make this library open source, and I think distributing a plain .framework file to the people who want to use it would be neat.
I Had the same issue on Xcode 7.
I solved it by editing the build settings of the project (the one which includes the framework).
By setting the Framework Search Paths field to $(PROJECT_DIR) or to the path to the directory that contains the .framework file it should help Xcode finding the module.

How to create a Xcode 6 workspace that includes 2 iOS Projects and an iOS Dynamic Framework project?

I'm trying to create one Xcode workspace that includes 3 projects:
- 2 different iOS apps
- One dynamic framework project
The two iOS apps should use the framework.
Sounds very easy and reasonable thing to do, but I just can't seem to make it to work.
When I add the framework to the iOS app target as linked library, the build process works but when running I get an exception that the framework could not be found.
If I go to the Embed Binaries -> click add -> choose the framework from the framework project, nothing happens (the embed binaries section stays empty.
I tried to do first add the framework as linked library, then add it to the embed binaries. Now compilation doesn't work (can't find the framework).
What am I missing? Every single example in the documentation shows how to add a framework as a new target under the same project. But that's doesn't help. I want the framework to be a separate project that a team can work on separately.
Open Xcode, so you can see Xcode in the menu bar.
Then go File>New>Workspace.
I believe you just drag and drop other projects into the workspace.
I've never really used a workspace, although I have made one before.

Attaching a source of framework in xcode

I am trying to debug some code of framework. Right now it always brings me to assembly code. Is there a way I can attach my source to framework so I can debug in framework? Any other alternatives?
If you want to debug the code of a framework that your app uses, create a workspace and put the sources of the framework as well as your app source as 2 projects inside the workspace. make sure the framework is a dependency of the app, and compile and run the app.
The framework will first compile, then the app, and you can put breakpoints in the framework and do all standard debugging.

Resources