container-migration.plist doesn't appear to do anything - osx-lion

I have setup my container-migration.plist for migrating my MAS app to the App Sandbox.
It doesn't appear to do anything when I run the app. I have confirmed the file is included in the app bunder resources. No console output is generated saying that items were migrated and the folders and files specified don't appear to be migrated. Instead they are recreated by my app as is the normal process when they don't appear to exist.
When does the migration occur? My app automatically files from within the applicationDidFinishLaunching method. Shouldn't the old files be migrated before this method is called? How can I debug the migration code?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Move</key>
<array>
<string>${ApplicationSupport}/com.company.AppName</string>
<string>${ApplicationSupport}/com.company.AppName/data.sqlite</string>
</array>
</dict>
</plist>

Nevermind... I found I just needed to delete the app folder from the ~/Library/Containers folder to make the migration run again.

Related

Flutter MacOs access to files

I'm trying to build app a custom desktop app in Flutter to be able to load pictures, like a gallery.
To do so, I will ask to the user to pick a folder, and automatically it should show the pictures.
Now, starting from simple things, since it's first time developing for Mac, I'm just trying to display a picture via Image.file(new File) method.
The issue that I got back is
======== Exception caught by image resource service ================================================
The following FileSystemException was thrown resolving an image codec:
Cannot open file, path = 'media/preview.jpg' (OS Error: Operation not permitted, errno = 1)
I'm thinking somehow is related to the entitlements.
What I have on my entitlements is:
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.assets.downloads.read-write</key>
<true/>
<key>com.apple.security.assets.pictures.read-write</key>
<true/>
<key>com.apple.security.assets.downloads.read-write</key>
<true/>
But since the folder from where I want to load the pictures could be anywhere, I wonder if this is the reason why I get the error.
I met the same issue and tackled it by disabling com.apple.security.app-sandbox in example/macos/Runner/DebugProfile.entitlements:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<false/>
</dict>
</plist>
So it seems that as long as your app is in the sandbox it looks like it can only open files outside of those folders (Downloads, Pictures, Music, and Movies) if the user selects them from an open dialog.
So for development purpouse I've disabled the sandboxing, conscious of the fact I could not distribute on the Apple Store.
But at least I can develop. Enjoy
i couldn't access to files which is located in external. But its worked for me thank you so much...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<false/>
</dict>
</plist>

Flutter ios stuck at 'Configuring the default Firebase app'

I don't want the push notification now, though I have added the GoogleService-Info.plist file and code for firebase push notification.
It works on android but having problem in iOS. iOS stuck like this.
I don't know if it will help now...
I found solution at https://firebase.google.com/docs/flutter/setup
It says "Using XCode, move the file into the Runner/Runner directory of your Flutter app."
When, I just copy & paste GoogleService-Info.plist at VSCode, and do flutter run.
It print "Configuring the default Firebase app" infinitly.
But,
1. Execute xcode and open {your_app}/ios
2. drag & drop `GoogleService-Info.plist` at `Runner/Runner`
3. Choose `Finish`
this way fixed error.
I hope it will help other people who have same problem.
The answer should be available here as a quote:
Open Xcode, then right-click on Runner directory and select Add Files to "Runner".
Select GoogleService-Info.plist from the file manager.
A dialog will show up and ask you to select the targets, select the Runner target.
Then add the CFBundleURLTypes attributes below into the [my_project]/ios/Runner/Info.plist file.
<!-- Put me in the [my_project]/ios/Runner/Info.plist file -->
<!-- Google Sign-in Section -->
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<!-- TODO Replace this value: -->
<!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->
<string>com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn</string>
</array>
</dict>
</array>
<!-- End of the Google Sign-in Section -->
I fixed the issue by adding GoogleService-Info.plist again through Xcode.
It appears that adding the file in VS Code sometimes doesn't work.

Resigning an application outside xcode [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have some apps i wanna resign with a different apple developer license,
Problem is, i dont have source code, only the ipa file, the app and the archiveinfo.plist
is it possible for me to resign the app if i dont have the source code?
Thanks!
Ompah
The ability to replace the signature on an already-signed binary is built into the codesign utility. That way, if your developer certificate expires (as they do annoyingly often), you don't have to rebuild your app.
This can be important, especially if you need to support an old app version, and you've made code alterations since you archived your IPA.
I usually use this script. It comes in handy when trading debug build IPAs with people who have their own developer accounts and who I don't want to burn a UDID slot for, and who don't want to have to load my provisioning profiles on their devices.
#!/bin/sh
TEMPDIR=/tmp/$RANDOM-$RANDOM-$RANDOM
RESOURCERULES=/tmp/ResourceRules-$RANDOM$RANDOM.plist
CURRENTDIR=`pwd`
mkdir -p "$TEMPDIR"
cat - > "$RESOURCERULES" <<ResourceRulesPlistDelimiter
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>rules</key>
<dict>
<key>.*</key>
<true/>
<key>Info.plist</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>ResourceRules.plist</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>100</real>
</dict>
</dict>
</dict>
</plist>
ResourceRulesPlistDelimiter
unzip -q "$1" -d "$TEMPDIR" || exit 1
xattr -d -r com.apple.quarantine "$TEMPDIR"
for APPBUNDLE in "`find "$TEMPDIR" -name "*.app"`"; do
codesign --resource-rules="$RESOURCERULES" -f -s "iPhone Developer" "$APPBUNDLE"
codesign -dvvvv -r- "$APPBUNDLE"
done
cd "$TEMPDIR"
zip -qr "$TEMPDIR.zip" "Payload" && cd "$CURRENTDIR" && mv "$1" "$1.bak" && mv "$TEMPDIR.zip" "$1"
cd "$CURRENTDIR"
rm -rf "$TEMPDIR.zip"
rm -rf "$TEMPDIR"
rm -rf "$RESOURCERULES"
This is the most effective and efficient solution I have come up with so far.
Make sure you are using a Mac. This process requires an application for Mac OSX.
Take the .ipa file, rename it to a .zip file.
Extract the zip file, you will see a folder called “Payload” containing a .app file.
Download the Mac OSX app AppResigner here: http://www.gorbster.net/misc/AppResigner.app.zip
Unzip the app. Inside the unzipped folder you will see the Mac App “AppResigner”
Open this app. It will ask you to choose a file. Choose the .app we unzipped from the .ipa file.
It will ask you for a signing identity. Open the Mac App “Keychain Access”. The steps that you will take here may vary slightly. Open the keychain “login” and choose category “Certificates”
Here you need to find the certificate with which you want to resign the app. For example it could be: “iPhone Distribution: Your Company Name”, you will need to have access to your company’s Distribution profile to use a distribution certificate. I have not tried doing this with a development certificate, I don't know if that will work.
Type in this certificate name exactly as it is shown here into the AppResigner prompt; copy / paste was not working correctly for me.
AppResigner should tell you that the app has been resigned.
Find the .app file that you resigned (it is the same one as before) and zip it up. I use the Mac OSX program Keka, but many are available.
Rename the zip file to a .ipa file.
Done!

The application-identifier entitlement is not formatted correctly - iOS Xcode 4

I've migrated to Xcode 4, and can no longer submit my application to the App Store. Every time I submit either via Xcode or Application Loader, I get the same error:
"the application-identifier entitlement is not formatted correctly ... "
Googling this points to the Entitlements.plist file where the application-identifier key should match my application bundle ID: J1234567885.com.domain.appName for example
Thing is, it is. The bundle identifier in my app.plist and in the Entitlements.plist are identical! What am I doing wrong? Here's my Entitlements.plist file (which has never changed looking back):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>application-identifier</key>
<string>J1234567885.com.domain.appName</string>
<key>get-task-allow</key>
<true/>
</dict>
</plist>
I've changed the identifier above, but just to give you an idea...
I had the same problem described by mootymoots. I solved this problem by adding a few additional params to Entitlements.plist.
I'm using TestFlight to deploy the app to a test group, so I felt it important to closely follow TestFlight's instructions for generating an IAP using Xcode 4. Completely removing Entitlements.plist seemed like a hack rather than a solution.
When I used the "New File..." wizard to create the Entitlements.plist, it generated the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>get-task-allow</key>
<true/>
</dict>
</plist>
When I tried creating an archive, it threw the "the application-identifier entitlement is not formatted correctly ..." warning.
Through some Googling, I realized the plist needed two additional params with Xcode variables as their values. See the snippet below for the inclusion of application-identifier and keychain-access-groups. (I do not believe the latter had anything to do with the issue I was having, though)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>get-task-allow</key>
<false/>
<key>application-identifier</key>
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
</array>
</dict>
</plist>
Once I added these params, the archive stopped throwing the warning and I was able to distribute using TestFlight.
Turns out now in Xcode 4+ you do not need an Entitlements.plist for your Release build (or at least, Xcode 4 does something weird with it that Xcode 3 didn't).
Anyway, to fix my issue I simply removed the reference to my Entitlements.plist from the release parameter under 'Code Signing Entitlements' in Build Settings.
Built, Archived, Validated, Submitted to iTunes Connect.
In my case, this was caused by using a wildcard app id for the distribution provisioning profile (com.mycompany.*). Replacing it with a provisioning profile using an absolute app id solved the issue.
In Xcode 4, your entitlements file should not contain the application identifier. Only on your Target -> Summary tab. Also, get-task-allow should be set to False for AppStore submission.
To fix, I would delete your current entitlements.plist file and create a new one using File -> New -> New File. Just use the key get-task-allow = FALSE and try that. Make sure you put your application identifier on the Target -> Summary tab.

Xcode not copying latest resource file to iPhone

I'm writing an iPhone app in Objective-C with Xcode and I have some Lua scripts that run on the device.
I'm having an issue where if I edit a Lua script, save, flick over to Xcode and Build and Run (⌘Y) the latest version of that Lua script is copied into the app bundle but not copied to the device.
The scripts aren't in the Xcode project, I edit them in Textmate. I have a build step which copies the scripts into the app bundle and touches the files, this is being run fine and the latest script version is in the app bundle when I run the app. The files have all been touched, but for some reason when copying the bundle to the device Xcode decides not to copy the latest.
If I stop the app and then Build and Run (⌘Y) again, the latest version is copied across.
My workaround is to save the Lua file, then in Xcode do a Build (⌘B) and then Build and Run (⌘Y), so build the app twice. This always seems to copy the latest version to the device.
Update:
As many have noted, one solution is to clean the targets and rebuild. You can do this, you could also build twice as I have noted above. This problem is easily reproducible (in my setup it happens every time, regardless of how recently the targets were cleaned). I'm hoping for a more reliable/permanent solution
You should definitely add those files to your Xcode project. You can still edit them in your other editor, but Xcode will include them in your bundle automatically if you add it to the project. If they aren't getting copied when you build, this is how I resolve it:
Right click on the file in Xcode and choose "Touch" which updates the timedate stamp on the file, so it looks "new".
On the simulator, choose Reset Content and Settings from the File Menu.
In Xcode, do a Build Clean
When you build and run after that it should install the file just fine.
EDIT:
To add external folders to your project that will get included in your bundle and preserve the folder structure intact, all you need to do is:
Click on the project icon at the top of the file list on the left.
Click the Project menu and Add to Project.
Select the folder you want to include and click Add.
Unchecked the Copy checkbox and change "Recursively create groups for any added folders" to "Create Folder References for any added folders".
When the target is built, open up the bundle and your directory structure will exist inside fully intact.
First of all: I feel your pain. I haven't found any good documentation on rolling up your sleeves and digging into the iOS build pipeline if you want to do some interesting (or even just simple) data pipelining using custom scripts.
Second of all: I don't agree that you need to, or even should put all your assets in your Xcode project. That's really a matter of personal preference, and if you've got a complicated enough project, Xcode becomes a beast to navigate your code alone as it is, let alone with all your art assets and data files.
Third: Cleaning is a work-around, as is touching an individual source-code file (Xcode will pick up on this and do the signing/touching of the master directory for you without the need to do a clean build -- a clean build is extremely time consuming if you have a large project or significant assets), but these are really just hacks to get the thing to work without fixing the underlying problem: you need to hit the right dependency to get the copy step to kick in.
I had the same issues you're describing here with the following differences:
I'm using a gnu make script to process art resources (audio, data files, images) by doing some basic manipulations (compression, stripping out un-needed things, building fonts, etc). I'm using gnu make because 1.) I know it 2.) I find it easier to put all my rules into one script 3.) I like to keep my data folder nice and hierarchical and 4.) Xcode isn't always the way you want to interface/organize/manage all your data! (though I think it does a great job for code and even small amounts of data in a less complex project)
Anyhow, what I found is that I really had 2 problems: 1.) Code signing and 2.) Copying. The copying is easy, all you need to do is touch the build products folder. In my case I added the following to my make file: "touch $(DIR_CONTENTS)" where I defined "$(DIR_CONTENTS)" using the existing env parms provided by Xcode to the shell when my Xcode is executed: "DIR_CONTENTS = $(BUILT_PRODUCTS_DIR)/$(CONTENTS_FOLDER_PATH)" (you can see the full list of env parms if you click on the 3 horizontal lines in the output log). In your case you'd need to do the equivalent in your lua script. Not sure what that entails, I've been purposely dodging lua for years, but I can't imagine it's too crazy.
The next bit is trickier, 'cuz what I found was that just because you've updated, doesn't mean that the code signing stuff works nicely. In my case I needed to add a ResourceRules.plist file and add my art directory (art/.*) as a dictionary, with a line to omit and a weight. I couldn't find docs on this anywhere, so I copied the ResourceRules.plist file from the generated folder into my source folder, added it to the project, and then pointed the code signing stuff at it. (This would be in the build rules under Code Signing: it'll be your "Code Signing Resource Rules Path")
This isn't really my ideal solution, by the way. I would rather be able to trigger the code-signing step via my script if my data changes, but as I stated earlier I haven't found any useful docs in apple's developer library on how to really dig into the custom builds. You can do the code signing by hand, but I didn't like it.
Hope that helps.
UPDATE:
I figured I'd add some example code.... here are some relevant excerpts from my makefile:
# Near the beginning, where I do my variables n' such, I define the
# directory in a variable. Note that BUILD_PRODUCTS_DIR and CONTENTS_FOLDER_PATH
# are environment variables set by XCode and will be filled with the corresponding
# paths
DIR_CONTENTS = $(BUILT_PRODUCTS_DIR)/$(CONTENTS_FOLDER_PATH)
DIR_DEST_ART = $(DIR_CONTENTS)/art
DIR_DEST_FONTS = $(DIR_DEST_ART)/fonts
# ... more folders defined here...
DIR_SRC_FONTS = $(SRCROOT)/source-art/fonts
# ... more folders defined here...
# ... do some useful build stuff ...
# This is an example of my rule that takes the .png's built by my font script
# and compresses them to .pvrs (note: this isn't final, so YMMV). The thing to
# note here is that if this rule kicks off, the last thing that will happen is
# that I will touch my DIR_CONTENTS folder, which will kick off the copy to the
# device. I find having to touch the folder really annoying, I prefer the way xcopy
# and similar copy methods recursively travel & update if required.
$(DIR_DEST_FONTS)/%.pvr : $(DIR_SRC_FONTS)/%.png
#echo == Compress $(subst $(SRCROOT),src,$<) to $(subst $(DIR_DEST_ART),dest,$#) ===
#mkdir -p $(dir $#)
#xcrun -sdk iphoneos texturetool -e PVRTC -o $# -f PVR $<
#touch $(DIR_CONTENTS)
Then, in order to deal with the code signing problem, I edited my ResourceRules.plist to look like the below. The area to pay attention to is the key that starts with "art/.*"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>rules</key>
<dict>
<key>.*</key>
<true/>
<key>art/.*</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<integer>0</integer>
</dict>
<key>Info.plist</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>ResourceRules.plist</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>100</real>
</dict>
</dict>
</dict>
</plist>
For reasons I am yet to understand, sometimes the build process seems to get forgetful or simply unreliable.
Usual troubleshooting for this type of scenario is to clean all in Xcode, and at the same time delete the app from the phone.
Why are the scripts not in the Xcode project? They can still be in the project while you use Textmate to edit them. Perhaps including them in the Xcode project will make it more likely that they get transferred to the device?
Sounds like you have an "one-off" kind of a problem, in which your updated scripts make it "too late" to the bundle. Have you tried changing the order of the build phases, in particular moving the copy phase not to be at the end but before the compile and link phases?
I work on this in device build when resource updated:
In Xcode, Right Click your .app file in Products Group
Choose 'Show in Finder'
Clean the files that where .app file located
Run again
this works fine for me on device building that won’t cost much time.
Clean all targets in Xcode
Restart Xcode
Try to install on the device
I see this problem once in a while with a sqlite database that I have included in my project. Sometimes it just doesn't get the updated version.
Typically my fix for this is to go into the Application Support/iPhone Simulator folder and delete the app inside the Application folder and also delete the Caches folder.
This will force the Simulator to reconstruct all of this and get fresh files.
I had a similar problem auto-copying a script file, when changed. Had set its Type to "C" to allow for auto syntax highlighting. Had added the file to "Build Phases / Copy Bundle Resources". But no luck; changes to the file would not update the bundle.
The fix, in this case, was to change the Type from "C" to "JSON". Now, it updates the bundle automatically on the device. Makes sense, since source files are rarely needed for a binary. Originally, Apple didn't allow any scripting.
I had the same problem today using Xcode 11.1. I tried deleting the app from my device, cleaning the project and rebuilding, deleting the resources and re-adding them to the project, none of which worked.
What eventually worked was this: I opened the project window, then went to 'Build Phases', then opened 'Copy Bundle Resources' and simply moved some of the resources up and down in the list. I suppose that told Xcode that something had changed.
Use Trouble Shooting
Clean the Xcode Projects
Build and Run