Mac app crashes on launch, linked framework not bundled - frameworks

(Edit: I was able to bundle the framework but it still would not take the changed installation directory. So, below, the question has changed to "linked and bundled framework image not found")
The Mac app was submitted to MAS but rejected by Apple, for a very reasonable reason: a framework that was linked was not bundled.
I simply ask how I can make sure it is included correctly in the bundle, and confirm that on my Mac before submitting again.
Please let me know what/any extra information you need from me.
Edit: More information after following subzero's instructions.
When going Product > Build, .app files end up in Documents/build/Release on my machine.
Here's how my build phases look - https://dl.dropbox.com/u/19155207/copyframeworks.jpg
and a UIKit.Framework folder is inside WinKonto.app/Contents/Frameworks containing this: https://dl.dropbox.com/u/19155207/frameworksfolder.jpg
It still gives the same error if I run it from the Releases folder. Only when I run it from XCode it works. Can you see something wrong?
Edit 2: I've gotten the framework file (UIKit) into the bundle.
Here is the crash report error message:
Dyld Error Message: Library not loaded:
Frameworks/UIKit.framework/Versions/A/UIKit Referenced from:
/Users/henrikerlandsson/Documents/build/Release/WinKonto.app/Contents/MacOS/WinKonto
Reason: image not found
But the framework is in the bundle, and it was modified by install_name_tool before being added to the project.
I don't know why that modification didn't work, but I made it a private framework instead and changed the installation directory there instead, and it worked (see my answer).

In XCode,
Add a Copy Files build phase to your application's target
Move this above the Link phase set its destination to myApp.app/Contents/Frameworks and add the framework to it.

I made it a private framework. I followed the instructions under Embedding a Private Framework in Your Application Bundle, and that let me set the framework's Installation Directory properly to where it appeared in the bundle.

Related

ERROR ITMS-90259: "Bad Bundle Executable. You must include a valid CFBundleExecutable key in your bundle's information property list file

I'm working on a multi-platform iOS and Mac app. When I try and Archive and Distribute to the App Store I run into this issue:
ERROR ITMS-90259: "Bad Bundle Executable. You must include a valid CFBundleExecutable key in your bundle's information property list file."
Verified that the Info.plist for the Mac target has a CFBundleExecutable
Tried Xcode 12 & 13
Tried using App Transporter
Used Xcode 13 RC and let that auto-generate the Info.plist
I've tried everything I could find online - there's not much - and I can't get the upload to succeed.
However, I was able to replicate the issue with an entirely empty project. No dependencies, no code, nothing. The project archives successfully, but the upload fails.
Any help would be appreciated. I've spent two days on this already.
An example project that fails: https://drive.google.com/file/d/1qUN5lHEWNyNHQV54fYPXMeRsuO-cpHqW/view?usp=sharing
We had two issues causing this, making it fail when uploading a Mac build to iTunes. The first issue, we had included a package (from Steam), that had its own plist and post build script.
com.rlabrecque.steamworks.net/Editor/RedistCopy.cs - build script
com.rlabrecque.steamworks.net/Plugins/steam_api.bundle.meta - folder with plugin and plist
We renamed the post build script and removed the plugin folder, not 100% sure if the renaming was needed.
Then, we had this in our own post build script that was causing issues, so we removed it too.
rootDict.SetString("CFBundleExecutable", "${EXECUTABLE_NAME}");
Then it worked! Also worth noting that we believe the CFBundleExecutable didnt actually end up matching the file name e.g. the file produced was a.pkg and the plist says:
<key>CFBundleExecutable</key>
<string>b</string>
But seems iTunes was ok with that. We use Unity and it seems in the pList the string was set to the "Product Name" (Edit > Project Settings > Player, at the top, "Product Name").
We also didnt need to use Transporter to upload.

Suppress warning: The Swift file cannot be processed by a Copy Bundle Resources build phase

I have an app that uses a Swift framework that contains an intentdefinition file. I use CocoaPods to manage/distribute my frameworks, so, in order for Siri to successfully find the app and extension so that she can respond, I needed to add a "Build Phases"/"Copy Bundle Resources" step that copies the intentdefinition file from the framework into the app's main bundle.
Please see this question and answer for more background about this question.
The app and extension are working properly, now, but at compile time I get warnings for each intent:
"The Swift file
'.../DerivedSources/IntentDefinitionGenerated/*Intents/*Intent.swift'
cannot be processed by a Copy Bundle Resources build phase"
While this statement is true, it is not relevant in this case, since the framework will process the files.
How can I suppress this warning?
Check if the files mentioned in the warning are there in Build Phases > Copy Bundle Resources Simply remove from there and warning will be gone.

Copying facebook-ios-sdk and configuring the Xcode project

I have gone through this document :Getting Started with the Facebook SDK for iOS v3.1
I have successfully configured my Xcode project by following it.
But I want to do it without adding the Facebook.framework.
As previously we used to only add the "src" folder which we used to clone from :Facebook SDK for iOS - Github. Why can't I just copy the "src" folder and configure my project.
I want to play around with FBFriendPickerViewController.m (dot m) file. Which I am not able to view if I follow the standard tutorial. But is available in the "src" folder.
Please how can I do that ? And it also seems that FbGraph.h file doesn't exist.
Please help.
If you want to play with the source, go to:
https://github.com/facebook/facebook-ios-sdk/
After getting the code, run this script to build the framework locally:
<Install Location>/scripts/build_framework.sh
This will drop the framework in the folder:
<Install Location>/build
Follow the same instructions in the Getting Started to include the Facebook SDK, however, you will get the framework from your local build folder.
Note: You'll likely have to modify the build search path in Xcode if you're swapping out, say one of the sample projects (that was looking for the Framework in a particular place).

iPhone application build fails with "dyld: Library not loaded: /System/[...]" error? Why?

For my own reasons and not for the app store I am referencing the Apple private framework Apple80211 in an iPhone app. I got the framework from an earlier version of the iPhone SDK.
I added the "existing framework", verified that that absolute path to the framework is
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/System/Library/PrivateFrameworks/Apple80211.framework
and tried to build the app.
But the build (to device) fails with the error
dyld: Library not loaded: /System/Library/PrivateFrameworks/Apple80211.framework/Apple80211
Referenced from: /var/mobile/Applications/3691587D-87AF-44EA-A505-F73D17F39B3B/iWire2.app/iWire2
Reason: image not found
I cannot figure out why Xcode would look for the library in a /System path (instead of using the path given in the frameworks list) or how to change that behaviour.
I tried the tricks I found here and elsewhere for similar (and identical) sitiations:
Delete the myusername.* files in the xcodeproj bundle
Delete the build directory
Clean all targets
Start new project
Result is always the same.
How can I add this (or a) framework to an iPhone project AND get Xcode to at least look at the library located where I point to rather than a location in /System?
You can try to open project file with text editor, found records for that library, and check which exact path is stored there. Probably, XCode added some defines inside it.

dyld: Library not loaded - When app run from the command line

I face some difficulties when adding a framework to my project when i run an iPhone app from the command line.
My final goal is to run applications tests from an automated build process.
When i run my app from xCode :
I add a "Copy File" build phase to my target and everything goes fine.
The copy is set to $(BUILT_PRODUCTS_DIR) as "Absolute path"
When i run my app from the terminal (using iphonesim project) i get this error :
dyld: Library not loaded: #rpath/OCMock.framework/Versions/A/OCMock
UIKitApplication:indemnisation[0xb894][26380] Referenced from: /Users/Admin/Library/Application Support/iPhone Simulator/User/Applications/CD5729B5-A674-49B2-91F6-AD398094B6F8/indemINT.app/indemINT
What i dont understand is that the copy build phase just copies the framework files in the same directory as the app.
When i run the app from the command line the framework files are already in the same directory. Does anyone knows why it doesn't work ?
I've also tried to add the OCMock.framework in the following directories (without success) :
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library
/Library/Frameworks
/Users/Admin/Library/Application Support/iPhone Simulator/User/Applications/CD5729B5-A674-49B2-91F6-AD398094B6F8
Thanks in advance,
Vincent.
I just had this same exact error in Xcode 4.2 (4D199) on Lion. I dragged/dropped the OCMock.framework folder into my project and selected the "copy files" checkbox. I saw the above answers and realized I neglected to add a "Copy Files" build phase to move the framework into place. I added one and dragged it right after the compile files build phase and tried to run my tests again. I couldn't get it to work until I had changed the destination in the "Copy Files" phase to the "Products Directory". Using "Frameworks" or "Shared Frameworks" did not work.
The iPhone does not support traditional Mac OS X frameworks. While the iPhone does use folders that end in ".framework", these folders are structured differently than typical Mac OS X frameworks. Most notably, iPhone frameworks are only permitted to use static libraries, while typical Mac OS X frameworks are dynamically loaded. That the message comes from dyld indicates that you are using a shared libary; however, applications targetting the iPhone may only be statically linked.
OCMock is distributed as a framework, and the iPhone does not allow you build your own arbitrary frameworks (there are good reasons to do this on a device with only 128MB of RAM and no swap).
The solution I see in a lot of places around the web is to put OCMock.framework in /Library/Frameworks or anywhere else in the standard framework search paths. This isn’t a very good solution: your build system is now dependent upon the state of your particular machine. Not good.
Another option would be to add the source for OCMock to your unit test target. This would work but is unnecessary, as your tests will never run on the iPhone,2 so why bother building them for ARM? Executables built for the iPhone simulator, being Mac OS X binaries, can link against dynamic libraries just fine. We can use this to our advantage.
What follows is what I believe is the best way to get OCMock working with iPhone projects:
First, add OCMock.framework to your project. Make sure that it’s being added to your Unit Tests target, not your application.
Next, add a Copy Files phase to your Unit Tests target. Set it up like so:
Destination :Absolute Path
Full Path :$(BUILT_PRODUCTS_DIR)
Now, drag OCMock.framework onto your new Copy Files phase to add it to the list of files to be copied.
Finally, drag the Copy Files phase, which I renamed it to “Copy OCMock”, between the Compile Sources and Link Binary With Libraries phases.
That’s it! Run (and by run I mean build) your tests and everything should work correctly.