Add Framework dynamically in Xcode - ios

How can I add framework at run time, so that I can access it globally in the project?
If I'm adding manually going to save my location, then I am getting below warning:
ld: warning: directory not found for option '-F <my drive location ...>
Also it is not accessible globally.

I also got similar issue because i am getting my framework end of build in my project : then i found solution:
add your project to framwork where you want :
Drag and Drop then go to :
Build Settings>> Search Paths >>Framework Search Path>>Change path to ./ (selecting recursive.)
or
Build Settings>> Search Paths >>Library Search Path>>Change path to ./ (selecting recursive.)
If that will not help then replace ./ to
$(PROJECT_DIR)/ => for getting project path dynamically . ../ => to go back to desire project folder
EX:
$(PROJECT_DIR)/..//Pinterest.embeddedframework

Related

Cyclic dependency error J2OBJC archive build?

I am having cyclic dependency issues with my Ionic/iOS project using J2OBJC as a internal Xcode settings built in.
I've set my build rules and settings in my ionic project as stated in the J2OBJC documentations. I have added the Library, User Header and framework search paths as required (firstly only app target, and also tried it with both app target and workspace) and created user defined $J2OBJC_HOME and (this probably isn't part of the requirements) I added a $PROJECT_DIR too. I also added the java build rule as such
"if [ ! -f "${J2OBJC_HOME}/j2objc" ]; then echo "J2OBJC_HOME not
correctly defined in Settings.xcconfig, currently set to
'${J2OBJC_HOME}'"; exit 1; fi; "${J2OBJC_HOME}/j2objc" -d
${DERIVED_FILE_DIR} -sourcepath "${PROJECT_DIR}/App"
--no-package-directories -use-arc --prefix Flowers=JOE -g ${INPUT_FILE_PATH};"
I have build both simulator and iPhone and ran them on both and they seem to be working. However, when I go to archive (so I can create the .ipa) for the project. I get a cyclic dependency error. I have tried numerous things, such as, fresh start of project, using different URLs for the search paths, using recursive and non-recursive, checked the documentations a few times, looked at forums and still have no solution. Any ideas would be greatly appreciated!
Xcode can no longer handle the same header search path in Header Search Paths and User Header Search Paths. You probably have "$(J2OBJC_HOME)/include" in both of these. So remove it from Header Search Paths and leave it in User Header Search Paths.
I've had this cyclic dependency issue for a good month and a half. I've tried almost everything.
I've looked everywhere.. and got 2 replies from Tom Ball. When it comes to a big project converted from java to Objc using the tool, xcode won't recognize the sub-directories made. I figured out the best fix is to create your own script using bash. I did some research and figured out how to recursively find all java files and apply the j2objc script to them and it will output all of your Objc files in the same directory layout. (Keeping a nice layout for you instead of the messy-everything-in-one folder like j2objc script rule on Xcode works).
My build.sh file is as follows, feel free to copy it-
!/bin/bash
Clean out Objective C folder
rm -rf /ObjC_Output
Move into Java Folder
cd Java
Run j2objc and output everything into ObjC
j2objc -d ../ObjC_Output $(find . -name "*.java")
Jump out of Java folder
cd ..
Delete previous org
rm -rf /Users/me/Projects/project-name/mobile-app-front-end/app/ios/app/app/org
cd to ObjC_Output
Copy new ObjC Project files over to the XCode project..
cp -R ./ObjC_Output/* /Users/me/Projects/project-name/mobile-app-front-end/app/ios/app/app/org
I automatically copy all my files back to my Xcode project.. feel free to do it anyway you want. Also don't forget to add j2objc to your path. and run your script as such ./builder.sh in terminal..
Also for Xcode to recognize your objC project folder you must add the top directory of your Xcode project and make it recursive.
In this case, you don't need to include the j2objc script in Xcode.. Just make sure you include all the default Linker paths, Library search paths and User Header search path as usual (shown in the j2objc documentation).
I've had to pull my hair out for this solution.. So feel free to ask for help if needed.

Header files are not found while archiving the build in xcode

I have a sub project that has been developed as dynamic lib and included that sub project into my main project and been set as target dependency.
When I run my main project, .a file for my sub project has been created successfully and the corresponding header files are created in the build directory such as (build/release-iphoneos/include). I have mentioned path using MACRO
In my main project, I mentioned header search path as the same that i mentioned above using MACRO.
But when I try to archive the build it throws the run time error file not found in the import statement
#import <subproject/myfile.h>
But it is getting build and run successfully even though it displays the file not found error in the xcode editor in compile time.
My question is
Is this because of the build directory will be empty while archieving?
I solved the problem as below
1. The header files were private so changed them as public so they are exposed to main project. (To build & run successfully)
2. I copied the header files and created a directory and add them into my main project and set the header search path to point that directory (To archive successfully)

Copy an existing Xcode project results in files with wrong references

I have a working project that builds ok. (Xcode 6.0.1)
There were images added that were at one folder (/Downloads) and were substituted by new ones (/MyDir/MyProject).
At adding files process copy options, group and add to it's targets were selected.
After a copy and paste at Finder from the root project folder to the new project some images contain references at Targets / Build Phases / Copy Bundle Resources to old folder (Downloads) while they are ok at original project.
I've deleted the .git from initial project to make sure it's not a git problem.
Already tried
rm -rf ~/Library/Developer/Xcode/DerivedData/
Any ideas? Thank you
In the rightmost panel, which contains Identity and Type, check to see if the "Location" field is Absolute Path, Relative to Group, or Relative to Project, and set each file accordingly to what it should be. Xcode seems to create new files with creative ideas on how this should be set.
check in your project build phases if there are some missing references and delete the one you don't need

XCode: 'Warning: Multiple build commands for output file' but I get error if I delete the duplicate

I get the errors:
Warning: Multiple build commands for output file /Users/me/Library/Developer/Xcode/DerivedData/myapp-csoyvdzaugzkszeagjrtzrfssudr/Build/Products/Debug-iphonesimulator/myapp.app/icon-72.png
Warning: Multiple build commands for output file /Users/me/Library/Developer/Xcode/DerivedData/myapp-csoyvdzaugzkszeagjrtzrfssudr/Build/Products/Debug-iphonesimulator/myapp.app/Default-Landscape#2x~ipad.png
Warning: Multiple build commands for output file /Users/me/Library/Developer/Xcode/DerivedData/myapp-csoyvdzaugzkszeagjrtzrfssudr/Build/Products/Debug-iphonesimulator/myapp.app/Default-Landscape~ipad.png
When I try to run my app in the simulator. I understand this is because of duplicate files. But when I remove either of the duplicates I get the errors:
error: /Users/me/Documents/Cordova27/myapp/myapp/Resources/icons/icon-72.png: No such file or directory
Does anyone know how to fix this at all? Have tried cleaning and restarting XCode to no avail.
open the Copy Bundle Resources Build Phase. find the twice files in that list and Delete the duplicate reference.
Remove both,Add again.[Drag and drop at the icon field in the summary page]
I moved bunch of images to a different folders and hit the same issue. To solve, basically go to build phases >> Copy Bundle Resources and remove earlier references as shown in the picture below.
Note: Another thing to check is to see if you have multiple references of the files in the left panel (you will see 2 files with the same name)
If you set the splash/launch icon from Xcode (Targets -> Summary ...), the Xcode has an annoying feature that will copy your png file into the root folder, and after that you will get the warning for "Multiple build commands". What you need to do is, delete your png file used for splash/launch and also check the copy bundle resources in Target section and make sure your file has been removed from there. It will appear in red if the file is removed from your project and not removed from Copy bundle resources.
My problem was also in Copy Bundle Resources, but my cause was fast lane. All of my fastlane files name.txt, keywords.txt, marketing.txt, etc. were copied from each of my support languages into the bundle.
Go to your target Build Settings. In the search tool, enter the name of each fastlane file. In this case, you can delete all fastlane files. These are used for uploading your bundle to the App Store and so the files don't need to be in the bundle at all.
Add a new image(PNG) only via Copy Bundle Resources. Remove duplicates same way.

Xcode linked project header files not found

Here is the situation I have:
ProjectA - Xcode static library project.
ProjectA contains logical code group ExternLib with file ExternLib.h. ExternLib.h itself is in the folder Classes/lib/ExternLib (relative to ProjectA folder). Within ProjectA, I use ExternLib.h simply as: #import "ExternLib.h". This works fine.
Next I have ProjectB. This includes ProjectA as a linked Xcode project. The target has been added correctly etc. However, when I include a file in ProjectB which in turn includes ExternLib.h, upon building ProjectB, I get an error saying that the file ExternLib.h cannot be found.
I have tried adding the path to ExternLib.h to the header search path (all types: relative, absolute, with recursion etc.) but to no avail. I have checked that static library target has the copy headers step and the file ExternLib.h is included in it.
Anybody able to shed some light on how to get around this?
Add a Run Script Build Phase to the target for ExternLib that executes
mkdir -p "${BUILT_PRODUCTS_DIR}ExternLibHeaders"
Add a Copy Files build phase that copies the ExternLib header files into ${BUILT_PRODUCTS_DIR}ExternLibHeaders, and add all of ExternLib's headers into that phase.
In the app target for ProjectB, add ${BUILT_PRODUCTS_DIR}/ExternLibHeaders/ to the Header Search Paths for all configurations.
In Xcode > Preferences > Build, set the Build Products Directory to some common location.
The fourth step is crucial; it ensures that BUILT_PRODUCTS_DIR is the same for both projects.
It's really hard to say what might have gone wrong.
I'd start from scratch with a tutorial on building and using static libraries, and see if any of the steps jog any ideas out of you.

Resources