Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
889 views
in Technique[技术] by (71.8m points)

objective c - containerURLForSecurityApplicationGroupIdentifier returns nil on iOS Simulator

Context

With iOS8 and extensions Apple introduced the App group containers (more info here).

Problem

We use it through NSFileManager's containerURLForSecurityApplicationGroupIdentifier: method. It works well in production on AppStore (with both iOS8 and iOS7). Problem is since our team updated to Xcode 6.1 (6A1052d), the method returns nil on Simulators.

We searched a lot but we didn't manage to find any clues. Even this question or this one are not applicable here.

TLDR: Question

Does NSFileManager's containerURLForSecurityApplicationGroupIdentifier: method works on your simulators? Is there any way to fix that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The method containerURLForSecurityApplicationGroupIdentifier: works in both device and Simulator.

If you have setup both targets (or Target and WatchKit Extension for instance) that are going to share data to support Groups, and it keeps returning nil, you may want to check your Targets settings.

  1. Target Settings > General > Team > yourCompany signing team should be selected here. If there is a warning and a Fix This Issue button, be good and fix the issue by hitting it :)

  2. Target Settings > Capabilities > App Groups > Is On + shows your group.com.yourcompany.yourapp.sharedContainter group name ("sharedContainer" is my choice name) is selected and is on black (not red). If it's red or there is a warning and Fix This Issue button, renew the group or create a different one.

  3. Target Settings > Build Settings > Code Signing > Code Signing Entitlements: points to your entitlements files for both Debug and Release (something like yourApp/yourApp.entitlements)

  4. Target Settings > Build Settings > Code Signing > Code Signing Identity: Make sure the identity is part of the Team selected above. I use iOS Developer.

  5. Target Settings > Build Settings > Code Signing > Provisioning Profile: As above, make sure the PP you are using is of the Team required. I set it to Automatic.

Check those for both targets sharing data.

I hope it helps


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...