Sharing SWIFT files between 2 targets?

Hi!


Today I tried to upload my tvOS app to app store and had this error message:


ERROR ITMS-90171: "Invalid Bundle Structure - The binary file 'TV Hi Nano.app/SceneWithTaphere.o' is not permitted. Your app can’t contain standalone executables or libraries, other than the CFBundleExecutable of supported bundles. Refer to the Bundle Programming Guide at https://developer.apple.com/go/?id=bundle-structure for information on the tvOS app bundle structure."


It seems that I cannot have SWIFT file in "Copy Bundle Resources" in my target's settings. But if I don't have this file in bundle resources, then app does not complie because it cannont find the class. Although I have this file in "Compile sources" section!


So how can I have this file shared between tvOS and iOS targets without including it in "Copy Bundle Resources"?


Thank you!

The weird thing is that when I go to file I need for this target and click to "Target Membership" box and try to compile the app once again the target membership checkbox becomes deselected by itself!

https://forums.developer.apple.com/message/188816#188816


"By removing the swift file it fix the uploading and Xcode8 from crashing." But how can I remove it?

The file "SceneWithTaphere.o" is not a Swift file, it's an object code file (though it may have been compiled from a Swift source file). You cannot and should not copy it to your app bundle.


The real problem is the question of why the Swift source file won't compile once for each target that it belongs to (and/or why it won't stay selected for both targets). It's not clear why this should be happening, but that's the area you need to look at further.

>The weird thing is that when I


Did you throw in an 'option-clean build folder' as well? Xcode might be clinging to indexed flags, otherwise thwarting and ignoring your intentions, so....

So I find the solution partly.


If I go to "Build Rules" and find "Copy swift files using script" and push the button "Add to target" then all my error disappear and the project compiles sucessfully.


The app runs ONE TIME.


It crashes with error that some library is missing. But when I am trying to fix something with the libraries the simulator crashes with the error "The file “<appName>.app” couldn’t be opened because you don’t have permission to view it".

And nothing can fix it. I tried all the different solutions from stackoverflow, but it's a dead end.

There is no such build rule in a standard Xcode installation, nor has there ever been AFAIK. It sounds like your Xcode has been modified somehow.


Note that it's unlikely you'd ever want to copy a Swift-language source file to the resources of an app bundle. There are other meanings of "SWIFT", so perhaps this is related to a 3rd-party library you're using in your app?

Hi Quincey.


I don't use 3rd-party libraries.


> Note that it's unlikely you'd ever want to copy a Swift-language source file to the resources of an app bundle.


I know it's a mistake. But I did that to make my new target work with the swift-language source files from my old target. Now I removed all swift-files from 'Copy Bundle Resources" and try to make the target work.

Here's the build rule that makes XCode recognize that my swift files belong to tvos target.


XCode is not modified.


http://learnwithpleasure.com/img/xcode-screenshot.png

So I created the project from the scratch and copied all my source files into it.


Everything works fine.


BTW, when you create sample project for SpriteKit game in XCode it does not work (crashes when trying to read gamescene.sks).


Too bad. Sometimes we have to waste hours of efforts because of Xcode bugs.

Sharing SWIFT files between 2 targets?
 
 
Q