dcariola / XCodeEditor-for-Unity

XCode 4 project editor for Unity3D postprocess.
MIT License
217 stars 101 forks source link

IOException: Sharing violation on path .../project.pbxproj #2

Open frarees opened 11 years ago

frarees commented 11 years ago

After a standard iOS build, there's a chance I get this exception.

Stacktrace:

IOException: Sharing violation on path /Users/frarees/Desktop/sandbox/Unity-iPhone.xcodeproj/project.pbxproj
System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.IO/FileStream.cs:320)
System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share)
(wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
System.IO.StreamWriter..ctor (System.String path, Boolean append, System.Text.Encoding encoding, Int32 bufferSize) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.IO/StreamWriter.cs:124)
System.IO.StreamWriter..ctor (System.String path, Boolean append)
(wrapper remoting-invoke-with-check) System.IO.StreamWriter:.ctor (string,bool)
System.IO.File.CreateText (System.String path) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.IO/File.cs:159)
UnityEditor.XCodeEditor.XCProject.Save () (at Assets/Editor/XCodeEditor/XCProject.cs:958)
XCodePostProcess.OnPostProcessBuild (BuildTarget target, System.String path) (at Assets/Editor/XCodePostProcess.cs:21)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

I suppose this is due to Xcode being launched (pbxproj is being read) while it's still writing on Xcode files.

dcariola commented 11 years ago

Well... yes, I think your issue is due an access to the already open file. It never happen to me, and Unity should call xcode only after the postprocess events are complete. What unity and xcode version are you on?

frarees commented 11 years ago

Latest (Unity Pro 4.0.0f7 & Xcode 4.5.2)

dcariola commented 11 years ago

I still not have tested it on Unity 4, as I'm still on 3.5 until some projects get completed. I'll give it a try soon, maybe there are some different behaviours.