nemer
nemer

Reputation: 66

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!

Upvotes: 0

Views: 248

Answers (2)

nemer
nemer

Reputation: 66

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.

Upvotes: 0

tball
tball

Reputation: 2044

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.

Upvotes: 1

Related Questions