Using box-api in an ARC project? - ios

How can I use the box-api in a project using ARC?
I copied the SDK folder to my project and added them, but I can't build my project since it uses ARC.

You have to disable ARC for these files:
Go to Your Project > Your Target > Build Phases
Select all Box files, press Enter and insert "-fno-objc-arc" without quotas
Clean and Build! ;)

Related

Swift Xcode cant remove Embedded binaries / Linked frameworks and libraries from project

I installed Alamofire by:
dragging Alamofire.xcodeproj file into my project navigator, then in
Project > General > Embedded Binaries, I clicked on the plus sign and selected Alamofire.framework. And it got integrated with no problem.
But how do I now remove it form my project ?
Thanks
You can remove it with the by selecting Target and then selecting framework in Linked Frameworks and Libraries
if you don't succeed in this way you can then probably check the Search Path of both of your Target and Project
I was having the same problem and my frameworks were not being removed then i cleared the Search Path of my Project
In some cases, after removing everything, the App will still recognize the library and compile with no errors.
In this case, the App folder in DerivedData needs to be removed.

Cannot add embedded binaries (other projects) to project dependencies in XCode

I have an XCode workspace created with XCode 6.0.1. It constains 2 (Swift) libraries and one iOS app (Swift) that depends on those 2 libraries. I had stable setup that allowed me to run the iOS app on both iPhone and simulators: The 2 library projects were added as Embedded Binaries (see picture) of the app.
Now, I have XCode 6.1. Recently, I deleted DerivedData folder in ~/Library/Developer/Xcode folder while XCode was running. After that my workspace did not work - the iOS app would fail to compile and I got linker error saying it cannot find the library projects.
I tried to solve it by removing my the 2 libraries from Embedded Binaries of the app project - and I cannot add them back. Clicking + button under Embedded Binaries in project settings displays workspace projects correctly but selecting and adding my library project does not add them to the list of Embedded Binaries. I have solved the linker error by creating new workspace. The app compiles but how it links the libraries is a mystery to me: They are not in listed Embedded Binaries or Linked Frameworks and Libraries not in the Frameworks search path. There appears to be no link between the app and the libraries it needs (and obviously have as it compiles) except that libraries projects are in the same workspace.
Why I cannot add library projects to Embedded Binaries? Is it normal in XCode 6.1 that dependency projects just compile and gets embedded into an app without being listed or linked anywhere?
This is a summary of my answer to the question Xcode won't add “Embedded binary” after deleting “DerivedData”, see the original question and answer for more context and information:
Remove all framework projects from the workspace
Perform a "clean build" and/or remove the "DerivedData"
Add project back into the workspace
Build the project (possibly optional)
In the General tab of the app target click the + under "Linked Frameworks and Libraries", select the framework.
Build and run in the Simulator (there should be no issues building or running)
Build and run for device (this might cause a crash due to the framework not being correctly linked, ignore this crash)
Click the + under "Embedded Binaries", select the framework. This should add it to the project (possible duplicate under "Linked Frameworks and Libraries")
Repeat for all required frameworks
Once building and running (on device) is confirmed you can remove any duplicate (and/or red) frameworks in the Project Navigator or target General tab
Ok, I ran into the same problem as you. After deleting the derived data, I could not re-link my binaries again. I think the reason is because the derived data is where the binaries are written to and linked against in your project.
What I did to solve was to select my Framework as my build target. After building it, the Framework target turned from red to black. I can see in your screenshot it is red, meaning it has not been compiled into a binary and written on disk.
Once I did this, I was able to re-link the Framework to my Project because there was a reference to it on disk. Hope this helps!
Clean your projects & build your framework first. Thereafter you can embed it.
Here is how I solved the problem:
Build the framwork.
Open the build folder and drag built framework into the app project (so it uses the path to DerivedData).
Add the framework to the list of embedded frameworks.
In the Finder, do a Show Contents on the app's xcodeproj file, then open project.pbxproj in your favorite text editor.
Find the line with the long DerivedData path. Change it so there is no name, the path is the framework name, and source tree is BUILT_PRODUCTS_DIR
Xcode should notice the change and the library in the app project will be black instead of red and will now build and run properly.
I have a very similar issue and fixed it just last night. Decided to come back to this thread and offer my workaround, as rjstelling's solution above did not help my case.
I have a workspace that contains two frameworks and one application. The App was making use of both frameworks happily for a while until I got hit by a mysterious compile eror where it decided that adding a property access to an instance variable called "cube" of a class type found in one of the framework, made access to "_cube" impossible (complaining it was not declared, while it had actually worked previously in a setter method).
Long story short, after a clean, somehow the workspace/app project lost track of the embedded framework of my iOS 8+ project. Removing the embedded framework was the last straw in that line of failure, causing my project to no longer allow be to select any frameworks for embedding.
Reverting the project & workspace to an earlier version did not get rid of the voodoo.
I ended up adding the to-be-embeded framework projects in the main app project (as files) and introduced target dependencies on the frameworks.
I was then able to re-embed the frameworks and link.
As for the _cube thing, I had to specify a getter for the property and #synthesize the property to a different name. I dont have an explanation for this one.
It's probably because your framework is a separate project and not a separate target. Try watching carefully Session 416: Building a Modern Framework at around minutes 34-36. It will show you how to set it up correctly.
This makes it a bit confusing if you wanted to share a framework across multiple projects by the way

Xcode 6: No Frameworks Folder in Project Navigator

I am using Xcode 6 and following an Xcode version 4 tutorial so things are different here and there.
There doesn't seem to be a Frameworks folder in my project navigator and so when I downloaded some .framework files and added them manually in the build phase of my project editor, I had no Frameworks folder to save them in and just let them fall into the top of my project navigator. So they are there, just not in a special folder, and it doesn't look good.
So should Xcode 6 have a frameworks folder automatically, or do I need to create one myself? And if so, how can I do that? (I've only added new files so far).
In Xcode 6, the Frameworks folder is not added by default. You can drag and drop your .framework files into the project navigator (tick 'Copy items if needed'), then select them all > right click > "New Group from Selection" and name the folder 'Frameworks'.
Also, make sure the frameworks are added into the Project > Build Phases > Link Binary With Libraries. If not, drag them there from your newly created 'Frameworks' folder.
In short, no, you shouldn't need to create a Frameworks group yourself as Xcode is doing stuff automatically for you...
Apple are slowly, gently pushing developers in the direction of newer Clang features with the goal of making native iOS development more approachable for newbies who don't have previous experience of compiling and linking with C-based languages.
You'll find that Objective-C projects created with Xcode 6 have new build settings enabled by default including Link Frameworks Automatically (CLANG_MODULES_AUTOLINK) and Enable Modules (C and Objective-C) (CLANG_ENABLE_MODULES).
Suggested reading:
Modules (Clang documentation)
#import vs #import - iOS 7 (excellent Stack Overflow answer)
I found the other answers too confusing (where am I supposed to get .framework files?)
It's way simpler in Xcode 6. Just go to Capabilities and turn Maps on. That's it... really.
I would recommend using drag and drop feature to move files into Xcode. Xcode show you the Choose options for adding these files window [Copy items if needed] [Added folders]
For example Xcode can automatically add relative path ($(PROJECT_DIR)/) to:
Build Settings -> Library Search Paths if you drag and drop a library
Build Settings -> Framework Search Paths if you drag and drop a framework

Using Core Plot 2 in an Xcode 5 project

I'm using the instructions here to integrate Core Plot into my iOS Xcode 5 project and am having no end of issues.
I tried using the Static Library Install but it seems this refers to 1.4 as there is no directory called CorePlotHeaders though if I try to use 1.4 I run into runtime issues.
I've then tried to drag the CorePlot-CocoaTouch.xcodeproj as described in the Dependent Project Install but this only copies it as if its a file and not the whole project.
Is there more current instructions for using it as a static library or how am I copying the project incorrectly into my project?
Here are some current steps to follow to add the static Core Plot library to your project:
download the latest version of CorePlot here
navigate to the CorePlot framework folder and run CorePlot-CocoaTouch.xcodeproj
build (not run) the CorePlot-CocoaTouch.xcodeproj project
navigate back to your CorePlot download folder > build > Debug-iphoneos and verify libCorePlot-CocoaTouch.a has been created. If not, unzip the download and repeat steps 1-4
back in Xcode highlight the CorePlot-CocoaTouch project
click Product > Scheme > select Universal Library (selects which target to build)
build project again (not run)
go BACK to your CorePlot download folder > build > Release-universal and you will see the CorePlotHeaders folder and libCorePlot-CocoaTouch.a are both available
open the Xcode project you would like to add static CorePlot to
add the CorePlot > build > Release-universal > CorePlotHeaders folder and libCorePlot-CocoaTouch.a files to your project (selecting 'copy items into destination group's folder)
select your Project and in the 'Linking' section find 'Other Linker Flags' and add -ObjC
from your Target > Build Phases > Link Binary With Libraries add the QuartzCore framework to your project
if libCorePlot-CocoaTouch.a is not in your Link Binary With Libraries list drag it from where you copied it to your project to the Library list to add it.
You should now be able to
#import "CorePlot-CocoaTouch.h"
(autocomplete) to the viewController that you will be using to manage your CorePlot.
If you are following old documentation on how to use CorePlot be aware that the new prefix is CPT (not CP, adjust accordingly)
Happy coding!
If you want to use the static library, build it using the "Universal Library" target. This will put the static library and the CorePlotHeaders folder in the build folder inside your Core Plot directory.
To use the dependent project, drag the project file from the Finder into Xcode under your app project in the browser pane at the left side of the Xcode window. Remember to set the "Header Search Paths" in your app build settings or it won't be able to find the Core Plot headers.
Use Cocoapod to install the necessary libraries instead of this manual step if you want to solve this problem in 1 minute ... (follow this link and go to the last thread: iOS CorePlot how to install)
As well as the steps above, you need to include -all_load in linker options, otherwise it won't work on Xcode 7.1.1

Unity iOS development build always yields non ARC Xcode Project

Unity iOS Xcode build always gives a non-ARC Xcode project. I want to have unity iOS build with ARC. How can I do that?
Easiest way is to activate ARC in your project but tell XCode to deactivate it only for the Unity-generated files using the "-fno-objc-arc" option. This way you can code your own stuff with arc but dont risk any sideeffects from automatically migrating the generated code. And you can easily integrate a new export from unity without having to re-migrate it.
The -fno-objc-arc has to be set in your project settings > Build Phases > Compile Sources
regards

Resources