onevcat / XUPorter

Add files and frameworks to your Xcode project after it is generated by Unity 3D.
http://onevcat.com/2012/12/xuporter/
MIT License
597 stars 240 forks source link

Cannot Add Compiler Flag to File #38

Open Exguardi opened 10 years ago

Exguardi commented 10 years ago

It's slightly unclear from the documentation which is the correct syntax for adding a compiler flag to just one file, either:

"files": ["iOS/Script.m:-flag", "iOS/Script.h"],

OR

"compiler_flags": ["iOS/Script.m:-fobjc-arc"]

Either way, I just get told that "the file iOS/Script.m:-fobjc-arc" does not exist; either by Unity in the former case, or Xcode in the latter.

Any ideas what might be going wrong? Thanks!

gforeman commented 10 years ago

per-file compile flags are not supported - adding files doesn't check for additional arguments and "compiler_flags" are global, not per-file.

if I make the mods to my version, i'll ping you. won't be for a few days though...some fires to fight beforehand.

Exguardi commented 10 years ago

Thank you, please let me know, this would be a very helpful feature for my current project.

gforeman commented 10 years ago

updated my version; uses "files": ["iOS/Script.m:-flag", "iOS/Script.h"] syntax.

Exguardi commented 10 years ago

Hi Gary, I snagged your new version; unfortunately it doesn't look like the flag system is working. It just gives me an error like:

Missing file: /Path-to-Project/iOS/Script.m:-fobjc-arc

And then it appears to set the entire project to use ARC (as I immediately get complaints from other files that should be non-ARC).

UPDATE: I tried grabbing the project as a .zip, and now the compiler flag is working properly. Not sure why cloning the repo didn't do it (when I cloned it over originally, it did have the readme that mentioned per-file flags, etc.).

Exguardi commented 10 years ago

Additionally, your version appears to suffer from a bug that was present in an older version of XUPorter; namely, using the "Append" function to build the project out of Unity causes the build to fail after the first build.

Specifically, the error received is:

InvalidCastException: Cannot cast from source type to destination type. UnityEditor.XCodeEditor.PBXParser.Decode (System.String data) (at Assets/Editor/XcodeProjectModifier/PBX Editor/PBXParser.cs:216) UnityEditor.XCodeEditor.XCProject..ctor (System.String filePath) (at Assets/Editor/XcodeProjectModifier/XCProject.cs:86) XCodePostProcess.OnPostProcessBuild (BuildTarget target, System.String pathToBuiltProject) (at Assets/Editor/XcodeProjectModifier/XCodePostProcess.cs:22) UnityEditor.HostView:OnGUI()

gforeman commented 10 years ago

hmmm. it worked for me when i tested it. which version of unity/xcode are you using?

i'm traveling this week, so won't be able to do anything but as soon as i'm back, i'll take a look. thanks for letting me know that my version of xuporter is old too - not sure how that happened, but again, it's been working for me.

Update: my version is based on the latest master from onevcat so i'm not sure how the append issue exists (assuming that it wasn't in their version). can you provide more info re: build settings, mods, xcode & unity versions. i'd like to make sure that my changes are usable ;)

Exguardi commented 10 years ago

I am using Unity 4.5.1p3 on OSX Yosemite 10.10. I'm also seeing the same Append issue with the newest version of onevcat's build, so, that would explain that (although not why it's happening of course).

The issue does not appear when building from scratch, only when using Append-- but not the first time using Append, only subsequent builds. None of the other settings seem to matter (I'm not making a debug build, I am using micro mscorlib, .NET 2.0 subset, target iOS version 5.1).

Exguardi commented 10 years ago

It also appears regardless of what mods are used, just using the library at all does it.

Exguardi commented 10 years ago

Here's something new and odd. I've changed nothing in the project, but now when I'm building out it is not adding the compiler flag to the specific file like it is supposed to.

gforeman commented 10 years ago

don't suppose you know which version had the working append feature - I only ever built fresh. trust issues ;)

re: the no flags... strange. i'll take another look tomorrow when I'm in the office.

dvmrmc commented 9 years ago

I submitted a pullrequest into gforeman's XUPorter version so it's able to include per file and per folder compiler flags (which basically adds a compiler flag to each contained and imported file inside a folder)

emperor1412 commented 9 years ago

this error still exists in current version, I always says that file/directory does not exist.

I used XCode 6.2 (6C131e) and Mac OS Yosemite 10.10.2 my mod fle:

{ "group": "Stripe", "libs": [], "frameworks": ["PassKit.framework:weak"], "headerpaths": [], "files": ["Plugins/iOS/Stripe/StripeError.m:-fobjc-arc"], "folders": ["Plugins/iOS/Stripe/:-fobjc-arc"],
"excludes": ["^..meta$", "^..mdown$", "^.*.pdf$"], "compiler_flags": [], "linker_flags": [] }

Missing file: /Volumes/Data/Projects/TestExportXCode/Assets/Editor/XUPorter/Mods/Plugins/iOS/Stripe/StripeError.m:-fobjc-arc UnityEditor.XCodeEditor.XCProject:ApplyMod(String) XCodePostProcess:OnPostProcessBuild(BuildTarget, String) (at Assets/Editor/XUPorter/XCodePostProcess.cs:29) UnityEditor.HostView:OnGUI()

Folder PATH: /Volumes/Data/Projects/TestExportXCode/Assets/Plugins/iOS/Stripe/:-fobjc-arc UnityEditor.XCodeEditor.XCProject:ApplyMod(String) XCodePostProcess:OnPostProcessBuild(BuildTarget, String) (at Assets/Editor/XUPorter/XCodePostProcess.cs:29) UnityEditor.HostView:OnGUI()

Directory doesn't exist? UnityEditor.XCodeEditor.XCProject:ApplyMod(String) XCodePostProcess:OnPostProcessBuild(BuildTarget, String) (at Assets/Editor/XUPorter/XCodePostProcess.cs:29) UnityEditor.HostView:OnGUI()

Brantone commented 8 years ago

The docs are very misleading on this. They say "Use : for folders and files to add compiler flags to those files."; however, the code doesn't appear to actually support that.

MatthewMaker commented 8 years ago

This feature used to work, but the code for it got clobbered in a merge some time ago.